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?
This commit is contained in:
PrPleGoo
2019-04-08 12:18:27 +02:00
committed by Pieter-Jan Briers
parent 50433c7ab6
commit 35f3cbe3f9
22 changed files with 248 additions and 21 deletions

View File

@@ -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)

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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
{