Make a lot more puddle stuff predicted (#38871)
* feat: predict evaporation * refactor: move puddle update logic to shared * refactor: move more puddle stuff to Shared Still can't do stuff that creates puddles :( * refactor: move puddle transfers to shared * fix: various style fixes + switch to predicted variants * style: make some puddle stuff private instead of protected * refactor: move solution dumping to its own system * docs: clarify Drainable/Dumpable/Refillable docs Also whacks unneeded VVAccess's. * fix: audit usages of drainable+refillable I'm leaving spear and arrow for now... but I don't love it. * Added an item query I guess * Review changes * You can pour out waterguns * Review changes * oops --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
using Content.Shared.Chemistry.Components;
|
|
||||||
using Content.Shared.Chemistry.Reagent;
|
|
||||||
using Content.Shared.FixedPoint;
|
|
||||||
using Content.Shared.Fluids.Components;
|
|
||||||
|
|
||||||
namespace Content.Server.Fluids.EntitySystems;
|
|
||||||
|
|
||||||
public sealed partial class PuddleSystem
|
|
||||||
{
|
|
||||||
private static readonly TimeSpan EvaporationCooldown = TimeSpan.FromSeconds(1);
|
|
||||||
|
|
||||||
private void OnEvaporationMapInit(Entity<EvaporationComponent> entity, ref MapInitEvent args)
|
|
||||||
{
|
|
||||||
entity.Comp.NextTick = _timing.CurTime + EvaporationCooldown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateEvaporation(EntityUid uid, Solution solution)
|
|
||||||
{
|
|
||||||
if (HasComp<EvaporationComponent>(uid))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (solution.GetTotalPrototypeQuantity(GetEvaporatingReagents(solution)) > FixedPoint2.Zero)
|
|
||||||
{
|
|
||||||
var evaporation = AddComp<EvaporationComponent>(uid);
|
|
||||||
evaporation.NextTick = _timing.CurTime + EvaporationCooldown;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemComp<EvaporationComponent>(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TickEvaporation()
|
|
||||||
{
|
|
||||||
var query = EntityQueryEnumerator<EvaporationComponent, PuddleComponent>();
|
|
||||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
|
||||||
var curTime = _timing.CurTime;
|
|
||||||
while (query.MoveNext(out var uid, out var evaporation, out var puddle))
|
|
||||||
{
|
|
||||||
if (evaporation.NextTick > curTime)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
evaporation.NextTick += EvaporationCooldown;
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.ResolveSolution(uid, puddle.SolutionName, ref puddle.Solution, out var puddleSolution))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Yes, this means that 50u water + 50u holy water evaporates twice as fast as 100u water.
|
|
||||||
foreach ((string evaporatingReagent, FixedPoint2 evaporatingSpeed) in GetEvaporationSpeeds(puddleSolution))
|
|
||||||
{
|
|
||||||
var reagentTick = evaporation.EvaporationAmount * EvaporationCooldown.TotalSeconds * evaporatingSpeed;
|
|
||||||
puddleSolution.SplitSolutionWithOnly(reagentTick, evaporatingReagent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Despawn if we're done
|
|
||||||
if (puddleSolution.Volume == FixedPoint2.Zero)
|
|
||||||
{
|
|
||||||
// Spawn a *sparkle*
|
|
||||||
Spawn("PuddleSparkle", xformQuery.GetComponent(uid).Coordinates);
|
|
||||||
QueueDel(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
_solutionContainerSystem.UpdateChemicals(puddle.Solution.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,8 @@
|
|||||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
|
||||||
using Content.Shared.Chemistry.Components;
|
|
||||||
using Content.Shared.Chemistry.EntitySystems;
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
using Content.Shared.Chemistry.Reaction;
|
|
||||||
using Content.Shared.Chemistry;
|
|
||||||
using Content.Shared.Clothing;
|
|
||||||
using Content.Shared.CombatMode.Pacification;
|
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.FixedPoint;
|
|
||||||
using Content.Shared.Fluids.Components;
|
using Content.Shared.Fluids.Components;
|
||||||
using Content.Shared.IdentityManagement;
|
|
||||||
using Content.Shared.Nutrition.EntitySystems;
|
|
||||||
using Content.Shared.Popups;
|
|
||||||
using Content.Shared.Spillable;
|
using Content.Shared.Spillable;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Content.Shared.Weapons.Melee.Events;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
|
|
||||||
namespace Content.Server.Fluids.EntitySystems;
|
namespace Content.Server.Fluids.EntitySystems;
|
||||||
|
|
||||||
@@ -26,10 +14,8 @@ public sealed partial class PuddleSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand);
|
SubscribeLocalEvent<SpillableComponent, LandEvent>(SpillOnLand);
|
||||||
// Openable handles the event if it's closed
|
// Openable handles the event if it's closed
|
||||||
SubscribeLocalEvent<SpillableComponent, MeleeHitEvent>(SplashOnMeleeHit, after: [typeof(OpenableSystem)]);
|
|
||||||
SubscribeLocalEvent<SpillableComponent, SolutionContainerOverflowEvent>(OnOverflow);
|
SubscribeLocalEvent<SpillableComponent, SolutionContainerOverflowEvent>(OnOverflow);
|
||||||
SubscribeLocalEvent<SpillableComponent, SpillDoAfterEvent>(OnDoAfter);
|
SubscribeLocalEvent<SpillableComponent, SpillDoAfterEvent>(OnDoAfter);
|
||||||
SubscribeLocalEvent<SpillableComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOverflow(Entity<SpillableComponent> entity, ref SolutionContainerOverflowEvent args)
|
private void OnOverflow(Entity<SpillableComponent> entity, ref SolutionContainerOverflowEvent args)
|
||||||
@@ -41,66 +27,6 @@ public sealed partial class PuddleSystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SplashOnMeleeHit(Entity<SpillableComponent> entity, ref MeleeHitEvent args)
|
|
||||||
{
|
|
||||||
if (args.Handled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// When attacking someone reactive with a spillable entity,
|
|
||||||
// splash a little on them (touch react)
|
|
||||||
// If this also has solution transfer, then assume the transfer amount is how much we want to spill.
|
|
||||||
// Otherwise let's say they want to spill a quarter of its max volume.
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetDrainableSolution(entity.Owner, out var soln, out var solution))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var hitCount = args.HitEntities.Count;
|
|
||||||
|
|
||||||
var totalSplit = FixedPoint2.Min(solution.MaxVolume * 0.25, solution.Volume);
|
|
||||||
if (TryComp<SolutionTransferComponent>(entity, out var transfer))
|
|
||||||
{
|
|
||||||
totalSplit = FixedPoint2.Min(transfer.TransferAmount, solution.Volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
// a little lame, but reagent quantity is not very balanced and we don't want people
|
|
||||||
// spilling like 100u of reagent on someone at once!
|
|
||||||
totalSplit = FixedPoint2.Min(totalSplit, entity.Comp.MaxMeleeSpillAmount);
|
|
||||||
|
|
||||||
if (totalSplit == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Optionally allow further melee handling occur
|
|
||||||
args.Handled = entity.Comp.PreventMelee;
|
|
||||||
|
|
||||||
// First update the hit count so anything that is not reactive wont count towards the total!
|
|
||||||
foreach (var hit in args.HitEntities)
|
|
||||||
{
|
|
||||||
if (!HasComp<ReactiveComponent>(hit))
|
|
||||||
hitCount -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var hit in args.HitEntities)
|
|
||||||
{
|
|
||||||
if (!HasComp<ReactiveComponent>(hit))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var splitSolution = _solutionContainerSystem.SplitSolution(soln.Value, totalSplit / hitCount);
|
|
||||||
|
|
||||||
_adminLogger.Add(LogType.MeleeHit, $"{ToPrettyString(args.User)} splashed {SharedSolutionContainerSystem.ToPrettyString(splitSolution):solution} from {ToPrettyString(entity.Owner):entity} onto {ToPrettyString(hit):target}");
|
|
||||||
_reactive.DoEntityReaction(hit, splitSolution, ReactionMethod.Touch);
|
|
||||||
|
|
||||||
_popups.PopupEntity(
|
|
||||||
Loc.GetString("spill-melee-hit-attacker", ("amount", totalSplit / hitCount), ("spillable", entity.Owner),
|
|
||||||
("target", Identity.Entity(hit, EntityManager))),
|
|
||||||
hit, args.User);
|
|
||||||
|
|
||||||
_popups.PopupEntity(
|
|
||||||
Loc.GetString("spill-melee-hit-others", ("attacker", args.User), ("spillable", entity.Owner),
|
|
||||||
("target", Identity.Entity(hit, EntityManager))),
|
|
||||||
hit, Filter.PvsExcept(args.User), true, PopupType.SmallCaution);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SpillOnLand(Entity<SpillableComponent> entity, ref LandEvent args)
|
private void SpillOnLand(Entity<SpillableComponent> entity, ref LandEvent args)
|
||||||
{
|
{
|
||||||
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution))
|
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution))
|
||||||
@@ -114,7 +40,7 @@ public sealed partial class PuddleSystem
|
|||||||
|
|
||||||
if (args.User != null)
|
if (args.User != null)
|
||||||
{
|
{
|
||||||
_adminLogger.Add(LogType.Landed,
|
AdminLogger.Add(LogType.Landed,
|
||||||
$"{ToPrettyString(entity.Owner):entity} spilled a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} on landing");
|
$"{ToPrettyString(entity.Owner):entity} spilled a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} on landing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,22 +48,6 @@ public sealed partial class PuddleSystem
|
|||||||
TrySplashSpillAt(entity.Owner, Transform(entity).Coordinates, drainedSolution, out _);
|
TrySplashSpillAt(entity.Owner, Transform(entity).Coordinates, drainedSolution, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prevent Pacified entities from throwing items that can spill liquids.
|
|
||||||
/// </summary>
|
|
||||||
private void OnAttemptPacifiedThrow(Entity<SpillableComponent> ent, ref AttemptPacifiedThrowEvent args)
|
|
||||||
{
|
|
||||||
// Don’t care about closed containers.
|
|
||||||
if (Openable.IsClosed(ent))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Don’t care about empty containers.
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(ent.Owner, ent.Comp.SolutionName, out _, out var solution) || solution.Volume <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
args.Cancel("pacified-cannot-throw-spill");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDoAfter(Entity<SpillableComponent> entity, ref SpillDoAfterEvent args)
|
private void OnDoAfter(Entity<SpillableComponent> entity, ref SpillDoAfterEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled || args.Cancelled || args.Args.Target == null)
|
if (args.Handled || args.Cancelled || args.Args.Target == null)
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
using Content.Shared.Chemistry.Components;
|
|
||||||
using Content.Shared.DragDrop;
|
|
||||||
using Content.Shared.FixedPoint;
|
|
||||||
using Content.Shared.Fluids;
|
|
||||||
using Content.Shared.Nutrition.EntitySystems;
|
|
||||||
|
|
||||||
namespace Content.Server.Fluids.EntitySystems;
|
|
||||||
|
|
||||||
public sealed partial class PuddleSystem
|
|
||||||
{
|
|
||||||
[Dependency] private readonly OpenableSystem _openable = default!;
|
|
||||||
|
|
||||||
private void InitializeTransfers()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<RefillableSolutionComponent, DragDropDraggedEvent>(OnRefillableDragged);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRefillableDragged(Entity<RefillableSolutionComponent> entity, ref DragDropDraggedEvent args)
|
|
||||||
{
|
|
||||||
if (!_actionBlocker.CanComplexInteract(args.User))
|
|
||||||
{
|
|
||||||
_popups.PopupEntity(Loc.GetString("mopping-system-no-hands"), args.User, args.User);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var solution) || solution.Volume == FixedPoint2.Zero)
|
|
||||||
{
|
|
||||||
_popups.PopupEntity(Loc.GetString("mopping-system-empty", ("used", entity.Owner)), entity, args.User);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump reagents into DumpableSolution
|
|
||||||
if (TryComp<DumpableSolutionComponent>(args.Target, out var dump))
|
|
||||||
{
|
|
||||||
if (!_solutionContainerSystem.TryGetDumpableSolution((args.Target, dump, null), out var dumpableSoln, out var dumpableSolution))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetDrainableSolution(entity.Owner, out _, out _))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_openable.IsClosed(entity))
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool success = true;
|
|
||||||
if (dump.Unlimited)
|
|
||||||
{
|
|
||||||
var split = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume);
|
|
||||||
dumpableSolution.AddSolution(split, _prototypeManager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var split = _solutionContainerSystem.SplitSolution(soln.Value, dumpableSolution.AvailableVolume);
|
|
||||||
success = _solutionContainerSystem.TryAddSolution(dumpableSoln.Value, split);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
_audio.PlayPvs(AbsorbentComponent.DefaultTransferSound, args.Target);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", args.Target)), args.Target, args.User);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Take reagents from target
|
|
||||||
if (!TryComp<DrainableSolutionComponent>(args.Target, out var drainable))
|
|
||||||
{
|
|
||||||
if (!_solutionContainerSystem.TryGetDrainableSolution((args.Target, drainable, null), out var drainableSolution, out _))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var split = _solutionContainerSystem.SplitSolution(drainableSolution.Value, solution.AvailableVolume);
|
|
||||||
|
|
||||||
if (_solutionContainerSystem.TryAddSolution(soln.Value, split))
|
|
||||||
{
|
|
||||||
_audio.PlayPvs(AbsorbentComponent.DefaultTransferSound, entity);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", entity.Owner)), entity, args.User);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +1,25 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Server.Administration.Logs;
|
|
||||||
using Content.Server.Chemistry.TileReactions;
|
|
||||||
using Content.Server.DoAfter;
|
|
||||||
using Content.Server.Fluids.Components;
|
using Content.Server.Fluids.Components;
|
||||||
using Content.Server.Spreader;
|
using Content.Server.Spreader;
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||||
using Content.Shared.Chemistry.EntitySystems;
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
using Content.Shared.Chemistry.Reaction;
|
using Content.Shared.Chemistry.Reaction;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Effects;
|
using Content.Shared.Effects;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Fluids;
|
using Content.Shared.Fluids;
|
||||||
using Content.Shared.Fluids.Components;
|
using Content.Shared.Fluids.Components;
|
||||||
using Content.Shared.Friction;
|
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using Content.Shared.Movement.Components;
|
|
||||||
using Content.Shared.Movement.Systems;
|
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Slippery;
|
using Content.Shared.Slippery;
|
||||||
using Content.Shared.StepTrigger.Components;
|
|
||||||
using Content.Shared.StepTrigger.Systems;
|
|
||||||
using Robust.Server.Audio;
|
|
||||||
using Robust.Shared.Collections;
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Server.Fluids.EntitySystems;
|
namespace Content.Server.Fluids.EntitySystems;
|
||||||
|
|
||||||
@@ -41,28 +28,15 @@ namespace Content.Server.Fluids.EntitySystems;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class PuddleSystem : SharedPuddleSystem
|
public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
|
||||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly AudioSystem _audio = default!;
|
|
||||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
[Dependency] private readonly ReactiveSystem _reactive = default!;
|
|
||||||
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popups = default!;
|
|
||||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
||||||
[Dependency] private readonly StepTriggerSystem _stepTrigger = default!;
|
|
||||||
[Dependency] private readonly SpeedModifierContactsSystem _speedModContacts = default!;
|
|
||||||
[Dependency] private readonly TileFrictionController _tile = default!;
|
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly TurfSystem _turf = default!;
|
[Dependency] private readonly TurfSystem _turf = default!;
|
||||||
|
|
||||||
// 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 = [];
|
|
||||||
|
|
||||||
private EntityQuery<PuddleComponent> _puddleQuery;
|
private EntityQuery<PuddleComponent> _puddleQuery;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -77,16 +51,11 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
|
|
||||||
_puddleQuery = GetEntityQuery<PuddleComponent>();
|
_puddleQuery = GetEntityQuery<PuddleComponent>();
|
||||||
|
|
||||||
// Shouldn't need re-anchoring.
|
|
||||||
SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
|
||||||
SubscribeLocalEvent<PuddleComponent, SpreadNeighborsEvent>(OnPuddleSpread);
|
SubscribeLocalEvent<PuddleComponent, SpreadNeighborsEvent>(OnPuddleSpread);
|
||||||
SubscribeLocalEvent<PuddleComponent, SlipEvent>(OnPuddleSlip);
|
SubscribeLocalEvent<PuddleComponent, SlipEvent>(OnPuddleSlip);
|
||||||
|
|
||||||
SubscribeLocalEvent<EvaporationComponent, MapInitEvent>(OnEvaporationMapInit);
|
|
||||||
|
|
||||||
InitializeTransfers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This can be predicted once https://github.com/space-wizards/RobustToolbox/pull/5849 is merged
|
||||||
private void OnPuddleSpread(Entity<PuddleComponent> entity, ref SpreadNeighborsEvent args)
|
private void OnPuddleSpread(Entity<PuddleComponent> entity, ref SpreadNeighborsEvent args)
|
||||||
{
|
{
|
||||||
// Overflow is the source of the overflowing liquid. This contains the excess fluid above overflow limit (20u)
|
// Overflow is the source of the overflowing liquid. This contains the excess fluid above overflow limit (20u)
|
||||||
@@ -273,6 +242,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This can be predicted once https://github.com/space-wizards/RobustToolbox/pull/5849 is merged
|
||||||
private void OnPuddleSlip(Entity<PuddleComponent> entity, ref SlipEvent args)
|
private void OnPuddleSlip(Entity<PuddleComponent> entity, ref SlipEvent args)
|
||||||
{
|
{
|
||||||
// Reactive entities have a chance to get a touch reaction from slipping on a puddle
|
// Reactive entities have a chance to get a touch reaction from slipping on a puddle
|
||||||
@@ -289,168 +259,12 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
out var solution))
|
out var solution))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_popups.PopupEntity(Loc.GetString("puddle-component-slipped-touch-reaction", ("puddle", entity.Owner)),
|
Popups.PopupEntity(Loc.GetString("puddle-component-slipped-touch-reaction", ("puddle", entity.Owner)),
|
||||||
args.Slipped, args.Slipped, PopupType.SmallCaution);
|
args.Slipped, args.Slipped, PopupType.SmallCaution);
|
||||||
|
|
||||||
// Take 15% of the puddle solution
|
// Take 15% of the puddle solution
|
||||||
var splitSol = _solutionContainerSystem.SplitSolution(entity.Comp.Solution.Value, solution.Volume * 0.15f);
|
var splitSol = _solutionContainerSystem.SplitSolution(entity.Comp.Solution.Value, solution.Volume * 0.15f);
|
||||||
_reactive.DoEntityReaction(args.Slipped, splitSol, ReactionMethod.Touch);
|
Reactive.DoEntityReaction(args.Slipped, splitSol, ReactionMethod.Touch);
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override void Update(float frameTime)
|
|
||||||
{
|
|
||||||
base.Update(frameTime);
|
|
||||||
foreach (var ent in _deletionQueue)
|
|
||||||
{
|
|
||||||
Del(ent);
|
|
||||||
}
|
|
||||||
|
|
||||||
_deletionQueue.Clear();
|
|
||||||
|
|
||||||
TickEvaporation();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
|
|
||||||
{
|
|
||||||
if (args.SolutionId != entity.Comp.SolutionName)
|
|
||||||
return;
|
|
||||||
|
|
||||||
base.OnSolutionUpdate(entity, ref args);
|
|
||||||
|
|
||||||
if (args.Solution.Volume <= 0)
|
|
||||||
{
|
|
||||||
_deletionQueue.Add(entity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_deletionQueue.Remove(entity);
|
|
||||||
UpdateSlip((entity, entity.Comp), args.Solution);
|
|
||||||
UpdateSlow(entity, args.Solution);
|
|
||||||
UpdateEvaporation(entity, args.Solution);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateSlip(Entity<PuddleComponent> entity, Solution solution)
|
|
||||||
{
|
|
||||||
if (!TryComp<StepTriggerComponent>(entity, out var comp))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Ensure we actually have the component
|
|
||||||
EnsureComp<TileFrictionModifierComponent>(entity);
|
|
||||||
|
|
||||||
EnsureComp<SlipperyComponent>(entity, out var slipComp);
|
|
||||||
|
|
||||||
// This is the base amount of reagent needed before a puddle can be considered slippery. Is defined based on
|
|
||||||
// the sprite threshold for a puddle larger than 5 pixels.
|
|
||||||
var smallPuddleThreshold = FixedPoint2.New(entity.Comp.OverflowVolume.Float() * LowThreshold);
|
|
||||||
|
|
||||||
// Stores how many units of slippery reagents a puddle has
|
|
||||||
var slipperyUnits = FixedPoint2.Zero;
|
|
||||||
// Stores how many units of super slippery reagents a puddle has
|
|
||||||
var superSlipperyUnits = FixedPoint2.Zero;
|
|
||||||
|
|
||||||
// These three values will be averaged later and all start at zero so the calculations work
|
|
||||||
// A cumulative weighted amount of minimum speed to slip values
|
|
||||||
var puddleFriction = FixedPoint2.Zero;
|
|
||||||
// A cumulative weighted amount of minimum speed to slip values
|
|
||||||
var slipStepTrigger = FixedPoint2.Zero;
|
|
||||||
// A cumulative weighted amount of launch multipliers from slippery reagents
|
|
||||||
var launchMult = FixedPoint2.Zero;
|
|
||||||
// A cumulative weighted amount of stun times from slippery reagents
|
|
||||||
var stunTimer = TimeSpan.Zero;
|
|
||||||
// A cumulative weighted amount of knockdown times from slippery reagents
|
|
||||||
var knockdownTimer = TimeSpan.Zero;
|
|
||||||
|
|
||||||
// Check if the puddle is big enough to slip in to avoid doing unnecessary logic
|
|
||||||
if (solution.Volume <= smallPuddleThreshold)
|
|
||||||
{
|
|
||||||
_stepTrigger.SetActive(entity, false, comp);
|
|
||||||
_tile.SetModifier(entity, 1f);
|
|
||||||
slipComp.SlipData.SlipFriction = 1f;
|
|
||||||
slipComp.AffectsSliding = false;
|
|
||||||
Dirty(entity, slipComp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
slipComp.AffectsSliding = true;
|
|
||||||
|
|
||||||
foreach (var (reagent, quantity) in solution.Contents)
|
|
||||||
{
|
|
||||||
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
|
||||||
|
|
||||||
// Calculate the minimum speed needed to slip in the puddle. Average the overall slip thresholds for all reagents
|
|
||||||
var deltaSlipTrigger = reagentProto.SlipData?.RequiredSlipSpeed ?? entity.Comp.DefaultSlippery;
|
|
||||||
slipStepTrigger += quantity * deltaSlipTrigger;
|
|
||||||
|
|
||||||
// Aggregate Friction based on quantity
|
|
||||||
puddleFriction += reagentProto.Friction * quantity;
|
|
||||||
|
|
||||||
if (reagentProto.SlipData == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
slipperyUnits += quantity;
|
|
||||||
// Aggregate launch speed based on quantity
|
|
||||||
launchMult += reagentProto.SlipData.LaunchForwardsMultiplier * quantity;
|
|
||||||
// Aggregate stun times based on quantity
|
|
||||||
stunTimer += reagentProto.SlipData.StunTime * (float)quantity;
|
|
||||||
knockdownTimer += reagentProto.SlipData.KnockdownTime * (float)quantity;
|
|
||||||
|
|
||||||
if (reagentProto.SlipData.SuperSlippery)
|
|
||||||
superSlipperyUnits += quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn on the step trigger if it's slippery
|
|
||||||
_stepTrigger.SetActive(entity, slipperyUnits > smallPuddleThreshold, comp);
|
|
||||||
|
|
||||||
// This is based of the total volume and not just the slippery volume because there is a default
|
|
||||||
// slippery for all reagents even if they aren't technically slippery.
|
|
||||||
slipComp.SlipData.RequiredSlipSpeed = (float)(slipStepTrigger / solution.Volume);
|
|
||||||
_stepTrigger.SetRequiredTriggerSpeed(entity, slipComp.SlipData.RequiredSlipSpeed);
|
|
||||||
|
|
||||||
// Divide these both by only total amount of slippery reagents.
|
|
||||||
// A puddle with 10 units of lube vs a puddle with 10 of lube and 20 catchup should stun and launch forward the same amount.
|
|
||||||
if (slipperyUnits > 0)
|
|
||||||
{
|
|
||||||
slipComp.SlipData.LaunchForwardsMultiplier = (float)(launchMult/slipperyUnits);
|
|
||||||
slipComp.SlipData.StunTime = (stunTimer/(float)slipperyUnits);
|
|
||||||
slipComp.SlipData.KnockdownTime = (knockdownTimer/(float)slipperyUnits);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only make it super slippery if there is enough super slippery units for its own puddle
|
|
||||||
slipComp.SlipData.SuperSlippery = superSlipperyUnits >= smallPuddleThreshold;
|
|
||||||
|
|
||||||
// Lower tile friction based on how slippery it is, lets items slide across a puddle of lube
|
|
||||||
slipComp.SlipData.SlipFriction = (float)(puddleFriction / solution.Volume);
|
|
||||||
_tile.SetModifier(entity, slipComp.SlipData.SlipFriction);
|
|
||||||
|
|
||||||
Dirty(entity, slipComp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateSlow(EntityUid uid, Solution solution)
|
|
||||||
{
|
|
||||||
var maxViscosity = 0f;
|
|
||||||
foreach (var (reagent, _) in solution.Contents)
|
|
||||||
{
|
|
||||||
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
|
||||||
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxViscosity > 0)
|
|
||||||
{
|
|
||||||
var comp = EnsureComp<SpeedModifierContactsComponent>(uid);
|
|
||||||
var speed = 1 - maxViscosity;
|
|
||||||
_speedModContacts.ChangeSpeedModifiers(uid, speed, comp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RemComp<SpeedModifierContactsComponent>(uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAnchorChanged(Entity<PuddleComponent> entity, ref AnchorStateChangedEvent args)
|
|
||||||
{
|
|
||||||
if (!args.Anchored)
|
|
||||||
QueueDel(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -507,7 +321,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_audio.PlayPvs(puddleComponent.SpillSound, puddleUid);
|
Audio.PlayPvs(puddleComponent.SpillSound, puddleUid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,6 +367,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
|
|
||||||
#region Spill
|
#region Spill
|
||||||
|
|
||||||
|
// TODO: This can be predicted once https://github.com/space-wizards/RobustToolbox/pull/5849 is merged
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool TrySplashSpillAt(EntityUid uid,
|
public override bool TrySplashSpillAt(EntityUid uid,
|
||||||
EntityCoordinates coordinates,
|
EntityCoordinates coordinates,
|
||||||
@@ -582,13 +397,13 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
|||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
_adminLogger.Add(LogType.Landed,
|
AdminLogger.Add(LogType.Landed,
|
||||||
$"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity} which splashed a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} onto {ToPrettyString(owner):target}");
|
$"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity} which splashed a solution {SharedSolutionContainerSystem.ToPrettyString(solution):solution} onto {ToPrettyString(owner):target}");
|
||||||
}
|
}
|
||||||
|
|
||||||
targets.Add(owner);
|
targets.Add(owner);
|
||||||
_reactive.DoEntityReaction(owner, splitSolution, ReactionMethod.Touch);
|
Reactive.DoEntityReaction(owner, splitSolution, ReactionMethod.Touch);
|
||||||
_popups.PopupEntity(
|
Popups.PopupEntity(
|
||||||
Loc.GetString("spill-land-spilled-on-other", ("spillable", uid),
|
Loc.GetString("spill-land-spilled-on-other", ("spillable", uid),
|
||||||
("target", Identity.Entity(owner, EntityManager))), owner, PopupType.SmallCaution);
|
("target", Identity.Entity(owner, EntityManager))), owner, PopupType.SmallCaution);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public sealed class ItemCabinetSystem : EntitySystem
|
|||||||
private void OnMapInit(Entity<ItemCabinetComponent> ent, ref MapInitEvent args)
|
private void OnMapInit(Entity<ItemCabinetComponent> ent, ref MapInitEvent args)
|
||||||
{
|
{
|
||||||
// update at mapinit to avoid copy pasting locked: true and locked: false for each closed/open prototype
|
// update at mapinit to avoid copy pasting locked: true and locked: false for each closed/open prototype
|
||||||
SetSlotLock(ent, !_openable.IsOpen(ent));
|
SetSlotLock(ent, _openable.IsClosed(ent, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAppearance(Entity<ItemCabinetComponent> ent)
|
private void UpdateAppearance(Entity<ItemCabinetComponent> ent)
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ using Robust.Shared.GameStates;
|
|||||||
namespace Content.Shared.Chemistry.Components;
|
namespace Content.Shared.Chemistry.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Denotes the solution that can be easily removed through any reagent container.
|
/// Denotes a specific solution contained within this entity that can can be
|
||||||
/// Think pouring this or draining from a water tank.
|
/// easily "drained". This means things with taps/spigots, or easily poured
|
||||||
|
/// items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class DrainableSolutionComponent : Component
|
public sealed partial class DrainableSolutionComponent : Component
|
||||||
@@ -12,6 +13,6 @@ public sealed partial class DrainableSolutionComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Solution name that can be drained.
|
/// Solution name that can be drained.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public string Solution = "default";
|
public string Solution = "default";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ using Robust.Shared.GameStates;
|
|||||||
namespace Content.Shared.Chemistry.Components;
|
namespace Content.Shared.Chemistry.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Denotes the solution that can be easily dumped into (completely removed from the dumping container into this one)
|
/// Denotes that there is a solution contained in this entity that can be
|
||||||
/// Think pouring a container fully into this.
|
/// easily dumped into (that is, completely removed from the dumping container
|
||||||
|
/// into this one). Think pouring a container fully into this.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class DumpableSolutionComponent : Component
|
public sealed partial class DumpableSolutionComponent : Component
|
||||||
@@ -12,12 +13,13 @@ public sealed partial class DumpableSolutionComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Solution name that can be dumped into.
|
/// Solution name that can be dumped into.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public string Solution = "default";
|
public string Solution = "default";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the solution can be dumped into infinitely.
|
/// Whether the solution can be dumped into infinitely.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
/// <remarks>Note that this is what makes the ChemMaster's buffer a stasis buffer as well!</remarks>
|
||||||
|
[DataField]
|
||||||
public bool Unlimited = false;
|
public bool Unlimited = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ using Robust.Shared.GameStates;
|
|||||||
namespace Content.Shared.Chemistry.Components;
|
namespace Content.Shared.Chemistry.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reagents that can be added easily. For example like
|
/// Denotes that the entity has a solution contained which can be easily added
|
||||||
/// pouring something into another beaker, glass, or into the gas
|
/// to. This should go on things that are meant to be refilled, including
|
||||||
/// tank of a car.
|
/// pouring things into a beaker. If you run it under a sink tap, it's probably
|
||||||
|
/// refillable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class RefillableSolutionComponent : Component
|
public sealed partial class RefillableSolutionComponent : Component
|
||||||
@@ -14,12 +15,12 @@ public sealed partial class RefillableSolutionComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Solution name that can added to easily.
|
/// Solution name that can added to easily.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public string Solution = "default";
|
public string Solution = "default";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum amount that can be transferred to the solution at once
|
/// The maximum amount that can be transferred to the solution at once
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public FixedPoint2? MaxRefill = null;
|
public FixedPoint2? MaxRefill = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,15 @@ namespace Content.Shared.Fluids.Components;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added to puddles that contain water so it may evaporate over time.
|
/// Added to puddles that contain water so it may evaporate over time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NetworkedComponent, AutoGenerateComponentPause]
|
[NetworkedComponent, AutoGenerateComponentPause, AutoGenerateComponentState]
|
||||||
[RegisterComponent, Access(typeof(SharedPuddleSystem))]
|
[RegisterComponent, Access(typeof(SharedPuddleSystem))]
|
||||||
public sealed partial class EvaporationComponent : Component
|
public sealed partial class EvaporationComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The next time we remove the EvaporationSystem reagent amount from this entity.
|
/// The next time we remove the EvaporationSystem reagent amount from this entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AutoPausedField, DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
[AutoNetworkedField, AutoPausedField]
|
||||||
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
||||||
public TimeSpan NextTick;
|
public TimeSpan NextTick;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
193
Content.Shared/Fluids/EntitySystems/SolutionDumpingSystem.cs
Normal file
193
Content.Shared/Fluids/EntitySystems/SolutionDumpingSystem.cs
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Content.Shared.ActionBlocker;
|
||||||
|
using Content.Shared.Chemistry.Components;
|
||||||
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
|
using Content.Shared.DragDrop;
|
||||||
|
using Content.Shared.FixedPoint;
|
||||||
|
using Content.Shared.Item;
|
||||||
|
using Content.Shared.Nutrition.EntitySystems;
|
||||||
|
using Content.Shared.Popups;
|
||||||
|
using Robust.Shared.Audio.Systems;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Shared.Fluids.EntitySystems;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles drag and drop of various solutions.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The thing dragged always "gives" its reagents away for consistent UX.
|
||||||
|
/// </remarks>
|
||||||
|
/// <seealso cref="DumpableSolutionComponent" />
|
||||||
|
/// <seealso cref="DrainableSolutionComponent" />
|
||||||
|
/// <seealso cref="RefillableSolutionComponent" />
|
||||||
|
public sealed class SolutionDumpingSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||||
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
||||||
|
[Dependency] private readonly OpenableSystem _openable = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly SharedSolutionContainerSystem _solContainer = default!;
|
||||||
|
|
||||||
|
private EntityQuery<ItemComponent> _itemQuery;
|
||||||
|
private EntityQuery<RefillableSolutionComponent> _refillableQuery;
|
||||||
|
private EntityQuery<DumpableSolutionComponent> _dumpQuery;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DrainableSolutionComponent, CanDragEvent>(OnDrainableCanDrag);
|
||||||
|
SubscribeLocalEvent<DrainableSolutionComponent, CanDropDraggedEvent>(OnDrainableCanDragDropped);
|
||||||
|
|
||||||
|
//SubscribeLocalEvent<RefillableSolutionComponent, DragDropDraggedEvent>(OnRefillableDragged); For if you want to refill a container by dragging it into another one. Can't find a use for that currently.
|
||||||
|
SubscribeLocalEvent<DrainableSolutionComponent, DragDropDraggedEvent>(OnDrainableDragged);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RefillableSolutionComponent, DrainedTargetEvent>(OnDrainedToRefillableDragged);
|
||||||
|
SubscribeLocalEvent<DumpableSolutionComponent, DrainedTargetEvent>(OnDrainedToDumpableDragged);
|
||||||
|
|
||||||
|
// We use queries for these since CanDropDraggedEvent gets called pretty rapidly
|
||||||
|
_itemQuery = GetEntityQuery<ItemComponent>();
|
||||||
|
_refillableQuery = GetEntityQuery<RefillableSolutionComponent>();
|
||||||
|
_dumpQuery = GetEntityQuery<DumpableSolutionComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrainableCanDrag(Entity<DrainableSolutionComponent> ent, ref CanDragEvent args)
|
||||||
|
{
|
||||||
|
if (_itemQuery.HasComp(ent))
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrainableCanDragDropped(Entity<DrainableSolutionComponent> ent, ref CanDropDraggedEvent args)
|
||||||
|
{
|
||||||
|
// Easily drawn-from thing can be dragged onto easily refillable thing.
|
||||||
|
if (!_refillableQuery.HasComp(args.Target) && !_dumpQuery.HasComp(args.Target))
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.CanDrop = true;
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For when you are pouring something out from the container.
|
||||||
|
/// </summary>
|
||||||
|
private void OnDrainableDragged(Entity<DrainableSolutionComponent> sourceContainer, ref DragDropDraggedEvent args)
|
||||||
|
{
|
||||||
|
// Raising an event to be able to drain into various kind of fillable components.
|
||||||
|
var ev = new DrainedTargetEvent(args.User, sourceContainer, sourceContainer.Comp.Solution);
|
||||||
|
RaiseLocalEvent(args.Target, ref ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: I feel that DumpableSolutionComponent is kind of redundant and only used to support unlimited containers,
|
||||||
|
// and even then that should probably be refactored out (see to-do below).
|
||||||
|
// It might be worth having the distinction if we want to separate "dump all" vs "pour some" functionalities,
|
||||||
|
// but then we probably want to do a proper pass on how RefillableSolutionComponent is handled.
|
||||||
|
private void OnDrainedToDumpableDragged(Entity<DumpableSolutionComponent> ent, ref DrainedTargetEvent args)
|
||||||
|
{
|
||||||
|
if (!_solContainer.TryGetDumpableSolution((ent, ent.Comp),
|
||||||
|
out var targetSolEnt,
|
||||||
|
out var targetSol))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check openness, hands, source being empty, and target being full.
|
||||||
|
if (!DragInteractionChecks(args.User,
|
||||||
|
args.Source,
|
||||||
|
ent.Owner,
|
||||||
|
args.SourceSolution,
|
||||||
|
targetSol,
|
||||||
|
out var sourceEnt,
|
||||||
|
!ent.Comp.Unlimited))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ent.Comp.Unlimited)
|
||||||
|
{
|
||||||
|
// Unlimited means we're dumping into an infinite buffer, so we
|
||||||
|
// have to be careful that we don't trigger any reactions. This
|
||||||
|
// means SolutionContainerSystem.AddSolution can't be used!
|
||||||
|
// TODO: This should be replaced with proper support for unlimited solutions, rather than cheating by bypassing UpdateChemicals using AddSolution. We can already avoid reactions using CanReact = false, this cheat just bypasses solution overflow.
|
||||||
|
targetSol.AddSolution(
|
||||||
|
_solContainer.SplitSolution(sourceEnt.Value, sourceEnt.Value.Comp.Solution.Volume),
|
||||||
|
_protoMan);
|
||||||
|
// Solution.AddSolution doesn't dirty targetSol for us
|
||||||
|
Dirty(targetSolEnt.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_solContainer.TryAddSolution(targetSolEnt.Value,
|
||||||
|
_solContainer.SplitSolution(sourceEnt.Value, targetSol.AvailableVolume));
|
||||||
|
}
|
||||||
|
|
||||||
|
_audio.PlayPredicted(AbsorbentComponent.DefaultTransferSound, ent, args.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrainedToRefillableDragged(Entity<RefillableSolutionComponent> ent, ref DrainedTargetEvent args)
|
||||||
|
{
|
||||||
|
if (!_solContainer.TryGetRefillableSolution((ent, ent.Comp),
|
||||||
|
out var targetSolEnt,
|
||||||
|
out var targetSol))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check openness, hands, source being empty, and target being full.
|
||||||
|
if (!DragInteractionChecks(args.User,
|
||||||
|
args.Source,
|
||||||
|
ent.Owner,
|
||||||
|
args.SourceSolution,
|
||||||
|
targetSol,
|
||||||
|
out var sourceEnt))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_solContainer.TryAddSolution(targetSolEnt.Value,
|
||||||
|
_solContainer.SplitSolution(sourceEnt.Value, targetSol.AvailableVolume));
|
||||||
|
|
||||||
|
_audio.PlayPredicted(AbsorbentComponent.DefaultTransferSound, ent, args.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Common checks between dragging handlers.
|
||||||
|
private bool DragInteractionChecks(EntityUid user,
|
||||||
|
EntityUid sourceContainer,
|
||||||
|
EntityUid targetContainer,
|
||||||
|
string sourceSolutionName,
|
||||||
|
Solution targetSol,
|
||||||
|
[NotNullWhen(true)] out Entity<SolutionComponent>? sourceSolEnt,
|
||||||
|
bool checkAvailableVolume = true)
|
||||||
|
{
|
||||||
|
sourceSolEnt = null;
|
||||||
|
if (!_actionBlocker.CanComplexInteract(user))
|
||||||
|
{
|
||||||
|
_popup.PopupClient(Loc.GetString("mopping-system-no-hands"), user, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_solContainer.TryGetSolution(sourceContainer, sourceSolutionName, out sourceSolEnt)
|
||||||
|
|| sourceSolEnt.Value.Comp.Solution.Volume == FixedPoint2.Zero)
|
||||||
|
{
|
||||||
|
_popup.PopupClient(Loc.GetString("mopping-system-empty", ("used", sourceContainer)),
|
||||||
|
sourceContainer,
|
||||||
|
user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkAvailableVolume && targetSol.AvailableVolume == FixedPoint2.Zero)
|
||||||
|
{
|
||||||
|
_popup.PopupClient(Loc.GetString("mopping-system-full", ("used", targetContainer)), targetContainer, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both things need to be open. If the entity has nothing to close, it will count as "open".
|
||||||
|
return !_openable.IsClosed(sourceContainer, user, predicted: true)
|
||||||
|
&& !_openable.IsClosed(targetContainer, user, predicted: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed on a target being drained into.
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent]
|
||||||
|
public record struct DrainedTargetEvent(EntityUid User, EntityUid Source, string SourceSolution)
|
||||||
|
{
|
||||||
|
public readonly EntityUid User = User;
|
||||||
|
public readonly EntityUid Source = Source;
|
||||||
|
public readonly string SourceSolution = SourceSolution;
|
||||||
|
public bool Handled = false;
|
||||||
|
}
|
||||||
@@ -1,15 +1,87 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
|
using Content.Shared.Fluids.Components;
|
||||||
|
|
||||||
namespace Content.Shared.Fluids;
|
namespace Content.Shared.Fluids;
|
||||||
|
|
||||||
public abstract partial class SharedPuddleSystem
|
public abstract partial class SharedPuddleSystem
|
||||||
{
|
{
|
||||||
|
private static readonly TimeSpan EvaporationCooldown = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
|
private void OnEvaporationMapInit(Entity<EvaporationComponent> ent, ref MapInitEvent args)
|
||||||
|
{
|
||||||
|
ent.Comp.NextTick = _timing.CurTime + EvaporationCooldown;
|
||||||
|
Dirty(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateEvaporation(EntityUid uid, Solution solution)
|
||||||
|
{
|
||||||
|
if (_evaporationQuery.HasComp(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (solution.GetTotalPrototypeQuantity(GetEvaporatingReagents(solution)) > FixedPoint2.Zero)
|
||||||
|
{
|
||||||
|
var evaporation = AddComp<EvaporationComponent>(uid);
|
||||||
|
evaporation.NextTick = _timing.CurTime + EvaporationCooldown;
|
||||||
|
Dirty<EvaporationComponent>((uid, evaporation));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemComp<EvaporationComponent>(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TickEvaporation()
|
||||||
|
{
|
||||||
|
var query = EntityQueryEnumerator<EvaporationComponent, PuddleComponent>();
|
||||||
|
var curTime = _timing.CurTime;
|
||||||
|
while (query.MoveNext(out var uid, out var evaporation, out var puddle))
|
||||||
|
{
|
||||||
|
if (evaporation.NextTick > curTime)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Necessary to keep client and server in sync so they don't drift
|
||||||
|
evaporation.NextTick += EvaporationCooldown;
|
||||||
|
Dirty(uid, evaporation);
|
||||||
|
|
||||||
|
if (!_solutionContainerSystem.ResolveSolution(uid, puddle.SolutionName, ref puddle.Solution, out var puddleSolution))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If we have multiple evaporating reagents in one puddle, just take the average evaporation speed and apply
|
||||||
|
// that to all of them.
|
||||||
|
var evaporationSpeeds = GetEvaporationSpeeds(puddleSolution);
|
||||||
|
if (evaporationSpeeds.Count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Can't use .Average because FixedPoint2
|
||||||
|
var evaporationSpeed = evaporationSpeeds.Values.Sum() / evaporationSpeeds.Count;
|
||||||
|
var reagentProportions = evaporationSpeeds.ToDictionary(kv => kv.Key,
|
||||||
|
kv => puddleSolution.GetTotalPrototypeQuantity(kv.Key) / puddleSolution.Volume);
|
||||||
|
|
||||||
|
// Still have to iterate over one-by-one since the full solution could have non-evaporating solutions.
|
||||||
|
foreach (var (reagent, factor) in reagentProportions)
|
||||||
|
{
|
||||||
|
var reagentTick = evaporation.EvaporationAmount * EvaporationCooldown.TotalSeconds * evaporationSpeed * factor;
|
||||||
|
puddleSolution.SplitSolutionWithOnly(reagentTick, reagent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Despawn if we're done
|
||||||
|
if (puddleSolution.Volume == FixedPoint2.Zero)
|
||||||
|
{
|
||||||
|
// Spawn a *sparkle*
|
||||||
|
SpawnAttachedTo(evaporation.EvaporationEffect, Transform(uid).Coordinates);
|
||||||
|
PredictedQueueDel(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
_solutionContainerSystem.UpdateChemicals(puddle.Solution.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public string[] GetEvaporatingReagents(Solution solution)
|
public string[] GetEvaporatingReagents(Solution solution)
|
||||||
{
|
{
|
||||||
var evaporatingReagents = new List<string>();
|
List<string> evaporatingReagents = [];
|
||||||
foreach (ReagentPrototype solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
foreach (var solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
||||||
{
|
{
|
||||||
if (solProto.EvaporationSpeed > FixedPoint2.Zero)
|
if (solProto.EvaporationSpeed > FixedPoint2.Zero)
|
||||||
evaporatingReagents.Add(solProto.ID);
|
evaporatingReagents.Add(solProto.ID);
|
||||||
@@ -19,8 +91,8 @@ public abstract partial class SharedPuddleSystem
|
|||||||
|
|
||||||
public string[] GetAbsorbentReagents(Solution solution)
|
public string[] GetAbsorbentReagents(Solution solution)
|
||||||
{
|
{
|
||||||
var absorbentReagents = new List<string>();
|
List<string> absorbentReagents = [];
|
||||||
foreach (ReagentPrototype solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
foreach (var solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
||||||
{
|
{
|
||||||
if (solProto.Absorbent)
|
if (solProto.Absorbent)
|
||||||
absorbentReagents.Add(solProto.ID);
|
absorbentReagents.Add(solProto.ID);
|
||||||
@@ -34,13 +106,13 @@ public abstract partial class SharedPuddleSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the evaporating speed of the reagents within a solution.
|
/// Gets a mapping of evaporating speed of the reagents within a solution.
|
||||||
/// The speed at which a solution evaporates is the sum of the speed of all evaporating reagents in it.
|
/// The speed at which a solution evaporates is the average of the speed of all evaporating reagents in it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, FixedPoint2> GetEvaporationSpeeds(Solution solution)
|
public Dictionary<string, FixedPoint2> GetEvaporationSpeeds(Solution solution)
|
||||||
{
|
{
|
||||||
var evaporatingSpeeds = new Dictionary<string, FixedPoint2>();
|
Dictionary<string, FixedPoint2> evaporatingSpeeds = [];
|
||||||
foreach (ReagentPrototype solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
foreach (var solProto in solution.GetReagentPrototypes(_prototypeManager).Keys)
|
||||||
{
|
{
|
||||||
if (solProto.EvaporationSpeed > FixedPoint2.Zero)
|
if (solProto.EvaporationSpeed > FixedPoint2.Zero)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,24 +1,34 @@
|
|||||||
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
|
using Content.Shared.Chemistry.Reaction;
|
||||||
|
using Content.Shared.CombatMode.Pacification;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Fluids.Components;
|
using Content.Shared.Fluids.Components;
|
||||||
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Nutrition.EntitySystems;
|
using Content.Shared.Nutrition.EntitySystems;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Spillable;
|
using Content.Shared.Spillable;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Weapons.Melee;
|
using Content.Shared.Weapons.Melee;
|
||||||
|
using Content.Shared.Weapons.Melee.Events;
|
||||||
|
using Robust.Shared.Player;
|
||||||
|
|
||||||
namespace Content.Shared.Fluids;
|
namespace Content.Shared.Fluids;
|
||||||
|
|
||||||
public abstract partial class SharedPuddleSystem
|
public abstract partial class SharedPuddleSystem
|
||||||
{
|
{
|
||||||
[Dependency] protected readonly OpenableSystem Openable = default!;
|
private static readonly FixedPoint2 MeleeHitTransferProportion = 0.25;
|
||||||
|
|
||||||
protected virtual void InitializeSpillable()
|
protected virtual void InitializeSpillable()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<SpillableComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<SpillableComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<SpillableComponent, GetVerbsEvent<Verb>>(AddSpillVerb);
|
SubscribeLocalEvent<SpillableComponent, GetVerbsEvent<Verb>>(AddSpillVerb);
|
||||||
|
SubscribeLocalEvent<SpillableComponent, MeleeHitEvent>(SplashOnMeleeHit, after: [typeof(OpenableSystem)]);
|
||||||
|
SubscribeLocalEvent<SpillableComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamined(Entity<SpillableComponent> entity, ref ExaminedEvent args)
|
private void OnExamined(Entity<SpillableComponent> entity, ref ExaminedEvent args)
|
||||||
@@ -37,7 +47,10 @@ public abstract partial class SharedPuddleSystem
|
|||||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(args.Target, entity.Comp.SolutionName, out var soln, out var solution))
|
if (!_solutionContainerSystem.TryGetSolution(args.Target,
|
||||||
|
entity.Comp.SolutionName,
|
||||||
|
out var soln,
|
||||||
|
out var solution))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Openable.IsClosed(args.Target))
|
if (Openable.IsClosed(args.Target))
|
||||||
@@ -74,7 +87,12 @@ public abstract partial class SharedPuddleSystem
|
|||||||
var user = args.User;
|
var user = args.User;
|
||||||
verb.Act = () =>
|
verb.Act = () =>
|
||||||
{
|
{
|
||||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, entity.Comp.SpillDelay ?? 0, new SpillDoAfterEvent(), entity.Owner, target: entity.Owner)
|
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager,
|
||||||
|
user,
|
||||||
|
entity.Comp.SpillDelay ?? 0,
|
||||||
|
new SpillDoAfterEvent(),
|
||||||
|
entity.Owner,
|
||||||
|
target: entity.Owner)
|
||||||
{
|
{
|
||||||
BreakOnDamage = true,
|
BreakOnDamage = true,
|
||||||
BreakOnMove = true,
|
BreakOnMove = true,
|
||||||
@@ -86,4 +104,89 @@ public abstract partial class SharedPuddleSystem
|
|||||||
verb.DoContactInteraction = true;
|
verb.DoContactInteraction = true;
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SplashOnMeleeHit(Entity<SpillableComponent> entity, ref MeleeHitEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// When attacking someone reactive with a spillable entity,
|
||||||
|
// splash a little on them (touch react)
|
||||||
|
// If this also has solution transfer, then assume the transfer amount is how much we want to spill.
|
||||||
|
// Otherwise let's say they want to spill a quarter of its max volume.
|
||||||
|
|
||||||
|
if (!_solutionContainerSystem.TryGetDrainableSolution(entity.Owner, out var soln, out var solution))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var hitCount = args.HitEntities.Count;
|
||||||
|
|
||||||
|
var totalSplit = FixedPoint2.Min(solution.MaxVolume * MeleeHitTransferProportion, solution.Volume);
|
||||||
|
if (TryComp<SolutionTransferComponent>(entity, out var transfer))
|
||||||
|
totalSplit = FixedPoint2.Min(transfer.TransferAmount, solution.Volume);
|
||||||
|
|
||||||
|
// a little lame, but reagent quantity is not very balanced and we don't want people
|
||||||
|
// spilling like 100u of reagent on someone at once!
|
||||||
|
totalSplit = FixedPoint2.Min(totalSplit, entity.Comp.MaxMeleeSpillAmount);
|
||||||
|
|
||||||
|
if (totalSplit == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Optionally allow further melee handling occur
|
||||||
|
args.Handled = entity.Comp.PreventMelee;
|
||||||
|
|
||||||
|
// First update the hit count so anything that is not reactive wont count towards the total!
|
||||||
|
foreach (var hit in args.HitEntities)
|
||||||
|
{
|
||||||
|
if (!_reactiveQuery.HasComp(hit))
|
||||||
|
hitCount -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var hit in args.HitEntities)
|
||||||
|
{
|
||||||
|
if (!_reactiveQuery.HasComp(hit))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var splitSolution = _solutionContainerSystem.SplitSolution(soln.Value, totalSplit / hitCount);
|
||||||
|
|
||||||
|
AdminLogger.Add(LogType.MeleeHit,
|
||||||
|
$"{ToPrettyString(args.User):actor} "
|
||||||
|
+ $"splashed {SharedSolutionContainerSystem.ToPrettyString(splitSolution):solution} "
|
||||||
|
+ $"from {ToPrettyString(entity.Owner):entity} onto {ToPrettyString(hit):target}");
|
||||||
|
|
||||||
|
Reactive.DoEntityReaction(hit, splitSolution, ReactionMethod.Touch);
|
||||||
|
|
||||||
|
Popups.PopupClient(Loc.GetString("spill-melee-hit-attacker",
|
||||||
|
("amount", totalSplit / hitCount),
|
||||||
|
("spillable", entity.Owner),
|
||||||
|
("target", Identity.Entity(hit, EntityManager, args.User))),
|
||||||
|
hit,
|
||||||
|
args.User);
|
||||||
|
Popups.PopupEntity(
|
||||||
|
Loc.GetString("spill-melee-hit-others",
|
||||||
|
("attacker", Identity.Entity(args.User, EntityManager)),
|
||||||
|
("spillable", entity.Owner),
|
||||||
|
("target", Identity.Entity(hit, EntityManager))),
|
||||||
|
hit,
|
||||||
|
Filter.PvsExcept(args.User),
|
||||||
|
true,
|
||||||
|
PopupType.SmallCaution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prevent Pacified entities from throwing items that can spill liquids.
|
||||||
|
/// </summary>
|
||||||
|
private void OnAttemptPacifiedThrow(Entity<SpillableComponent> ent, ref AttemptPacifiedThrowEvent args)
|
||||||
|
{
|
||||||
|
// Don’t care about closed containers.
|
||||||
|
if (Openable.IsClosed(ent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Don’t care about empty containers.
|
||||||
|
if (!_solutionContainerSystem.TryGetSolution(ent.Owner, ent.Comp.SolutionName, out _, out var solution)
|
||||||
|
|| solution.Volume <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Cancel("pacified-cannot-throw-spill");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,46 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Shared.Administration.Logs;
|
||||||
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
using Content.Shared.Chemistry.EntitySystems;
|
using Content.Shared.Chemistry.EntitySystems;
|
||||||
|
using Content.Shared.Chemistry.Reaction;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.DragDrop;
|
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
using Content.Shared.Fluids.Components;
|
using Content.Shared.Fluids.Components;
|
||||||
|
using Content.Shared.Friction;
|
||||||
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
|
using Content.Shared.Movement.Systems;
|
||||||
|
using Content.Shared.Nutrition.EntitySystems;
|
||||||
|
using Content.Shared.Popups;
|
||||||
|
using Content.Shared.Slippery;
|
||||||
using Content.Shared.StepTrigger.Components;
|
using Content.Shared.StepTrigger.Components;
|
||||||
|
using Content.Shared.StepTrigger.Systems;
|
||||||
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Shared.Fluids;
|
namespace Content.Shared.Fluids;
|
||||||
|
|
||||||
public abstract partial class SharedPuddleSystem : EntitySystem
|
public abstract partial class SharedPuddleSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] protected readonly ISharedAdminLogManager AdminLogger = default!;
|
||||||
|
[Dependency] protected readonly OpenableSystem Openable = default!;
|
||||||
|
[Dependency] protected readonly ReactiveSystem Reactive = default!;
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||||
|
[Dependency] protected readonly SharedPopupSystem Popups = default!;
|
||||||
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
||||||
|
[Dependency] private readonly SpeedModifierContactsSystem _speedModContacts = default!;
|
||||||
|
[Dependency] private readonly StepTriggerSystem _stepTrigger = default!;
|
||||||
|
[Dependency] private readonly TileFrictionController _tile = default!;
|
||||||
|
|
||||||
private string[] _standoutReagents = [];
|
private string[] _standoutReagents = [];
|
||||||
|
|
||||||
@@ -31,25 +51,53 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
|
|
||||||
public const float MediumThreshold = 0.6f;
|
public const float MediumThreshold = 0.6f;
|
||||||
|
|
||||||
|
// 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 = [];
|
||||||
|
|
||||||
|
private EntityQuery<StepTriggerComponent> _stepTriggerQuery;
|
||||||
|
private EntityQuery<ReactiveComponent> _reactiveQuery;
|
||||||
|
private EntityQuery<EvaporationComponent> _evaporationQuery;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<RefillableSolutionComponent, CanDragEvent>(OnRefillableCanDrag);
|
// Shouldn't need re-anchoring.
|
||||||
SubscribeLocalEvent<DumpableSolutionComponent, CanDropTargetEvent>(OnDumpCanDropTarget);
|
SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
||||||
SubscribeLocalEvent<DrainableSolutionComponent, CanDropTargetEvent>(OnDrainCanDropTarget);
|
|
||||||
SubscribeLocalEvent<RefillableSolutionComponent, CanDropDraggedEvent>(OnRefillableCanDropDragged);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<PuddleComponent, SolutionContainerChangedEvent>(OnSolutionUpdate);
|
SubscribeLocalEvent<PuddleComponent, SolutionContainerChangedEvent>(OnSolutionUpdate);
|
||||||
SubscribeLocalEvent<PuddleComponent, GetFootstepSoundEvent>(OnGetFootstepSound);
|
SubscribeLocalEvent<PuddleComponent, GetFootstepSoundEvent>(OnGetFootstepSound);
|
||||||
SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
|
SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
|
||||||
SubscribeLocalEvent<PuddleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
SubscribeLocalEvent<PuddleComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<EvaporationComponent, MapInitEvent>(OnEvaporationMapInit);
|
||||||
|
|
||||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
|
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
|
||||||
|
|
||||||
|
_stepTriggerQuery = GetEntityQuery<StepTriggerComponent>();
|
||||||
|
_reactiveQuery = GetEntityQuery<ReactiveComponent>();
|
||||||
|
_evaporationQuery = GetEntityQuery<EvaporationComponent>();
|
||||||
|
|
||||||
CacheStandsout();
|
CacheStandsout();
|
||||||
InitializeSpillable();
|
InitializeSpillable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
|
||||||
|
foreach (var ent in _deletionQueue)
|
||||||
|
{
|
||||||
|
// It's possible to have items in the queue that are already being deleted but threw a
|
||||||
|
// SolutionContainerChangedEvent as a part of their shutdown, like during a round restart.
|
||||||
|
if (!TerminatingOrDeleted(ent))
|
||||||
|
PredictedDel(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
_deletionQueue.Clear();
|
||||||
|
|
||||||
|
TickEvaporation();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev)
|
private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev)
|
||||||
{
|
{
|
||||||
if (ev.WasModified<ReagentPrototype>())
|
if (ev.WasModified<ReagentPrototype>())
|
||||||
@@ -64,44 +112,22 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
_standoutReagents = [.. _prototypeManager.EnumeratePrototypes<ReagentPrototype>().Where(x => x.Standsout).Select(x => x.ID)];
|
_standoutReagents = [.. _prototypeManager.EnumeratePrototypes<ReagentPrototype>().Where(x => x.Standsout).Select(x => x.ID)];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
|
private void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContainerChangedEvent args)
|
||||||
{
|
{
|
||||||
if (args.SolutionId != entity.Comp.SolutionName)
|
if (args.SolutionId != entity.Comp.SolutionName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateAppearance((entity, entity.Comp));
|
if (args.Solution.Volume <= 0)
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRefillableCanDrag(Entity<RefillableSolutionComponent> entity, ref CanDragEvent args)
|
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
_deletionQueue.Add(entity);
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDumpCanDropTarget(Entity<DumpableSolutionComponent> entity, ref CanDropTargetEvent args)
|
|
||||||
{
|
|
||||||
if (HasComp<DrainableSolutionComponent>(args.Dragged))
|
|
||||||
{
|
|
||||||
args.CanDrop = true;
|
|
||||||
args.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDrainCanDropTarget(Entity<DrainableSolutionComponent> entity, ref CanDropTargetEvent args)
|
|
||||||
{
|
|
||||||
if (HasComp<RefillableSolutionComponent>(args.Dragged))
|
|
||||||
{
|
|
||||||
args.CanDrop = true;
|
|
||||||
args.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRefillableCanDropDragged(Entity<RefillableSolutionComponent> entity, ref CanDropDraggedEvent args)
|
|
||||||
{
|
|
||||||
if (!HasComp<DrainableSolutionComponent>(args.Target) && !HasComp<DumpableSolutionComponent>(args.Target))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
args.CanDrop = true;
|
_deletionQueue.Remove(entity);
|
||||||
args.Handled = true;
|
UpdateSlip((entity, entity.Comp), args.Solution);
|
||||||
|
UpdateSlow(entity, args.Solution);
|
||||||
|
UpdateEvaporation(entity, args.Solution);
|
||||||
|
UpdateAppearance((entity, entity.Comp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetFootstepSound(Entity<PuddleComponent> entity, ref GetFootstepSoundEvent args)
|
private void OnGetFootstepSound(Entity<PuddleComponent> entity, ref GetFootstepSoundEvent args)
|
||||||
@@ -122,12 +148,12 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
using (args.PushGroup(nameof(PuddleComponent)))
|
using (args.PushGroup(nameof(PuddleComponent)))
|
||||||
{
|
{
|
||||||
if (TryComp<StepTriggerComponent>(entity, out var slippery) && slippery.Active)
|
if (_stepTriggerQuery.TryComp(entity, out var slippery) && slippery.Active)
|
||||||
{
|
{
|
||||||
args.PushMarkup(Loc.GetString("puddle-component-examine-is-slippery-text"));
|
args.PushMarkup(Loc.GetString("puddle-component-examine-is-slippery-text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasComp<EvaporationComponent>(entity) &&
|
if (_evaporationQuery.HasComp(entity) &&
|
||||||
_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName,
|
_solutionContainerSystem.ResolveSolution(entity.Owner, entity.Comp.SolutionName,
|
||||||
ref entity.Comp.Solution, out var solution))
|
ref entity.Comp.Solution, out var solution))
|
||||||
{
|
{
|
||||||
@@ -143,6 +169,12 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnAnchorChanged(Entity<PuddleComponent> entity, ref AnchorStateChangedEvent args)
|
||||||
|
{
|
||||||
|
if (!args.Anchored)
|
||||||
|
PredictedQueueDel(entity.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
// Workaround for https://github.com/space-wizards/space-station-14/pull/35314
|
// Workaround for https://github.com/space-wizards/space-station-14/pull/35314
|
||||||
private void OnEntRemoved(Entity<PuddleComponent> ent, ref EntRemovedFromContainerMessage args)
|
private void OnEntRemoved(Entity<PuddleComponent> ent, ref EntRemovedFromContainerMessage args)
|
||||||
{
|
{
|
||||||
@@ -191,6 +223,122 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
_appearance.SetData(ent, PuddleVisuals.SolutionColor, color, appearance);
|
_appearance.SetData(ent, PuddleVisuals.SolutionColor, color, appearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateSlip(Entity<PuddleComponent> entity, Solution solution)
|
||||||
|
{
|
||||||
|
if (!_stepTriggerQuery.TryComp(entity, out var comp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Ensure we actually have the component
|
||||||
|
EnsureComp<TileFrictionModifierComponent>(entity);
|
||||||
|
EnsureComp<SlipperyComponent>(entity, out var slipComp);
|
||||||
|
|
||||||
|
// This is the base amount of reagent needed before a puddle can be considered slippery. Is defined based on
|
||||||
|
// the sprite threshold for a puddle larger than 5 pixels.
|
||||||
|
var smallPuddleThreshold = FixedPoint2.New(entity.Comp.OverflowVolume.Float() * LowThreshold);
|
||||||
|
|
||||||
|
// Stores how many units of slippery reagents a puddle has
|
||||||
|
var slipperyUnits = FixedPoint2.Zero;
|
||||||
|
// Stores how many units of super slippery reagents a puddle has
|
||||||
|
var superSlipperyUnits = FixedPoint2.Zero;
|
||||||
|
|
||||||
|
// These three values will be averaged later and all start at zero so the calculations work
|
||||||
|
// A cumulative weighted amount of minimum speed to slip values
|
||||||
|
var puddleFriction = FixedPoint2.Zero;
|
||||||
|
// A cumulative weighted amount of minimum speed to slip values
|
||||||
|
var slipStepTrigger = FixedPoint2.Zero;
|
||||||
|
// A cumulative weighted amount of launch multipliers from slippery reagents
|
||||||
|
var launchMult = FixedPoint2.Zero;
|
||||||
|
// A cumulative weighted amount of stun times from slippery reagents
|
||||||
|
var stunTimer = TimeSpan.Zero;
|
||||||
|
// A cumulative weighted amount of knockdown times from slippery reagents
|
||||||
|
var knockdownTimer = TimeSpan.Zero;
|
||||||
|
|
||||||
|
// Check if the puddle is big enough to slip in to avoid doing unnecessary logic
|
||||||
|
if (solution.Volume <= smallPuddleThreshold)
|
||||||
|
{
|
||||||
|
_stepTrigger.SetActive(entity, false, comp);
|
||||||
|
_tile.SetModifier(entity, 1f);
|
||||||
|
slipComp.SlipData.SlipFriction = 1f;
|
||||||
|
slipComp.AffectsSliding = false;
|
||||||
|
Dirty(entity, slipComp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
slipComp.AffectsSliding = true;
|
||||||
|
|
||||||
|
foreach (var (reagent, quantity) in solution.Contents)
|
||||||
|
{
|
||||||
|
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
||||||
|
|
||||||
|
// Calculate the minimum speed needed to slip in the puddle. Average the overall slip thresholds for all reagents
|
||||||
|
var deltaSlipTrigger = reagentProto.SlipData?.RequiredSlipSpeed ?? entity.Comp.DefaultSlippery;
|
||||||
|
slipStepTrigger += quantity * deltaSlipTrigger;
|
||||||
|
|
||||||
|
// Aggregate Friction based on quantity
|
||||||
|
puddleFriction += reagentProto.Friction * quantity;
|
||||||
|
|
||||||
|
if (reagentProto.SlipData == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
slipperyUnits += quantity;
|
||||||
|
// Aggregate launch speed based on quantity
|
||||||
|
launchMult += reagentProto.SlipData.LaunchForwardsMultiplier * quantity;
|
||||||
|
// Aggregate stun times based on quantity
|
||||||
|
stunTimer += reagentProto.SlipData.StunTime * (float)quantity;
|
||||||
|
knockdownTimer += reagentProto.SlipData.KnockdownTime * (float)quantity;
|
||||||
|
|
||||||
|
if (reagentProto.SlipData.SuperSlippery)
|
||||||
|
superSlipperyUnits += quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn on the step trigger if it's slippery
|
||||||
|
_stepTrigger.SetActive(entity, slipperyUnits > smallPuddleThreshold, comp);
|
||||||
|
|
||||||
|
// This is based of the total volume and not just the slippery volume because there is a default
|
||||||
|
// slippery for all reagents even if they aren't technically slippery.
|
||||||
|
slipComp.SlipData.RequiredSlipSpeed = (float)(slipStepTrigger / solution.Volume);
|
||||||
|
_stepTrigger.SetRequiredTriggerSpeed(entity, slipComp.SlipData.RequiredSlipSpeed);
|
||||||
|
|
||||||
|
// Divide these both by only total amount of slippery reagents.
|
||||||
|
// A puddle with 10 units of lube vs a puddle with 10 of lube and 20 catchup should stun and launch forward the same amount.
|
||||||
|
if (slipperyUnits > 0)
|
||||||
|
{
|
||||||
|
slipComp.SlipData.LaunchForwardsMultiplier = (float)(launchMult/slipperyUnits);
|
||||||
|
slipComp.SlipData.StunTime = (stunTimer/(float)slipperyUnits);
|
||||||
|
slipComp.SlipData.KnockdownTime = (knockdownTimer/(float)slipperyUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only make it super slippery if there is enough super slippery units for its own puddle
|
||||||
|
slipComp.SlipData.SuperSlippery = superSlipperyUnits >= smallPuddleThreshold;
|
||||||
|
|
||||||
|
// Lower tile friction based on how slippery it is, lets items slide across a puddle of lube
|
||||||
|
slipComp.SlipData.SlipFriction = (float)(puddleFriction/solution.Volume);
|
||||||
|
_tile.SetModifier(entity, slipComp.SlipData.SlipFriction);
|
||||||
|
|
||||||
|
Dirty(entity, slipComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSlow(EntityUid uid, Solution solution)
|
||||||
|
{
|
||||||
|
var maxViscosity = 0f;
|
||||||
|
foreach (var (reagent, _) in solution.Contents)
|
||||||
|
{
|
||||||
|
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
|
||||||
|
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxViscosity > 0)
|
||||||
|
{
|
||||||
|
var comp = EnsureComp<SpeedModifierContactsComponent>(uid);
|
||||||
|
var speed = 1 - maxViscosity;
|
||||||
|
_speedModContacts.ChangeSpeedModifiers(uid, speed, comp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RemComp<SpeedModifierContactsComponent>(uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void DoTileReactions(TileRef tileRef, Solution solution)
|
public void DoTileReactions(TileRef tileRef, Solution solution)
|
||||||
{
|
{
|
||||||
for (var i = solution.Contents.Count - 1; i >= 0; i--)
|
for (var i = solution.Contents.Count - 1; i >= 0; i--)
|
||||||
@@ -217,7 +365,7 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
/// puddle. This is intended for 'destructive' spills, like when entities are destroyed or thrown.
|
/// puddle. This is intended for 'destructive' spills, like when entities are destroyed or thrown.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"> and return false.
|
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"/> and return false.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public abstract bool TrySplashSpillAt(EntityUid uid,
|
public abstract bool TrySplashSpillAt(EntityUid uid,
|
||||||
EntityCoordinates coordinates,
|
EntityCoordinates coordinates,
|
||||||
@@ -231,25 +379,15 @@ public abstract partial class SharedPuddleSystem : EntitySystem
|
|||||||
/// Will add to an existing puddle if present or create a new one if not.
|
/// Will add to an existing puddle if present or create a new one if not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"> and return false.
|
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"/> and return false.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public abstract bool TrySpillAt(EntityCoordinates coordinates, Solution solution, out EntityUid puddleUid, bool sound = true);
|
public abstract bool TrySpillAt(EntityCoordinates coordinates, Solution solution, out EntityUid puddleUid, bool sound = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc cref="TrySpillAt(EntityCoordinates, Solution, out EntityUid, bool)"/>
|
||||||
/// <see cref="TrySpillAt(EntityCoordinates, Solution, out EntityUid, bool)"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"> and return false.
|
|
||||||
/// </remarks>
|
|
||||||
public abstract bool TrySpillAt(EntityUid uid, Solution solution, out EntityUid puddleUid, bool sound = true,
|
public abstract bool TrySpillAt(EntityUid uid, Solution solution, out EntityUid puddleUid, bool sound = true,
|
||||||
TransformComponent? transformComponent = null);
|
TransformComponent? transformComponent = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc cref="TrySpillAt(EntityCoordinates, Solution, out EntityUid, bool)"/>
|
||||||
/// <see cref="TrySpillAt(EntityCoordinates, Solution, out EntityUid, bool)"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// On the client, this will always set <paramref name="puddleUid"/> to <see cref="EntityUid.Invalid"> and return false.
|
|
||||||
/// </remarks>
|
|
||||||
public abstract bool TrySpillAt(TileRef tileRef, Solution solution, out EntityUid puddleUid, bool sound = true,
|
public abstract bool TrySpillAt(TileRef tileRef, Solution solution, out EntityUid puddleUid, bool sound = true,
|
||||||
bool tileReact = true);
|
bool tileReact = true);
|
||||||
|
|
||||||
|
|||||||
@@ -147,18 +147,6 @@ public sealed partial class OpenableSystem : EntitySystem
|
|||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns true if the entity either does not have OpenableComponent or it is opened.
|
|
||||||
/// Drinks that don't have OpenableComponent are automatically open, so it returns true.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsOpen(EntityUid uid, OpenableComponent? comp = null)
|
|
||||||
{
|
|
||||||
if (!Resolve(uid, ref comp, false))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return comp.Opened;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if the entity both has OpenableComponent and is not opened.
|
/// Returns true if the entity both has OpenableComponent and is not opened.
|
||||||
/// Drinks that don't have OpenableComponent are automatically open, so it returns false.
|
/// Drinks that don't have OpenableComponent are automatically open, so it returns false.
|
||||||
|
|||||||
@@ -149,15 +149,9 @@
|
|||||||
solutions:
|
solutions:
|
||||||
ammo:
|
ammo:
|
||||||
maxVol: 15
|
maxVol: 15
|
||||||
- type: RefillableSolution
|
|
||||||
solution: ammo
|
|
||||||
- type: DrainableSolution
|
|
||||||
solution: ammo
|
|
||||||
- type: SolutionInjectOnProjectileHit
|
- type: SolutionInjectOnProjectileHit
|
||||||
transferAmount: 15
|
transferAmount: 15
|
||||||
solution: ammo
|
solution: ammo
|
||||||
- type: InjectableSolution
|
|
||||||
solution: ammo
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PelletShotgunFlare
|
id: PelletShotgunFlare
|
||||||
|
|||||||
@@ -38,10 +38,10 @@
|
|||||||
type: TransferAmountBoundUserInterface
|
type: TransferAmountBoundUserInterface
|
||||||
- type: DrawableSolution
|
- type: DrawableSolution
|
||||||
solution: chamber
|
solution: chamber
|
||||||
- type: RefillableSolution
|
|
||||||
solution: chamber
|
|
||||||
- type: DrainableSolution
|
- type: DrainableSolution
|
||||||
solution: chamber
|
solution: chamber
|
||||||
|
- type: RefillableSolution
|
||||||
|
solution: chamber
|
||||||
- type: ExaminableSolution
|
- type: ExaminableSolution
|
||||||
solution: chamber
|
solution: chamber
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
solutions:
|
solutions:
|
||||||
ammo:
|
ammo:
|
||||||
maxVol: 2
|
maxVol: 2
|
||||||
- type: RefillableSolution
|
- type: RefillableSolution # This is sus. You can't really just run an arrowhead under a sink faucet.
|
||||||
solution: ammo
|
solution: ammo
|
||||||
- type: InjectableSolution
|
- type: InjectableSolution
|
||||||
solution: ammo
|
solution: ammo
|
||||||
|
|||||||
@@ -38,8 +38,6 @@
|
|||||||
solutions:
|
solutions:
|
||||||
drainBuffer:
|
drainBuffer:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
- type: DrainableSolution
|
|
||||||
solution: drainBuffer
|
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
damageContainer: StructuralInorganic
|
damageContainer: StructuralInorganic
|
||||||
damageModifierSet: StructuralMetallic
|
damageModifierSet: StructuralMetallic
|
||||||
|
|||||||
Reference in New Issue
Block a user