diff --git a/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs b/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs index 6deb653030..831d296383 100644 --- a/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs +++ b/Content.Client/GameObjects/Components/Clothing/ClothingComponent.cs @@ -1,11 +1,21 @@ +using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.GameObjects.Components.Items; using SS14.Client.Graphics; +using SS14.Shared.GameObjects; +using SS14.Shared.ViewVariables; +using System; namespace Content.Client.GameObjects.Components.Clothing { public class ClothingComponent : ItemComponent { public override string Name => "Clothing"; + public override uint? NetID => ContentNetIDs.CLOTHING; + public override Type StateType => typeof(ClothingComponentState); + + [ViewVariables(VVAccess.ReadWrite)] + public string ClothingEquippedPrefix { get; set; } public (RSI rsi, RSI.StateId stateId)? GetEquippedStateInfo(EquipmentSlotDefines.SlotFlags slot) { @@ -15,7 +25,8 @@ namespace Content.Client.GameObjects.Components.Clothing } var rsi = GetRSI(); - var stateId = EquippedPrefix != null ? $"{EquippedPrefix}-equipped-{slot}" : $"equipped-{slot}"; + var prefix = ClothingEquippedPrefix ?? EquippedPrefix; + var stateId = prefix != null ? $"{prefix}-equipped-{slot}" : $"equipped-{slot}"; if (rsi.TryGetState(stateId, out _)) { return (rsi, stateId); @@ -23,5 +34,12 @@ namespace Content.Client.GameObjects.Components.Clothing return null; } + + public override void HandleComponentState(ComponentState state) + { + var clothingComponentState = (ClothingComponentState)state; + ClothingEquippedPrefix = clothingComponentState.ClothingEquippedPrefix; + EquippedPrefix = clothingComponentState.EquippedPrefix; + } } } diff --git a/Content.Client/GameObjects/Components/Items/ItemComponent.cs b/Content.Client/GameObjects/Components/Items/ItemComponent.cs index b3bb4e84b7..3db6de991e 100644 --- a/Content.Client/GameObjects/Components/Items/ItemComponent.cs +++ b/Content.Client/GameObjects/Components/Items/ItemComponent.cs @@ -1,4 +1,5 @@ -using Content.Shared.GameObjects.Components.Inventory; +using Content.Shared.GameObjects; +using Content.Shared.GameObjects.Components.Items; using SS14.Client.Graphics; using SS14.Client.Interfaces.ResourceManagement; using SS14.Client.ResourceManagement; @@ -8,12 +9,15 @@ using SS14.Shared.IoC; using SS14.Shared.Serialization; using SS14.Shared.Utility; using SS14.Shared.ViewVariables; +using System; namespace Content.Client.GameObjects { public class ItemComponent : Component { public override string Name => "Item"; + public override uint? NetID => ContentNetIDs.ITEM; + public override Type StateType => typeof(ItemComponentState); [ViewVariables] protected ResourcePath RsiPath; @@ -56,5 +60,11 @@ namespace Content.Client.GameObjects var resourceCache = IoCManager.Resolve(); return resourceCache.GetResource(SharedSpriteComponent.TextureRoot / RsiPath).RSI; } + + public override void HandleComponentState(ComponentState state) + { + var itemComponentState = (ItemComponentState)state; + EquippedPrefix = itemComponentState.EquippedPrefix; + } } } diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index 87e1b16e9e..0e2a7cda69 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -20,6 +20,7 @@ namespace Content.Server.GameObjects.Components.Interactable [ViewVariables] private ContainerSlot _cellContainer; private PointLightComponent _pointLight; private SpriteComponent _spriteComponent; + private ClothingComponent _clothingComponent; [ViewVariables] private PowerCellComponent Cell @@ -70,6 +71,7 @@ namespace Content.Server.GameObjects.Components.Interactable _pointLight = Owner.GetComponent(); _spriteComponent = Owner.GetComponent(); + Owner.TryGetComponent(out _clothingComponent); _cellContainer = ContainerManagerComponent.Ensure("flashlight_cell_container", Owner, out var existed); @@ -92,13 +94,11 @@ namespace Content.Server.GameObjects.Components.Interactable // Update sprite and light states to match the activation. if (Activated) { - _spriteComponent.LayerSetState(0, "lantern_on"); - _pointLight.State = LightState.On; + SetState(LightState.On); } else { - _spriteComponent.LayerSetState(0, "lantern_off"); - _pointLight.State = LightState.Off; + SetState(LightState.Off); } // Toggle always succeeds. @@ -109,8 +109,7 @@ namespace Content.Server.GameObjects.Components.Interactable { if (!Activated) return; - _spriteComponent.LayerSetState(0, "lantern_off"); - _pointLight.State = LightState.Off; + SetState(LightState.Off); Activated = false; } @@ -126,8 +125,17 @@ namespace Content.Server.GameObjects.Components.Interactable // Simple enough. if (cell.AvailableCharge(1) < Wattage) return; - _spriteComponent.LayerSetState(0, "lantern_on"); - _pointLight.State = LightState.On; + SetState(LightState.On); + } + + private void SetState(LightState newState) + { + _spriteComponent.LayerSetVisible(1, newState == LightState.On); + _pointLight.State = newState; + if (_clothingComponent != null) + { + _clothingComponent.ClothingEquippedPrefix = newState.ToString(); + } } public void OnUpdate(float frameTime) diff --git a/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs b/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs index 6bd553fe75..8aa0af932f 100644 --- a/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Clothing/ClothingComponent.cs @@ -1,4 +1,7 @@ -using SS14.Shared.Serialization; +using Content.Shared.GameObjects; +using Content.Shared.GameObjects.Components.Items; +using SS14.Shared.GameObjects; +using SS14.Shared.Serialization; using System; using System.Collections.Generic; using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines; @@ -8,11 +11,28 @@ namespace Content.Server.GameObjects public class ClothingComponent : ItemComponent { public override string Name => "Clothing"; + public override uint? NetID => ContentNetIDs.CLOTHING; + public override Type StateType => typeof(ClothingComponentState); + public SlotFlags SlotFlags = SlotFlags.PREVENTEQUIP; //Different from None, NONE allows equips if no slot flags are required private int _heatResistance; public int HeatResistance => _heatResistance; + private string _clothingEquippedPrefix; + public string ClothingEquippedPrefix + { + get + { + return _clothingEquippedPrefix; + } + set + { + Dirty(); + _clothingEquippedPrefix = value; + } + } + public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); @@ -28,5 +48,10 @@ namespace Content.Server.GameObjects serializer.DataFieldCached(ref _heatResistance, "HeatResistance", 323); } + + public override ComponentState GetComponentState() + { + return new ClothingComponentState(ClothingEquippedPrefix, EquippedPrefix); + } } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 153c730948..26ae93ef90 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -3,13 +3,32 @@ using SS14.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; using SS14.Shared.Interfaces.GameObjects; using Content.Server.GameObjects.EntitySystems; +using SS14.Shared.GameObjects; +using System; +using Content.Shared.GameObjects.Components.Items; namespace Content.Server.GameObjects { public class ItemComponent : StoreableComponent, IAttackHand { public override string Name => "Item"; + public override uint? NetID => ContentNetIDs.ITEM; + public override Type StateType => typeof(ItemComponentState); + private string _equippedPrefix; + + public string EquippedPrefix + { + get + { + return _equippedPrefix; + } + set + { + Dirty(); + _equippedPrefix = value; + } + } public void RemovedFromSlot() { @@ -63,5 +82,10 @@ namespace Content.Server.GameObjects } } } + + public override ComponentState GetComponentState() + { + return new ItemComponentState(EquippedPrefix); + } } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs index 76b7ba9666..946b7eb636 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/StoreableComponent.cs @@ -1,10 +1,5 @@ using SS14.Shared.GameObjects; using SS14.Shared.Serialization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Content.Server.GameObjects { diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index 9b6c55ce85..a8ec723674 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -69,6 +69,8 @@ + + @@ -118,4 +120,4 @@ - + \ No newline at end of file diff --git a/Content.Shared/GameObjects/Components/Items/ClothingComponentState.cs b/Content.Shared/GameObjects/Components/Items/ClothingComponentState.cs new file mode 100644 index 0000000000..39ef0c7f09 --- /dev/null +++ b/Content.Shared/GameObjects/Components/Items/ClothingComponentState.cs @@ -0,0 +1,17 @@ +using SS14.Shared.GameObjects; +using SS14.Shared.Serialization; +using System; + +namespace Content.Shared.GameObjects.Components.Items +{ + [Serializable, NetSerializable] + public class ClothingComponentState : ItemComponentState + { + public string ClothingEquippedPrefix { get; set; } + + public ClothingComponentState(string clothingEquippedPrefix, string equippedPrefix) : base(equippedPrefix, ContentNetIDs.CLOTHING) + { + ClothingEquippedPrefix = clothingEquippedPrefix; + } + } +} diff --git a/Content.Shared/GameObjects/Components/Items/ItemComponentState.cs b/Content.Shared/GameObjects/Components/Items/ItemComponentState.cs new file mode 100644 index 0000000000..7af71c3ae2 --- /dev/null +++ b/Content.Shared/GameObjects/Components/Items/ItemComponentState.cs @@ -0,0 +1,22 @@ +using SS14.Shared.GameObjects; +using SS14.Shared.Serialization; +using System; + +namespace Content.Shared.GameObjects.Components.Items +{ + [Serializable, NetSerializable] + public class ItemComponentState : ComponentState + { + public string EquippedPrefix { get; set; } + + public ItemComponentState(string equippedPrefix) : base(ContentNetIDs.ITEM) + { + EquippedPrefix = equippedPrefix; + } + + protected ItemComponentState(string equippedPrefix, uint netId) : base(netId) + { + EquippedPrefix = equippedPrefix; + } + } +} diff --git a/Content.Shared/GameObjects/ContentNetIDs.cs b/Content.Shared/GameObjects/ContentNetIDs.cs index cffb1f54b4..5fc2a2d496 100644 --- a/Content.Shared/GameObjects/ContentNetIDs.cs +++ b/Content.Shared/GameObjects/ContentNetIDs.cs @@ -15,5 +15,7 @@ public const uint RANGED_WEAPON = 1010; public const uint CAMERA_RECOIL = 1011; public const uint SOUND = 1012; + public const uint ITEM = 1013; + public const uint CLOTHING = 1014; } } diff --git a/Resources/Prototypes/Entities/Clothing/helmets.yml b/Resources/Prototypes/Entities/Clothing/helmets.yml index da9a4460e8..c53e55a095 100644 --- a/Resources/Prototypes/Entities/Clothing/helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/helmets.yml @@ -14,3 +14,27 @@ Slots: - head sprite: Clothing/helmet_sec.rsi + +- type: entity + parent: Clothing + id: HelmetEngineering + name: Hard hat + description: A piece of headgear used in dangerous working conditions to protect the head. Comes with a built-in flashlight. + components: + - type: HandheldLight + - type: PointLight + state: Off + - type: Sprite + sprite: Clothing/helmet_engineering.rsi + layers: + - state: HelmetEngineering + - state: HandheldLightOnOverlay + shader: unshaded + visible: false + - type: Icon + sprite: Clothing/helmet_engineering.rsi + state: HelmetEngineering + - type: Clothing + Slots: + - head + sprite: Clothing/helmet_engineering.rsi \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Items.yml b/Resources/Prototypes/Entities/Items.yml index 8a7f5ad52a..7a24945ac8 100644 --- a/Resources/Prototypes/Entities/Items.yml +++ b/Resources/Prototypes/Entities/Items.yml @@ -92,7 +92,11 @@ - type: HandheldLight - type: Sprite sprite: Objects/lantern.rsi - state: lantern_off + layers: + - state: lantern_off + - state: HandheldLightOnOverlay + shader: unshaded + visible: false - type: Icon sprite: Objects/lantern.rsi state: lantern_off diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/HandheldLightOnOverlay.png b/Resources/Textures/Clothing/helmet_engineering.rsi/HandheldLightOnOverlay.png new file mode 100644 index 0000000000..302bb018e5 Binary files /dev/null and b/Resources/Textures/Clothing/helmet_engineering.rsi/HandheldLightOnOverlay.png differ diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/HelmetEngineering.png b/Resources/Textures/Clothing/helmet_engineering.rsi/HelmetEngineering.png new file mode 100644 index 0000000000..d4478639c4 Binary files /dev/null and b/Resources/Textures/Clothing/helmet_engineering.rsi/HelmetEngineering.png differ diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/Off-equipped-HELMET.png b/Resources/Textures/Clothing/helmet_engineering.rsi/Off-equipped-HELMET.png new file mode 100644 index 0000000000..e11f14967f Binary files /dev/null and b/Resources/Textures/Clothing/helmet_engineering.rsi/Off-equipped-HELMET.png differ diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/On-equipped-HELMET.png b/Resources/Textures/Clothing/helmet_engineering.rsi/On-equipped-HELMET.png new file mode 100644 index 0000000000..6aa5db8def Binary files /dev/null and b/Resources/Textures/Clothing/helmet_engineering.rsi/On-equipped-HELMET.png differ diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/equipped-HELMET.png b/Resources/Textures/Clothing/helmet_engineering.rsi/equipped-HELMET.png new file mode 100644 index 0000000000..e11f14967f Binary files /dev/null and b/Resources/Textures/Clothing/helmet_engineering.rsi/equipped-HELMET.png differ diff --git a/Resources/Textures/Clothing/helmet_engineering.rsi/meta.json b/Resources/Textures/Clothing/helmet_engineering.rsi/meta.json new file mode 100644 index 0000000000..fc9cdce5e6 --- /dev/null +++ b/Resources/Textures/Clothing/helmet_engineering.rsi/meta.json @@ -0,0 +1,51 @@ +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from https://github.com/discordia-space/CEV-Eris at commit 9a3a3a180344460263e8df7ea2565128e07b86b5", + "states": [ + { + "name": "Off-equipped-HELMET", + "directions": 4, + "delays": [ + [ 1.0 ], + [ 1.0 ], + [ 1.0 ], + [ 1.0 ] + ] + }, + { + "name": "On-equipped-HELMET", + "directions": 4, + "delays": [ + [ 1.0 ], + [ 1.0 ], + [ 1.0 ], + [ 1.0 ] + ] + }, + { + "name": "equipped-HELMET", + "directions": 4, + "delays": [ + [ 1.0 ], + [ 1.0 ], + [ 1.0 ], + [ 1.0 ] + ] + }, + { + "name": "HelmetEngineering", + "directions": 1, + "delays": [ [ 1.0 ] ] + }, + { + "name": "HandheldLightOnOverlay", + "directions": 1, + "delays": [ [ 1.0 ] ] + } + ] +} diff --git a/Resources/Textures/Clothing/helmet_sec.rsi/meta.json b/Resources/Textures/Clothing/helmet_sec.rsi/meta.json index 7a185f0ae9..3f9020d7c2 100644 --- a/Resources/Textures/Clothing/helmet_sec.rsi/meta.json +++ b/Resources/Textures/Clothing/helmet_sec.rsi/meta.json @@ -1 +1,26 @@ -{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris at commit 9a3a3a180344460263e8df7ea2565128e07b86b5", "states": [{"name": "equipped-HELMET", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "helmet", "directions": 1, "delays": [[1.0]]}]} \ No newline at end of file +{ + "version": 1, + "size": { + "x": 32, + "y": 32 + }, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from https://github.com/discordia-space/CEV-Eris at commit 9a3a3a180344460263e8df7ea2565128e07b86b5", + "states": [ + { + "name": "equipped-HELMET", + "directions": 4, + "delays": [ + [ 1.0 ], + [ 1.0 ], + [ 1.0 ], + [ 1.0 ] + ] + }, + { + "name": "helmet", + "directions": 1, + "delays": [ [ 1.0 ] ] + } + ] +} diff --git a/Resources/Textures/Objects/lantern.rsi/HandheldLightOnOverlay.png b/Resources/Textures/Objects/lantern.rsi/HandheldLightOnOverlay.png new file mode 100644 index 0000000000..b08e42294f Binary files /dev/null and b/Resources/Textures/Objects/lantern.rsi/HandheldLightOnOverlay.png differ diff --git a/Resources/Textures/Objects/lantern.rsi/lantern_on.png b/Resources/Textures/Objects/lantern.rsi/lantern_on.png deleted file mode 100644 index b292f1c8b2..0000000000 Binary files a/Resources/Textures/Objects/lantern.rsi/lantern_on.png and /dev/null differ diff --git a/Resources/Textures/Objects/lantern.rsi/meta.json b/Resources/Textures/Objects/lantern.rsi/meta.json index 0cb4b371cd..ba7d8a3bef 100644 --- a/Resources/Textures/Objects/lantern.rsi/meta.json +++ b/Resources/Textures/Objects/lantern.rsi/meta.json @@ -1,4 +1,4 @@ -{ +{ "version": 1, "size": { "x": 32, @@ -17,7 +17,7 @@ ] }, { - "name": "lantern_on", + "name": "HandheldLightOnOverlay", "select": [], "flags": {}, "directions": 1,