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)