Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Shared.DoAfter;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Rotation;
|
||||
@@ -24,6 +25,7 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!; // WD EDIT
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!; // WD EDIT
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!; // WD EDIT
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!; // WD EDIT
|
||||
|
||||
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
|
||||
private const int StandingCollisionLayer = (int)CollisionGroup.MidImpassable;
|
||||
@@ -64,6 +66,11 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_mobState.IsAlive(uid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsDown(uid))
|
||||
{
|
||||
TryStandUp(uid);
|
||||
@@ -123,13 +130,13 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
|
||||
if (standingState.CurrentState is not StandingState.Lying)
|
||||
return false;
|
||||
|
||||
standingState.CurrentState = StandingState.GettingUp;
|
||||
var doargs = new DoAfterArgs(EntityManager, uid, standingState.StandingUpTime,
|
||||
new StandingUpDoAfterEvent(), uid)
|
||||
{
|
||||
BreakOnMove = false,
|
||||
BreakOnDamage = false,
|
||||
BreakOnHandChange = false
|
||||
BreakOnHandChange = false,
|
||||
RequireCanInteract = false
|
||||
};
|
||||
|
||||
if (!_doAfter.TryStartDoAfter(doargs))
|
||||
@@ -141,7 +148,7 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
|
||||
|
||||
public bool TryLieDown(EntityUid uid, StandingStateComponent? standingState = null, bool dropHeldItems = false)
|
||||
{
|
||||
if (!Resolve(uid, ref standingState, false))
|
||||
if (!Resolve(uid, ref standingState, false) || !standingState.CanLieDown)
|
||||
return false;
|
||||
|
||||
if (standingState.CurrentState is not StandingState.Standing)
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Content.Shared.Standing.Systems;
|
||||
public abstract partial class SharedStandingStateSystem
|
||||
{
|
||||
[Dependency] protected readonly IRobustRandom Random = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
|
||||
private void InitializeColliding()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared._White.PolymorphableCanister;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||
public sealed partial class PolymorphableCanisterComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public ResPath ResPath = new("Structures/Storage/canister.rsi");
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public ProtoId<EntityPrototype>? CurrentPrototype;
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public int DoAfterTime = 3;
|
||||
|
||||
[DataField]
|
||||
public List<ProtoId<EntityPrototype>> Prototypes = new()
|
||||
{
|
||||
"GasCanister",
|
||||
"StorageCanister",
|
||||
"AirCanister",
|
||||
"OxygenCanister",
|
||||
"NitrogenCanister",
|
||||
"CarbonDioxideCanister",
|
||||
"PlasmaCanister",
|
||||
"TritiumCanister",
|
||||
"WaterVaporCanister",
|
||||
"AmmoniaCanister",
|
||||
"NitrousOxideCanister",
|
||||
"FrezonCanister",
|
||||
"BZCanister",
|
||||
"PluoxiumCanister",
|
||||
"HydrogenCanister",
|
||||
"NitriumCanister",
|
||||
"HealiumCanister",
|
||||
"HyperNobliumCanister",
|
||||
"ProtoNitrateCanister",
|
||||
"ZaukerCanister",
|
||||
"HalonCanister",
|
||||
"HeliumCanister",
|
||||
"AntiNobliumCanister",
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._White.PolymorphableCanister;
|
||||
|
||||
public abstract class SharedPolymorphableCanisterSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PolymorphableCanisterComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<PolymorphableCanisterComponent, PolymorphableCanisterMessage>(OnMessage);
|
||||
SubscribeLocalEvent<PolymorphableCanisterComponent, PolymorphableCanisterDoAfterEvent>(OnDoAfter);
|
||||
}
|
||||
|
||||
private void OnInit(Entity<PolymorphableCanisterComponent> ent, ref ComponentInit args)
|
||||
{
|
||||
var proto = MetaData(ent.Owner).EntityPrototype;
|
||||
if (proto is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ent.Comp.CurrentPrototype = proto.ID;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
private void OnMessage(Entity<PolymorphableCanisterComponent> ent, ref PolymorphableCanisterMessage args)
|
||||
{
|
||||
if (!args.Session.AttachedEntity.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager,
|
||||
args.Session.AttachedEntity.Value,
|
||||
ent.Comp.DoAfterTime,
|
||||
new PolymorphableCanisterDoAfterEvent(args.ProtoId),
|
||||
ent.Owner
|
||||
)
|
||||
{
|
||||
BreakOnMove = true,
|
||||
NeedHand = true
|
||||
};
|
||||
|
||||
_doAfter.TryStartDoAfter(doAfterArgs);
|
||||
}
|
||||
|
||||
private void OnDoAfter(Entity<PolymorphableCanisterComponent> ent, ref PolymorphableCanisterDoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ent.Comp.CurrentPrototype = args.ProtoId;
|
||||
UpdateAppearance(ent, args.ProtoId);
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
public void UpdateAppearance(EntityUid uid, ProtoId<EntityPrototype>? protoId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(protoId) || !_proto.TryIndex(protoId, out var proto))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var metadata = MetaData(uid);
|
||||
_metaData.SetEntityName(uid, proto.Name, metadata);
|
||||
_metaData.SetEntityDescription(uid, proto.Description, metadata);
|
||||
|
||||
UpdateSprite(uid, proto);
|
||||
}
|
||||
|
||||
protected virtual void UpdateSprite(EntityUid uid, EntityPrototype proto)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum PolymorphableCanisterUiKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class PolymorphableCanisterMessage(string protoId) : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly ProtoId<EntityPrototype> ProtoId = protoId;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class PolymorphableCanisterDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
public readonly ProtoId<EntityPrototype> ProtoId;
|
||||
|
||||
public PolymorphableCanisterDoAfterEvent(string protoId)
|
||||
{
|
||||
ProtoId = protoId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user