mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-07 22:13:40 -04:00
Added survey checks for professions without the surveying skill mod
This commit is contained in:
+27
-7
@@ -2,6 +2,8 @@ package com.projectswg.holocore.resources.support.objects.radial.object.survey;
|
||||
|
||||
import com.projectswg.common.data.radial.RadialItem;
|
||||
import com.projectswg.common.data.radial.RadialOption;
|
||||
import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage;
|
||||
import com.projectswg.common.network.packets.swg.zone.chat.ChatSystemMessage.SystemChatType;
|
||||
import com.projectswg.holocore.intents.gameplay.crafting.survey.StartSurveyToolIntent;
|
||||
import com.projectswg.holocore.resources.gameplay.crafting.survey.SurveyToolResolution;
|
||||
import com.projectswg.holocore.resources.support.global.player.Player;
|
||||
@@ -12,6 +14,7 @@ import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.ServerAttribute;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject;
|
||||
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject;
|
||||
import me.joshlarson.jlcommon.log.Log;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,9 +33,10 @@ public class ObjectSurveyToolRadial extends UsableObjectRadial {
|
||||
if (creature == null)
|
||||
return;
|
||||
|
||||
options.add(RadialOption.create(RadialItem.ITEM_USE));
|
||||
RadialOption [] toolOptions = getResolutions(creature);
|
||||
List<SurveyToolResolution> resolutions = SurveyToolResolution.getOptions(creature);
|
||||
RadialOption [] toolOptions = getResolutions(resolutions);
|
||||
|
||||
options.add(RadialOption.create(RadialItem.ITEM_USE));
|
||||
if (toolOptions.length == 0)
|
||||
options.add(RadialOption.create(RadialItem.SERVER_ITEM_OPTIONS, "Tool Options"));
|
||||
else
|
||||
@@ -43,13 +47,21 @@ public class ObjectSurveyToolRadial extends UsableObjectRadial {
|
||||
public void handleSelection(Player player, SWGObject target, RadialItem selection) {
|
||||
if (!(target instanceof TangibleObject))
|
||||
return;
|
||||
CreatureObject creature = player.getCreatureObject();
|
||||
if (creature == null)
|
||||
return;
|
||||
List<SurveyToolResolution> resolutions = SurveyToolResolution.getOptions(creature);
|
||||
if (resolutions.isEmpty()) {
|
||||
creature.sendSelf(new ChatSystemMessage(SystemChatType.PERSONAL, "@error_message:survey_cant"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (selection) {
|
||||
case ITEM_USE:
|
||||
if (target.getServerAttribute(ServerAttribute.SURVEY_TOOL_RANGE) == null)
|
||||
startToolOptionMenu(player, (TangibleObject) target, true);
|
||||
else
|
||||
new StartSurveyToolIntent(player.getCreatureObject(), (TangibleObject) target).broadcast();
|
||||
new StartSurveyToolIntent(creature, (TangibleObject) target).broadcast();
|
||||
break;
|
||||
case SERVER_SURVEY_TOOL_RANGE:
|
||||
case SERVER_ITEM_OPTIONS:
|
||||
@@ -65,11 +77,12 @@ public class ObjectSurveyToolRadial extends UsableObjectRadial {
|
||||
case SERVER_MENU8: target.setServerAttribute(ServerAttribute.SURVEY_TOOL_RANGE, 8); break;
|
||||
case SERVER_MENU9: target.setServerAttribute(ServerAttribute.SURVEY_TOOL_RANGE, 9); break;
|
||||
default:
|
||||
Log.t("Used unknown selection: %s", selection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private RadialOption [] getResolutions(CreatureObject creature) {
|
||||
private RadialOption [] getResolutions(List<SurveyToolResolution> resolutions) {
|
||||
List<RadialOption> options = new ArrayList<>();
|
||||
RadialItem [] menuItems = new RadialItem[]{
|
||||
RadialItem.SERVER_MENU1,
|
||||
@@ -83,7 +96,7 @@ public class ObjectSurveyToolRadial extends UsableObjectRadial {
|
||||
RadialItem.SERVER_MENU9,
|
||||
};
|
||||
|
||||
for (SurveyToolResolution resolution : SurveyToolResolution.getOptions(creature)) {
|
||||
for (SurveyToolResolution resolution : resolutions) {
|
||||
int menuItemIndex = resolution.getCounter()-1;
|
||||
if (menuItemIndex < 0 || menuItemIndex >= menuItems.length)
|
||||
continue;
|
||||
@@ -97,12 +110,19 @@ public class ObjectSurveyToolRadial extends UsableObjectRadial {
|
||||
if (creature == null)
|
||||
return;
|
||||
|
||||
List<SurveyToolResolution> resolutions = SurveyToolResolution.getOptions(creature);
|
||||
if (resolutions.isEmpty())
|
||||
return;
|
||||
|
||||
SuiListBox window = new SuiListBox("STAR WARS GALAXIES", "@survey:select_range");
|
||||
for (SurveyToolResolution resolution : SurveyToolResolution.getOptions(creature)) {
|
||||
for (SurveyToolResolution resolution : resolutions) {
|
||||
window.addListItem(String.format("%dm x %dpts", resolution.getRange(), resolution.getResolution()), resolution);
|
||||
}
|
||||
window.addOkButtonCallback("rangeSelected", (event, params) -> {
|
||||
SuiListBoxItem item = window.getListItem(SuiListBox.getSelectedRow(params));
|
||||
int selectedRow = SuiListBox.getSelectedRow(params);
|
||||
if (selectedRow < 0 || selectedRow >= window.getList().size())
|
||||
return;
|
||||
SuiListBoxItem item = window.getListItem(selectedRow);
|
||||
SurveyToolResolution resolution = (SurveyToolResolution) item.getObject();
|
||||
surveyTool.setServerAttribute(ServerAttribute.SURVEY_TOOL_RANGE, resolution.getCounter());
|
||||
if (startToolWhenClosed)
|
||||
|
||||
Reference in New Issue
Block a user