40 public static class CustomRaidObjective
extends BaseGroundRaidObjectivePluginImpl {
41 public CustomRaidObjectiveAdder adder;
43 public CustomRaidObjective(CustomRaidObjectiveAdder adder) {
44 super(adder.market,
null);
46 int marines = adder.danger.marineTokens;
47 setMarinesRequired(marines);
50 public boolean withContinueBeforeResult() {
55 public String getQuantityString(
int marines) {
59 public String getValueString(
int marines) {
62 public float getValueSortValue() {
63 return super.getValueSortValue();
65 public int getCargoSpaceNeeded() {
68 public int getFuelSpaceNeeded() {
71 public int getProjectedCreditsValue() {
74 public RaidDangerLevel getDangerLevel() {
78 public int getValue(
int marines) {
81 public float getQuantitySortValue() {
82 float add = adder.name.hashCode();
83 return QUANTITY_SORT_TIER_0 + add;
85 public String getName() {
89 public String getIconName() {
93 public float getQuantity(
int marines) {
96 public int performRaid(CargoAPI loot, Random random,
float lootMult, TextPanelAPI text) {
101 public boolean hasTooltip() {
102 return adder.tooltip !=
null;
106 public void createTooltip(TooltipMakerAPI t,
boolean expanded) {
107 t.addPara(adder.tooltip, 0f);
111 public static class CustomRaidObjectiveAdder
implements EveryFrameScript, GroundRaidObjectivesListener {
112 protected boolean done =
false;
116 public String trigger;
117 public String tooltip;
119 public boolean showInCustomOnly;
120 public RaidDangerLevel danger;
121 public MarketAPI market;
122 public SectorEntityToken entity;
124 public CustomRaidObjectiveAdder(MarketAPI market, SectorEntityToken entity, String icon, String name, String trigger,
int xp, RaidDangerLevel danger,
boolean showInCustomOnly, String tooltip) {
125 this.market = market;
126 this.entity = entity;
129 this.trigger = trigger;
130 this.tooltip = tooltip;
132 this.danger = danger;
133 this.showInCustomOnly = showInCustomOnly;
134 for (CustomRaidObjectiveAdder adder :
Global.
getSector().getListenerManager().getListeners(CustomRaidObjectiveAdder.class)) {
135 if (adder.name.equals(name) && adder.trigger.equals(trigger)) {
142 public void advance(
float amount) {
143 if (amount > 0 && !done) {
144 for (CustomRaidObjectiveAdder adder :
Global.
getSector().getListenerManager().getListeners(CustomRaidObjectiveAdder.class)) {
145 if (adder.name.equals(name) && adder.trigger.equals(trigger)) {
153 public boolean isDone() {
156 public boolean runWhilePaused() {
159 public void modifyRaidObjectives(MarketAPI market, SectorEntityToken entity, List<GroundRaidObjectivePlugin> objectives, RaidType type,
int marineTokens,
int priority) {
160 if (priority != 0)
return;
162 if (type == RaidType.DISRUPT)
return;
163 if (type != RaidType.CUSTOM_ONLY && showInCustomOnly)
return;
165 if (type == RaidType.CUSTOM_ONLY && entity !=
null &&
166 entity.getMemoryWithoutUpdate().contains(
"$raidRestrictToTrigger")) {
167 String restrict = entity.getMemoryWithoutUpdate().getString(
"$raidRestrictToTrigger");
168 if (restrict !=
null && !restrict.isEmpty() && !restrict.equals(trigger)) {
173 if ((this.market !=
null && market == this.market) ||
174 (this.entity !=
null && entity == this.entity)) {
175 CustomRaidObjective custom =
new CustomRaidObjective(
this);
176 objectives.add(custom);
180 public void reportRaidObjectivesAchieved(RaidResultData data, InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
181 boolean found =
false;
182 for (GroundRaidObjectivePlugin obj : data.objectives) {
183 if (obj instanceof CustomRaidObjective) {
184 CustomRaidObjective custom = (CustomRaidObjective) obj;
185 if (custom.adder ==
this) {
193 dialog.getInteractionTarget().getMemoryWithoutUpdate().set(
"$raidMarinesLost", data.marinesLost, 0);
201 public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Token> params, Map<String, MemoryAPI> memoryMap) {
202 String icon = params.get(0).getString(memoryMap);
203 String name = params.get(1).getStringWithTokenReplacement(ruleId, dialog, memoryMap);
204 RaidDangerLevel danger = RaidDangerLevel.valueOf(RaidDangerLevel.class, params.get(2).getString(memoryMap));
205 int xp = (int) params.get(3).getFloat(memoryMap);
206 String trigger = params.get(4).getString(memoryMap);
208 boolean showInCustomOnly =
false;
210 String tooltip =
null;
211 if (params.size() > 5) {
212 if (params.size() > 6) {
213 showInCustomOnly = params.get(5).getBoolean(memoryMap);
214 tooltip = params.get(6).getStringWithTokenReplacement(params.get(5).getString(memoryMap), dialog, memoryMap);
216 String str = params.get(5).getString(memoryMap);
218 if (str.toLowerCase().equals(
"true") || str.toLowerCase().equals(
"false")) {
219 showInCustomOnly = params.get(5).getBoolean(memoryMap);
221 tooltip = params.get(5).getStringWithTokenReplacement(params.get(5).getString(memoryMap), dialog, memoryMap);
227 SectorEntityToken entity = dialog.getInteractionTarget();
228 MarketAPI market = entity.getMarket();
230 new CustomRaidObjectiveAdder(market, entity, icon, name, trigger, xp, danger, showInCustomOnly, tooltip);