Puddle IExamine event.
This commit is contained in:
@@ -7,7 +7,6 @@ using Content.Shared.Chemistry.Components;
|
|||||||
using Content.Shared.Chemistry.EntitySystems;
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
using Content.Shared.Directions;
|
using Content.Shared.Directions;
|
||||||
using Content.Shared.Examine;
|
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Slippery;
|
using Content.Shared.Slippery;
|
||||||
@@ -16,14 +15,12 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.Utility;
|
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Fluids.Components
|
namespace Content.Server.Fluids.Components
|
||||||
@@ -32,7 +29,7 @@ namespace Content.Server.Fluids.Components
|
|||||||
/// Puddle on a floor
|
/// Puddle on a floor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class PuddleComponent : Component, IExamine, IMapInit
|
public class PuddleComponent : Component, IMapInit
|
||||||
{
|
{
|
||||||
// Current design: Something calls the SpillHelper.Spill, that will either
|
// Current design: Something calls the SpillHelper.Spill, that will either
|
||||||
// A) Add to an existing puddle at the location (normalised to tile-center) or
|
// A) Add to an existing puddle at the location (normalised to tile-center) or
|
||||||
@@ -120,8 +117,6 @@ namespace Content.Server.Fluids.Components
|
|||||||
|
|
||||||
[DataField("state")] private string _spriteState = "puddle";
|
[DataField("state")] private string _spriteState = "puddle";
|
||||||
|
|
||||||
private bool Slippery => Owner.TryGetComponent(out SlipperyComponent? slippery) && slippery.Slippery;
|
|
||||||
|
|
||||||
private Solution? PuddleSolution => EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, DefaultSolutionName);
|
private Solution? PuddleSolution => EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, DefaultSolutionName);
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
@@ -152,14 +147,6 @@ namespace Content.Server.Fluids.Components
|
|||||||
_spriteComponent.Rotation = Angle.FromDegrees(robustRandom.Next(0, 359));
|
_spriteComponent.Rotation = Angle.FromDegrees(robustRandom.Next(0, 359));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
|
|
||||||
{
|
|
||||||
if (Slippery)
|
|
||||||
{
|
|
||||||
message.AddText(Loc.GetString("puddle-component-examine-is-slipper-text"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether adding this solution to this puddle would overflow.
|
/// Whether adding this solution to this puddle would overflow.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
using Content.Server.Fluids.Components;
|
using Content.Server.Fluids.Components;
|
||||||
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Slippery;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
namespace Content.Server.Fluids
|
namespace Content.Server.Fluids
|
||||||
@@ -15,6 +18,8 @@ namespace Content.Server.Fluids
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
_mapManager.TileChanged += HandleTileChanged;
|
_mapManager.TileChanged += HandleTileChanged;
|
||||||
|
|
||||||
|
SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
@@ -23,6 +28,14 @@ namespace Content.Server.Fluids
|
|||||||
_mapManager.TileChanged -= HandleTileChanged;
|
_mapManager.TileChanged -= HandleTileChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandlePuddleExamined(EntityUid uid, PuddleComponent component, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
if (ComponentManager.TryGetComponent<SlipperyComponent>(uid, out var slippery) && slippery.Slippery)
|
||||||
|
{
|
||||||
|
args.Message.AddText(Loc.GetString("puddle-component-examine-is-slipper-text"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Replace all this with an Unanchored event that deletes the puddle
|
//TODO: Replace all this with an Unanchored event that deletes the puddle
|
||||||
private void HandleTileChanged(object? sender, TileChangedEventArgs eventArgs)
|
private void HandleTileChanged(object? sender, TileChangedEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user