Chameleon clothing hides identity (#12642)
This commit is contained in:
parent
186b8e00da
commit
1cae861f40
|
|
@ -1,5 +1,8 @@
|
|||
using Content.Shared.Clothing.Components;
|
||||
using Content.Server.IdentityManagement;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Clothing.EntitySystems;
|
||||
using Content.Shared.IdentityManagement.Components;
|
||||
using Content.Shared.Prototypes;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
|
|
@ -11,6 +14,8 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
|
|||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly IComponentFactory _factory = default!;
|
||||
[Dependency] private readonly IdentitySystem _identity = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
|
@ -91,8 +96,20 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
|
|||
return;
|
||||
component.SelectedId = protoId;
|
||||
|
||||
UpdateIdentityBlocker(uid, component, proto);
|
||||
UpdateVisuals(uid, component);
|
||||
UpdateUi(uid, component);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private void UpdateIdentityBlocker(EntityUid uid, ChameleonClothingComponent component, EntityPrototype proto)
|
||||
{
|
||||
if (proto.HasComponent<IdentityBlockerComponent>(_factory))
|
||||
EnsureComp<IdentityBlockerComponent>(uid);
|
||||
else
|
||||
RemComp<IdentityBlockerComponent>(uid);
|
||||
|
||||
if (component.User != null)
|
||||
_identity.QueueIdentityUpdate(component.User.Value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ public sealed class ChameleonClothingComponent : Component
|
|||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("default", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? SelectedId;
|
||||
|
||||
/// <summary>
|
||||
/// Current user that wears chameleon clothing.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public EntityUid? User;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
|
@ -13,6 +14,23 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
|
|||
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
|
||||
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ChameleonClothingComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<ChameleonClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||
}
|
||||
|
||||
private void OnGotEquipped(EntityUid uid, ChameleonClothingComponent component, GotEquippedEvent args)
|
||||
{
|
||||
component.User = args.Equipee;
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(EntityUid uid, ChameleonClothingComponent component, GotUnequippedEvent args)
|
||||
{
|
||||
component.User = null;
|
||||
}
|
||||
|
||||
// Updates chameleon visuals and meta information.
|
||||
// This function is called on a server after user selected new outfit.
|
||||
// And after that on a client after state was updated.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
- type: ChameleonClothing
|
||||
slot: [mask]
|
||||
default: ClothingMaskGas
|
||||
- type: IdentityBlocker # need that for default ClothingMaskGas
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.ChameleonUiKey.Key
|
||||
|
|
|
|||
Loading…
Reference in New Issue