Stable merge (#37050)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Server.Actions;
|
||||
|
||||
@@ -20,8 +19,10 @@ namespace Content.Server.Actions;
|
||||
[RegisterComponent]
|
||||
public sealed partial class ActionOnInteractComponent : Component
|
||||
{
|
||||
[DataField(required:true)]
|
||||
[DataField(required: true)]
|
||||
public List<EntProtoId>? Actions;
|
||||
|
||||
[DataField] public List<EntityUid>? ActionEntities;
|
||||
|
||||
[DataField] public bool RequiresCharge;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Charges.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -15,6 +17,7 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
|
||||
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -54,6 +57,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
if (options.Count == 0)
|
||||
return;
|
||||
|
||||
if (!TryUseCharge((uid, component)))
|
||||
return;
|
||||
|
||||
var (actId, act) = _random.Pick(options);
|
||||
_actions.PerformAction(args.User, null, actId, act, act.Event, _timing.CurTime, false);
|
||||
args.Handled = true;
|
||||
@@ -85,6 +91,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
|
||||
if (entOptions.Count > 0)
|
||||
{
|
||||
if (!TryUseCharge((uid, component)))
|
||||
return;
|
||||
|
||||
var (entActId, entAct) = _random.Pick(entOptions);
|
||||
if (entAct.Event != null)
|
||||
{
|
||||
@@ -108,6 +117,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
|
||||
if (entWorldOptions.Count > 0)
|
||||
{
|
||||
if (!TryUseCharge((uid, component)))
|
||||
return;
|
||||
|
||||
var (entActId, entAct) = _random.Pick(entWorldOptions);
|
||||
if (entAct.Event != null)
|
||||
{
|
||||
@@ -132,6 +144,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
if (options.Count == 0)
|
||||
return;
|
||||
|
||||
if (!TryUseCharge((uid, component)))
|
||||
return;
|
||||
|
||||
var (actId, act) = _random.Pick(options);
|
||||
if (act.Event != null)
|
||||
{
|
||||
@@ -163,4 +178,17 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
private bool TryUseCharge(Entity<ActionOnInteractComponent> ent)
|
||||
{
|
||||
if (!ent.Comp.RequiresCharge)
|
||||
return true;
|
||||
|
||||
Entity<LimitedChargesComponent?> charges = ent.Owner;
|
||||
if (_charges.IsEmpty(charges))
|
||||
return false;
|
||||
|
||||
_charges.TryUseCharge(charges);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Chemistry.TileReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class SpillIfPuddlePresentTileReaction : ITileReaction
|
||||
{
|
||||
public FixedPoint2 TileReact(TileRef tile,
|
||||
ReagentPrototype reagent,
|
||||
FixedPoint2 reactVolume,
|
||||
IEntityManager entityManager,
|
||||
List<ReagentData>? data)
|
||||
{
|
||||
var spillSystem = entityManager.System<PuddleSystem>();
|
||||
if (!spillSystem.TryGetPuddle(tile, out _))
|
||||
return FixedPoint2.Zero;
|
||||
|
||||
return spillSystem.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out _, sound: false, tileReact: false)
|
||||
? reactVolume
|
||||
: FixedPoint2.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Content.Server/Chemistry/TileReactions/SpillTileReaction.cs
Normal file
28
Content.Server/Chemistry/TileReactions/SpillTileReaction.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Chemistry.TileReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class SpillTileReaction : ITileReaction
|
||||
{
|
||||
public FixedPoint2 TileReact(TileRef tile,
|
||||
ReagentPrototype reagent,
|
||||
FixedPoint2 reactVolume,
|
||||
IEntityManager entityManager,
|
||||
List<ReagentData>? data)
|
||||
{
|
||||
var spillSystem = entityManager.System<PuddleSystem>();
|
||||
|
||||
return spillSystem.TrySpillAt(tile, new Solution(reagent.ID, reactVolume, data), out _, sound: false, tileReact: false)
|
||||
? reactVolume
|
||||
: FixedPoint2.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,6 +232,9 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
{
|
||||
if (_container.TryGetContainingContainer(targetUid, out var container))
|
||||
{
|
||||
if (container.Owner == owner)
|
||||
return 0f;
|
||||
|
||||
if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent))
|
||||
{
|
||||
if (storageComponent is { Open: false } && _weldable.IsWelded(container.Owner))
|
||||
|
||||
@@ -55,7 +55,6 @@ public sealed class RingerSystem : SharedRingerSystem
|
||||
/// </summary>
|
||||
private void OnGenerateUplinkCode(Entity<RingerUplinkComponent> ent, ref GenerateUplinkCodeEvent ev)
|
||||
{
|
||||
// Generate a new uplink code
|
||||
var code = GenerateRingtone();
|
||||
|
||||
// Set the code on the component
|
||||
@@ -74,6 +73,10 @@ public sealed class RingerSystem : SharedRingerSystem
|
||||
if (!HasComp<StoreComponent>(uid))
|
||||
return false;
|
||||
|
||||
// Wasn't generated yet
|
||||
if (uplink.Code is null)
|
||||
return false;
|
||||
|
||||
// On the server, we always check if the code matches
|
||||
if (!uplink.Code.SequenceEqual(ringtone))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user