3 using Microsoft.Xna.Framework;
5 using System.Globalization;
12 private float flowPercentage;
13 private float maxFlow;
17 private bool hijacked;
20 get {
return hijacked; }
23 if (value == hijacked) {
return; }
28 item.CreateServerEvent(
this);
43 private float pumpSpeedLockTimer, isActiveLockTimer;
45 [
Serialize(0.0f,
IsPropertySaveable.Yes, description:
"How fast the item is currently pumping water (-100 = full speed out, 100 = full speed in). Intended to be used by StatusEffect conditionals (setting this value in XML has no effect).")]
48 get {
return flowPercentage; }
51 if (!MathUtils.IsValid(flowPercentage)) {
return; }
52 flowPercentage = MathHelper.Clamp(value, -100.0f, 100.0f);
53 flowPercentage = MathF.Round(flowPercentage);
61 set => maxFlow = value;
71 private float currFlow;
77 return Math.Abs(currFlow);
84 private const float TinkeringSpeedIncrease = 4.0f;
93 InitProjSpecific(element);
100 pumpSpeedLockTimer -= deltaTime;
101 isActiveLockTimer -= deltaTime;
112 float hullPercentage = 0.0f;
119 if ((linked is
Hull linkedHull))
121 hullWaterVolume += linkedHull.WaterVolume;
122 totalHullVolume += linkedHull.Volume;
125 hullPercentage = hullWaterVolume / totalHullVolume * 100.0f;
135 UpdateProjSpecific(deltaTime);
143 currFlow = flowPercentage / 100.0f *
item.
StatManager.GetAdjustedValueMultiplicative(ItemTalentStats.PumpMaxFlow,
MaxFlow) * powerFactor;
145 if (
item.GetComponent<
Repairable>() is { IsTinkering: true } repairable)
147 currFlow *= 1f + repairable.TinkeringStrength * TinkeringSpeedIncrease;
150 currFlow =
item.
StatManager.GetAdjustedValueMultiplicative(ItemTalentStats.PumpSpeed, currFlow);
159 public void InfectBallast(Identifier identifier,
bool allowMultiplePerShip =
false)
162 if (hull ==
null) {
return; }
164 if (!allowMultiplePerShip)
167 if (
Hull.
HullList.Where(h => h.Submarine == hull.
Submarine).Any(h => h.BallastFlora !=
null)) {
return; }
173 if (ballastFloraPrefab ==
null)
175 DebugConsole.ThrowError($
"Failed to infect a ballast pump (could not find a ballast flora prefab with the identifier \"{identifier}\").\n" + Environment.StackTrace);
180 hull.
BallastFlora =
new BallastFloraBehavior(hull, ballastFloraPrefab, offset, firstGrowth:
true);
183 hull.
BallastFlora.CreateNetworkMessage(
new BallastFloraBehavior.SpawnEventData());
205 partial
void UpdateProjSpecific(
float deltaTime);
211 if (connection.
Name ==
"toggle")
214 isActiveLockTimer = 0.1f;
216 else if (connection.
Name ==
"set_active")
219 isActiveLockTimer = 0.1f;
221 else if (connection.
Name ==
"set_speed")
223 if (
float.TryParse(signal.
value, NumberStyles.Any, CultureInfo.InvariantCulture, out
float tempSpeed))
225 flowPercentage = MathHelper.Clamp(tempSpeed, -100.0f, 100.0f);
227 pumpSpeedLockTimer = 0.1f;
230 else if (connection.
Name ==
"set_targetlevel")
232 if (
float.TryParse(signal.
value, NumberStyles.Any, CultureInfo.InvariantCulture, out
float tempTarget))
234 TargetLevel = MathUtils.InverseLerp(-100.0f, 100.0f, tempTarget) * 100.0f;
235 pumpSpeedLockTimer = 0.1f;
246 switch (objective.
Option.Value.ToLowerInvariant())
252 item.CreateServerEvent(
this);
262 item.CreateServerEvent(
this);
272 item.CreateServerEvent(
this);
readonly Identifier Option
static BallastFloraPrefab Find(Identifier identifier)
virtual Vector2 WorldPosition
BallastFloraBehavior BallastFlora
static readonly List< Hull > HullList
ItemStatManager StatManager
float ConditionPercentage
void ApplyStatusEffects(ActionType type, float deltaTime, Character character=null, Limb targetLimb=null, Entity useTarget=null, Character user=null, Vector2? worldPosition=null, float afflictionMultiplier=1.0f)
const float MaxOverVoltageFactor
Maximum voltage factor when the device is being overvolted. I.e. how many times more effectively the ...
float powerConsumption
The maximum amount of power the item can draw from connected items
float currPowerConsumption
The amount of power currently consumed by the item. Negative values mean that the item is providing p...
override bool CrewAIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
true if the operation was completed
void InfectBallast(Identifier identifier, bool allowMultiplePerShip=false)
override void Update(float deltaTime, Camera cam)
float CurrentBrokenVolume
override void ReceiveSignal(Signal signal, Connection connection)
override float GetCurrentPowerConsumption(Connection connection=null)
Power consumption of the Pump. Only consume power when active and adjust consumption based on conditi...
Pump(Item item, ContentXElement element)
override bool UpdateWhenInactive
readonly List< MapEntity > linkedTo
Interface for entities that the clients can send events to the server
Interface for entities that the server can send events to the clients
ActionType
ActionTypes define when a StatusEffect is executed.