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