Starsector API
Loading...
Searching...
No Matches
DwellerHullmod.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat.dweller;
2
3import java.util.LinkedHashMap;
4import java.util.Map;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.combat.BaseHullMod;
8import com.fs.starfarer.api.combat.CombatEngineAPI;
9import com.fs.starfarer.api.combat.MutableShipStatsAPI;
10import com.fs.starfarer.api.combat.ShipAPI;
11import com.fs.starfarer.api.combat.ShipAPI.HullSize;
12
19public class DwellerHullmod extends BaseHullMod {
20
21 public static Map<String, DwellerShipCreator> SHIP_CREATORS = new LinkedHashMap<>();
22
23 static {
24 //SHIP_CREATORS.put("shrouded_tendril", new TestDwellerShipCreator());
25 SHIP_CREATORS.put("shrouded_tendril", new ShroudedTendrilShipCreator());
26 SHIP_CREATORS.put("shrouded_eye", new ShroudedEyeShipCreator());
27 SHIP_CREATORS.put("shrouded_vortex", new ShroudedVortexShipCreator());
28 SHIP_CREATORS.put("shrouded_maw", new ShroudedMawShipCreator());
29 SHIP_CREATORS.put("shrouded_maelstrom", new ShroudedMaelstromShipCreator());
30 SHIP_CREATORS.put("shrouded_ejecta", new ShroudedEjectaShipCreator());
31 }
32
33
34 public static String INITED_DWELLER_STUFF = "inited_dweller_stuff";
35
36 protected DwellerShipCreator getShipCreator(String hullId) {
37 return SHIP_CREATORS.get(hullId);
38 }
39 protected boolean addStrategyAI() {
40 return true;
41 }
42
43 @Override
44 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
45 if (stats == null || stats.getVariant() == null) return;
46 String hullId = stats.getVariant().getHullSpec().getBaseHullId();
47 DwellerShipCreator creator = getShipCreator(hullId);
48 if (creator != null) {
49 creator.initBeforeShipCreation(hullSize, stats, id);
50 }
51 }
52
53 @Override
54 public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
55 if (ship == null || ship.getHullSpec() == null) return;
56 String hullId = ship.getHullSpec().getBaseHullId();
57 DwellerShipCreator creator = getShipCreator(hullId);
58 if (creator != null) {
59 creator.initAfterShipCreation(ship, id);
60 }
61 }
62
63
64
65 @Override
67 if (ship == null || ship.getHullSpec() == null) return;
68 String hullId = ship.getHullSpec().getBaseHullId();
69 DwellerShipCreator creator = getShipCreator(hullId);
70 if (creator != null) {
71 creator.initAfterShipAddedToCombatEngine(ship, id);
72 }
73
74 if (addStrategyAI()) {
78 }
79 }
80 }
81
82 @Override
83 public void advanceInCombat(ShipAPI ship, float amount) {
84 if (amount <= 0f || ship == null) return;
85
86 if (ship.hasTag(INITED_DWELLER_STUFF)) return;
88
89 if (ship == null || ship.getHullSpec() == null) return;
90 String hullId = ship.getHullSpec().getBaseHullId();
91 DwellerShipCreator creator = getShipCreator(hullId);
92 if (creator != null) {
93 creator.initInCombat(ship);
94 }
95 }
96}
97
98
99
100
101
102
103
104
105
106
107
108
109
110
static CombatEngineAPI getCombatEngine()
Definition Global.java:69
void applyEffectsAfterShipAddedToCombatEngine(ShipAPI ship, String id)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
static Map< String, DwellerShipCreator > SHIP_CREATORS
void addPlugin(EveryFrameCombatPlugin plugin)
void initBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
void initAfterShipAddedToCombatEngine(ShipAPI ship, String id)