Engineer's helmet (#188)
* refacting some sprite things * fix sprites * Netcode for sending a new icon state to the ClientComponent * Fixed broken torches. * Fix dirty calls. * ClothingComponentState now also includes EquippedPrefix * Inherritance ClothingComponent : ItemComponent * Added parameter to ItemComponentState constructor. * Update RobustToolbox * Revert "Update RobustToolbox" This reverts commit 82c7e98ff3853b64698d5e80a45cd7a3758618e0. Undo weird commit to toolbox?
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<IResourceCache>();
|
||||
return resourceCache.GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / RsiPath).RSI;
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState state)
|
||||
{
|
||||
var itemComponentState = (ItemComponentState)state;
|
||||
EquippedPrefix = itemComponentState.EquippedPrefix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<PointLightComponent>();
|
||||
_spriteComponent = Owner.GetComponent<SpriteComponent>();
|
||||
Owner.TryGetComponent(out _clothingComponent);
|
||||
_cellContainer =
|
||||
ContainerManagerComponent.Ensure<ContainerSlot>("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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
<Compile Include="GameObjects\Components\Inventory\EquipmentSlotDefinitions.cs" />
|
||||
<Compile Include="GameObjects\Components\Inventory\InventoryTemplates.cs" />
|
||||
<Compile Include="GameObjects\Components\Inventory\SharedInventoryComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\ClothingComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Items\ItemComponentState.cs" />
|
||||
<Compile Include="GameObjects\Components\Markers\SharedSpawnPointComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\SharedCameraRecoilComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\PowerShared.cs" />
|
||||
@@ -118,4 +120,4 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
51
Resources/Textures/Clothing/helmet_engineering.rsi/meta.json
Normal file
@@ -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 ] ]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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]]}]}
|
||||
{
|
||||
"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 ] ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 293 B |
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
@@ -17,7 +17,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lantern_on",
|
||||
"name": "HandheldLightOnOverlay",
|
||||
"select": [],
|
||||
"flags": {},
|
||||
"directions": 1,
|
||||
|
||||