Files
tbd-station-14/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs
Pieter-Jan Briers 0ac4c0e85c SKREEEEEE (#3706)
* Import bird sprites and define basic mob.

* SKREEEEEEEEE

* Move hair styles to new sprite accessory prototypes.

Basic stuff, no multi-species stuff yet.

* Vox hair styles and clothes

* Make HumanoidCharacterProfile.Default() a static default to fix tests.

Usages that wanted the previous random behavior now call Random().

* Remove names from hair style prototypes.

(They're in localization files)

* Update Content.Shared/Actions/ActionType.cs

(sk)reeee github

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2021-03-28 17:26:32 +11:00

116 lines
3.4 KiB
C#

using Content.Client.GameObjects.Components.HUD.Inventory;
using Content.Client.GameObjects.Components.Items;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.Components.Items;
using Robust.Client.Graphics;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.Components.Clothing
{
[RegisterComponent]
[ComponentReference(typeof(ItemComponent))]
[ComponentReference(typeof(IItemComponent))]
public class ClothingComponent : ItemComponent
{
[DataField("femaleMask")]
private FemaleClothingMask _femaleMask = FemaleClothingMask.UniformFull;
public override string Name => "Clothing";
public override uint? NetID => ContentNetIDs.CLOTHING;
private string? _clothingEquippedPrefix;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("ClothingPrefix")]
public string? ClothingEquippedPrefix
{
get => _clothingEquippedPrefix;
set
{
if (_clothingEquippedPrefix == value)
return;
_clothingEquippedPrefix = value;
if(!Initialized) return;
if (!Owner.TryGetContainer(out IContainer? container))
return;
if (!container.Owner.TryGetComponent(out ClientInventoryComponent? inventory))
return;
if (!inventory.TryFindItemSlots(Owner, out EquipmentSlotDefines.Slots? slots))
return;
inventory.SetSlotVisuals(slots.Value, Owner);
}
}
public override void Initialize()
{
base.Initialize();
ClothingEquippedPrefix = ClothingEquippedPrefix;
}
[ViewVariables(VVAccess.ReadWrite)]
public FemaleClothingMask FemaleMask
{
get => _femaleMask;
set => _femaleMask = value;
}
public (RSI rsi, RSI.StateId stateId)? GetEquippedStateInfo(EquipmentSlotDefines.SlotFlags slot, string? speciesId=null)
{
if (RsiPath == null)
{
return null;
}
var rsi = GetRSI();
if (rsi == null)
{
return null;
}
var prefix = ClothingEquippedPrefix ?? EquippedPrefix;
var stateId = prefix != null ? $"{prefix}-equipped-{slot}" : $"equipped-{slot}";
if (speciesId != null)
{
var speciesState = $"{stateId}-{speciesId}";
if (rsi.TryGetState(speciesState, out _))
{
return (rsi, speciesState);
}
}
if (rsi.TryGetState(stateId, out _))
{
return (rsi, stateId);
}
return null;
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
if (curState is not ClothingComponentState state)
{
return;
}
ClothingEquippedPrefix = state.ClothingEquippedPrefix;
EquippedPrefix = state.EquippedPrefix;
}
}
public enum FemaleClothingMask : byte
{
NoMask = 0,
UniformFull,
UniformTop
}
}