Generalize ReagentUnit into FixedPoint2 and use it for damage calculations (#5151)
* Damage units * sum ext method
This commit is contained in:
@@ -4,6 +4,7 @@ using Content.Server.DoAfter;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
@@ -40,9 +41,9 @@ namespace Content.Server.Fluids.Components
|
||||
}
|
||||
}
|
||||
|
||||
public ReagentUnit MaxVolume
|
||||
public FixedPoint2 MaxVolume
|
||||
{
|
||||
get => MopSolution?.MaxVolume ?? ReagentUnit.Zero;
|
||||
get => MopSolution?.MaxVolume ?? FixedPoint2.Zero;
|
||||
set
|
||||
{
|
||||
var solution = MopSolution;
|
||||
@@ -53,14 +54,14 @@ namespace Content.Server.Fluids.Components
|
||||
}
|
||||
}
|
||||
|
||||
public ReagentUnit CurrentVolume => MopSolution?.CurrentVolume ?? ReagentUnit.Zero;
|
||||
public FixedPoint2 CurrentVolume => MopSolution?.CurrentVolume ?? FixedPoint2.Zero;
|
||||
|
||||
// Currently there's a separate amount for pickup and dropoff so
|
||||
// Picking up a puddle requires multiple clicks
|
||||
// Dumping in a bucket requires 1 click
|
||||
// Long-term you'd probably use a cooldown and start the pickup once we have some form of global cooldown
|
||||
[DataField("pickup_amount")]
|
||||
public ReagentUnit PickupAmount { get; } = ReagentUnit.New(5);
|
||||
public FixedPoint2 PickupAmount { get; } = FixedPoint2.New(5);
|
||||
|
||||
[DataField("pickup_sound")]
|
||||
private SoundSpecifier _pickupSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
|
||||
@@ -136,7 +137,7 @@ namespace Content.Server.Fluids.Components
|
||||
return false;
|
||||
|
||||
// Annihilate the puddle
|
||||
var transferAmount = ReagentUnit.Min(ReagentUnit.New(5), puddleComponent.CurrentVolume, CurrentVolume);
|
||||
var transferAmount = FixedPoint2.Min(FixedPoint2.New(5), puddleComponent.CurrentVolume, CurrentVolume);
|
||||
var puddleCleaned = puddleComponent.CurrentVolume - transferAmount <= 0;
|
||||
|
||||
var puddleSystem = EntitySystem.Get<PuddleSystem>();
|
||||
@@ -146,7 +147,7 @@ namespace Content.Server.Fluids.Components
|
||||
if (puddleSystem.EmptyHolder(puddleComponent.Owner.Uid, puddleComponent)) //The puddle doesn't actually *have* reagents, for example vomit because there's no "vomit" reagent.
|
||||
{
|
||||
puddleComponent.Owner.Delete();
|
||||
transferAmount = ReagentUnit.Min(ReagentUnit.New(5), CurrentVolume);
|
||||
transferAmount = FixedPoint2.Min(FixedPoint2.New(5), CurrentVolume);
|
||||
puddleCleaned = true;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user