Fix smoking visuals, but properly this time. (#6051)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,8 @@ namespace Content.Client.Clothing
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("femaleMask")]
|
[DataField("femaleMask")]
|
||||||
public FemaleClothingMask FemaleMask { get; } = FemaleClothingMask.UniformFull;
|
public FemaleClothingMask FemaleMask { get; } = FemaleClothingMask.UniformFull;
|
||||||
|
|
||||||
|
public string? InSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FemaleClothingMask : byte
|
public enum FemaleClothingMask : byte
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Content.Shared.CharacterAppearance;
|
|||||||
using Content.Shared.Clothing;
|
using Content.Shared.Clothing;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
@@ -46,9 +47,24 @@ public class ClothingSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ClothingComponent, GotEquippedEvent>(OnGotEquipped);
|
SubscribeLocalEvent<ClothingComponent, GotEquippedEvent>(OnGotEquipped);
|
||||||
|
SubscribeLocalEvent<ClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||||
|
SubscribeLocalEvent<ClientInventoryComponent, ItemPrefixChangeEvent>(OnPrefixChanged);
|
||||||
SubscribeLocalEvent<SpriteComponent, DidUnequipEvent>(OnDidUnequip);
|
SubscribeLocalEvent<SpriteComponent, DidUnequipEvent>(OnDidUnequip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPrefixChanged(EntityUid uid, ClientInventoryComponent component, ItemPrefixChangeEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp(args.Item, out ClothingComponent? clothing) || clothing.InSlot == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RenderEquipment(uid, args.Item, clothing.InSlot, component, null, clothing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
|
||||||
|
{
|
||||||
|
component.InSlot = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEvent args)
|
private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEvent args)
|
||||||
{
|
{
|
||||||
component.LayerSetVisible(args.Slot, false);
|
component.LayerSetVisible(args.Slot, false);
|
||||||
@@ -71,6 +87,8 @@ public class ClothingSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnGotEquipped(EntityUid uid, ClothingComponent component, GotEquippedEvent args)
|
private void OnGotEquipped(EntityUid uid, ClothingComponent component, GotEquippedEvent args)
|
||||||
{
|
{
|
||||||
|
component.InSlot = args.Slot;
|
||||||
|
|
||||||
if (!TryComp<SpriteComponent>(args.Equipee, out var sprite) || !TryComp<ClientInventoryComponent>(args.Equipee, out var invComp))
|
if (!TryComp<SpriteComponent>(args.Equipee, out var sprite) || !TryComp<ClientInventoryComponent>(args.Equipee, out var invComp))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace Content.Shared.Hands
|
|||||||
SubscribeAllEvent<RequestSetHandEvent>(HandleSetHand);
|
SubscribeAllEvent<RequestSetHandEvent>(HandleSetHand);
|
||||||
SubscribeLocalEvent<SharedHandsComponent, EntRemovedFromContainerMessage>(HandleContainerRemoved);
|
SubscribeLocalEvent<SharedHandsComponent, EntRemovedFromContainerMessage>(HandleContainerRemoved);
|
||||||
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleContainerModified);
|
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleContainerModified);
|
||||||
|
SubscribeLocalEvent<SharedHandsComponent, ItemPrefixChangeEvent>(OnPrefixChanged);
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.Drop, new PointerInputCmdHandler(DropPressed))
|
.Bind(ContentKeyFunctions.Drop, new PointerInputCmdHandler(DropPressed))
|
||||||
@@ -33,6 +34,15 @@ namespace Content.Shared.Hands
|
|||||||
.Register<SharedHandsSystem>();
|
.Register<SharedHandsSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPrefixChanged(EntityUid uid, SharedHandsComponent component, ItemPrefixChangeEvent args)
|
||||||
|
{
|
||||||
|
// update hands visuals if this item is in a hand (rather then inventory or other container).
|
||||||
|
if (component.HasHand(args.ContainerId))
|
||||||
|
{
|
||||||
|
UpdateHandVisuals(uid, component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace Content.Shared.Item
|
|||||||
private void OnEquippedPrefixChange()
|
private void OnEquippedPrefixChange()
|
||||||
{
|
{
|
||||||
if (Owner.TryGetContainer(out var container))
|
if (Owner.TryGetContainer(out var container))
|
||||||
EntitySystem.Get<SharedHandsSystem>().UpdateHandVisuals(container.Owner);
|
_entMan.EventBus.RaiseLocalEvent(container.Owner, new ItemPrefixChangeEvent(Owner, container.ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovedFromSlot()
|
public void RemovedFromSlot()
|
||||||
@@ -154,6 +154,23 @@ namespace Content.Shared.Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when an item's EquippedPrefix is changed. The event is directed at the entity that contains this item, so
|
||||||
|
/// that it can properly update its sprite/GUI.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public class ItemPrefixChangeEvent : EntityEventArgs
|
||||||
|
{
|
||||||
|
public readonly EntityUid Item;
|
||||||
|
public readonly string ContainerId;
|
||||||
|
|
||||||
|
public ItemPrefixChangeEvent(EntityUid item, string containerId)
|
||||||
|
{
|
||||||
|
Item = item;
|
||||||
|
ContainerId = containerId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reference sizes for common containers and items.
|
/// Reference sizes for common containers and items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user