using Content.Server.Chemistry.Containers.EntitySystems;
-using Content.Server.Fluids.Components;
using Content.Server.Fluids.EntitySystems;
+using Content.Shared.Fluids.Components;
using JetBrains.Annotations;
namespace Content.Server.Destructible.Thresholds.Behaviors
-using Content.Server.Fluids.Components;
using Content.Shared.Chemistry.Components;
-using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Fluids.Components;
{
private static readonly TimeSpan EvaporationCooldown = TimeSpan.FromSeconds(1);
- [ValidatePrototypeId<ReagentPrototype>]
- private const string Water = "Water";
-
- public static string[] EvaporationReagents = new[] { Water };
-
private void OnEvaporationMapInit(Entity<EvaporationComponent> entity, ref MapInitEvent args)
{
entity.Comp.NextTick = _timing.CurTime + EvaporationCooldown;
}
}
}
-
- public bool CanFullyEvaporate(Solution solution)
- {
- return solution.GetTotalPrototypeQuantity(EvaporationReagents) == solution.Volume;
- }
}
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Database;
using Content.Shared.DoAfter;
-using Content.Shared.Examine;
using Content.Shared.FixedPoint;
+using Content.Shared.Fluids.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory.Events;
using Content.Shared.Popups;
using Content.Shared.Spillable;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
-using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Player;
[Dependency] private readonly OpenableSystem _openable = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
- private void InitializeSpillable()
+ protected override void InitializeSpillable()
{
- SubscribeLocalEvent<SpillableComponent, ExaminedEvent>(OnExamined);
+ base.InitializeSpillable();
+
SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand);
- // openable handles the event if its closed
- SubscribeLocalEvent<SpillableComponent, MeleeHitEvent>(SplashOnMeleeHit, after: new[] { typeof(OpenableSystem) });
+ // Openable handles the event if it's closed
+ SubscribeLocalEvent<SpillableComponent, MeleeHitEvent>(SplashOnMeleeHit, after: [typeof(OpenableSystem)]);
SubscribeLocalEvent<SpillableComponent, GetVerbsEvent<Verb>>(AddSpillVerb);
SubscribeLocalEvent<SpillableComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<SpillableComponent, SolutionContainerOverflowEvent>(OnOverflow);
SubscribeLocalEvent<SpillableComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
}
- private void OnExamined(Entity<SpillableComponent> entity, ref ExaminedEvent args)
- {
- using (args.PushGroup(nameof(SpillableComponent)))
- {
- args.PushMarkup(Loc.GetString("spill-examine-is-spillable"));
-
- if (HasComp<MeleeWeaponComponent>(entity))
- args.PushMarkup(Loc.GetString("spill-examine-spillable-weapon"));
- }
- }
-
private void OnOverflow(Entity<SpillableComponent> entity, ref SolutionContainerOverflowEvent args)
{
if (args.Handled)
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Database;
using Content.Shared.Effects;
-using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
[ValidatePrototypeId<ReagentPrototype>]
private const string CopperBlood = "CopperBlood";
- private static string[] _standoutReagents = new[] { Blood, Slime, CopperBlood };
+ private static string[] _standoutReagents = [Blood, Slime, CopperBlood];
- public static float PuddleVolume = 1000;
+ public static readonly float PuddleVolume = 1000;
// Using local deletion queue instead of the standard queue so that we can easily "undelete" if a puddle
// loses & then gains reagents in a single tick.
- private HashSet<EntityUid> _deletionQueue = new();
+ private HashSet<EntityUid> _deletionQueue = [];
private EntityQuery<PuddleComponent> _puddleQuery;
// Shouldn't need re-anchoring.
SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
- SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
SubscribeLocalEvent<PuddleComponent, SolutionContainerChangedEvent>(OnSolutionUpdate);
SubscribeLocalEvent<PuddleComponent, ComponentInit>(OnPuddleInit);
SubscribeLocalEvent<PuddleComponent, SpreadNeighborsEvent>(OnPuddleSpread);
SubscribeLocalEvent<EvaporationComponent, MapInitEvent>(OnEvaporationMapInit);
- InitializeSpillable();
InitializeTransfers();
}
}
}
- private void HandlePuddleExamined(Entity<PuddleComponent> entity, ref ExaminedEvent args)
- {
- using (args.PushGroup(nameof(PuddleComponent)))
- {
- if (TryComp<StepTriggerComponent>(entity, out var slippery) && slippery.Active)
- {
- args.PushMarkup(Loc.GetString("puddle-component-examine-is-slipper-text"));
- }
-
- if (HasComp<EvaporationComponent>(entity) &&
- _solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName,
- ref entity.Comp.Solution, out var solution))
- {
- if (CanFullyEvaporate(solution))
- args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating"));
- else if (solution.GetTotalPrototypeQuantity(EvaporationReagents) > FixedPoint2.Zero)
- args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-partial"));
- else
- args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-no"));
- }
- else
- args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-no"));
- }
- }
-
private void OnAnchorChanged(Entity<PuddleComponent> entity, ref AnchorStateChangedEvent args)
{
if (!args.Anchored)
-using Content.Server.Fluids.EntitySystems;
-using Content.Shared.FixedPoint;
+using Content.Shared.FixedPoint;
+using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
-namespace Content.Server.Fluids.Components;
+namespace Content.Shared.Fluids.Components;
/// <summary>
/// Added to puddles that contain water so it may evaporate over time.
/// </summary>
-[RegisterComponent, Access(typeof(PuddleSystem))]
+[NetworkedComponent]
+[RegisterComponent, Access(typeof(SharedPuddleSystem))]
public sealed partial class EvaporationComponent : Component
{
/// <summary>
/// The next time we remove the EvaporationSystem reagent amount from this entity.
/// </summary>
- [ViewVariables(VVAccess.ReadWrite), DataField("nextTick", customTypeSerializer:typeof(TimeOffsetSerializer))]
+ [ViewVariables(VVAccess.ReadWrite), DataField("nextTick", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextTick = TimeSpan.Zero;
/// <summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedPuddleSystem))]
public sealed partial class PuddleComponent : Component
{
- [DataField("spillSound")]
+ [DataField]
public SoundSpecifier SpillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg");
- [DataField("overflowVolume")]
+ [DataField]
public FixedPoint2 OverflowVolume = FixedPoint2.New(20);
[DataField("solution")] public string SolutionName = "puddle";
using Content.Shared.FixedPoint;
-namespace Content.Server.Fluids.Components;
+namespace Content.Shared.Fluids.Components;
[RegisterComponent]
public sealed partial class SpillableComponent : Component
/// Should this item be spilled when worn as clothing?
/// Doesn't count for pockets or hands.
/// </summary>
- [DataField("spillWorn")]
+ [DataField]
public bool SpillWorn = true;
- [DataField("spillDelay")]
+ [DataField]
public float? SpillDelay;
/// <summary>
/// At most how much reagent can be splashed on someone at once?
/// </summary>
- [DataField("maxMeleeSpillAmount")]
+ [DataField]
public FixedPoint2 MaxMeleeSpillAmount = FixedPoint2.New(20);
}
--- /dev/null
+using Content.Shared.Chemistry.Components;
+using Content.Shared.Chemistry.Reagent;
+
+namespace Content.Shared.Fluids;
+
+public abstract partial class SharedPuddleSystem
+{
+ [ValidatePrototypeId<ReagentPrototype>]
+ private const string Water = "Water";
+
+ public static readonly string[] EvaporationReagents = [Water];
+
+ public bool CanFullyEvaporate(Solution solution)
+ {
+ return solution.GetTotalPrototypeQuantity(EvaporationReagents) == solution.Volume;
+ }
+}
--- /dev/null
+using Content.Shared.Examine;
+using Content.Shared.Fluids.Components;
+using Content.Shared.Weapons.Melee;
+
+namespace Content.Shared.Fluids;
+
+public abstract partial class SharedPuddleSystem
+{
+ protected virtual void InitializeSpillable()
+ {
+ SubscribeLocalEvent<SpillableComponent, ExaminedEvent>(OnExamined);
+ }
+
+ private void OnExamined(Entity<SpillableComponent> entity, ref ExaminedEvent args)
+ {
+ using (args.PushGroup(nameof(SpillableComponent)))
+ {
+ args.PushMarkup(Loc.GetString("spill-examine-is-spillable"));
+
+ if (HasComp<MeleeWeaponComponent>(entity))
+ args.PushMarkup(Loc.GetString("spill-examine-spillable-weapon"));
+ }
+ }
+}
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.DragDrop;
+using Content.Shared.Examine;
+using Content.Shared.FixedPoint;
using Content.Shared.Fluids.Components;
using Content.Shared.Movement.Events;
+using Content.Shared.StepTrigger.Components;
using Robust.Shared.Prototypes;
namespace Content.Shared.Fluids;
-public abstract class SharedPuddleSystem : EntitySystem
+public abstract partial class SharedPuddleSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
SubscribeLocalEvent<DrainableSolutionComponent, CanDropTargetEvent>(OnDrainCanDropTarget);
SubscribeLocalEvent<RefillableSolutionComponent, CanDropDraggedEvent>(OnRefillableCanDropDragged);
SubscribeLocalEvent<PuddleComponent, GetFootstepSoundEvent>(OnGetFootstepSound);
+ SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
+
+ InitializeSpillable();
}
private void OnRefillableCanDrag(Entity<RefillableSolutionComponent> entity, ref CanDragEvent args)
args.Sound = proto.FootstepSound;
}
}
+
+ private void HandlePuddleExamined(Entity<PuddleComponent> entity, ref ExaminedEvent args)
+ {
+ using (args.PushGroup(nameof(PuddleComponent)))
+ {
+ if (TryComp<StepTriggerComponent>(entity, out var slippery) && slippery.Active)
+ {
+ args.PushMarkup(Loc.GetString("puddle-component-examine-is-slippery-text"));
+ }
+
+ if (HasComp<EvaporationComponent>(entity) &&
+ _solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName,
+ ref entity.Comp.Solution, out var solution))
+ {
+ if (CanFullyEvaporate(solution))
+ args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating"));
+ else if (solution.GetTotalPrototypeQuantity(EvaporationReagents) > FixedPoint2.Zero)
+ args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-partial"));
+ else
+ args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-no"));
+ }
+ else
+ args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-no"));
+ }
+ }
}
-puddle-component-examine-is-slipper-text = It looks [color=#169C9C]slippery[/color].
+puddle-component-examine-is-slippery-text = It looks [color=#169C9C]slippery[/color].
puddle-component-examine-evaporating = It is [color=#5E7C16]evaporating[/color].
puddle-component-examine-evaporating-partial = It is [color=#FED83D]partially evaporating[/color].
puddle-component-examine-evaporating-no = It is [color=#B02E26]not evaporating[/color].