Item status!
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Server.GameObjects.Components.Sound;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
@@ -20,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
/// Component that represents a handheld lightsource which can be toggled on and off.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
internal class HandheldLightComponent : Component, IUse, IExamine, IAttackBy, IMapInit
|
||||
internal sealed class HandheldLightComponent : SharedHandheldLightComponent, IUse, IExamine, IAttackBy, IMapInit
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ISharedNotifyManager _notifyManager;
|
||||
@@ -44,9 +45,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string Name => "HandheldLight";
|
||||
|
||||
/// <summary>
|
||||
/// Status of light, whether or not it is emitting light.
|
||||
@@ -73,7 +71,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void IExamine.Examine(FormattedMessage message)
|
||||
@@ -153,6 +150,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
soundComponent.Play("/Audio/machines/button.ogg");
|
||||
}
|
||||
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Cell missing..."));
|
||||
return;
|
||||
}
|
||||
@@ -166,6 +164,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
soundComponent.Play("/Audio/machines/button.ogg");
|
||||
}
|
||||
|
||||
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
|
||||
return;
|
||||
}
|
||||
@@ -195,6 +194,8 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
var cell = Cell;
|
||||
if (cell == null || !cell.TryDeductWattage(Wattage, frameTime)) TurnOff();
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
private void EjectCell(IEntity user)
|
||||
@@ -227,6 +228,23 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
if (Cell == null)
|
||||
{
|
||||
return new HandheldLightComponentState(null);
|
||||
}
|
||||
|
||||
if (Cell.AvailableCharge(1) < Wattage)
|
||||
{
|
||||
// Practically zero.
|
||||
// This is so the item status works correctly.
|
||||
return new HandheldLightComponentState(0);
|
||||
}
|
||||
|
||||
return new HandheldLightComponentState(Cell.Charge / Cell.Capacity);
|
||||
}
|
||||
|
||||
[Verb]
|
||||
public sealed class EjectCellVerb : Verb<HandheldLightComponent>
|
||||
{
|
||||
@@ -252,6 +270,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper", Owner.Transform.GridPosition);
|
||||
_cellContainer.Insert(cell);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -32,6 +34,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
#pragma warning restore 649
|
||||
|
||||
public override string Name => "Welder";
|
||||
public override uint? NetID => ContentNetIDs.WELDER;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum fuel capacity the welder can hold
|
||||
@@ -40,8 +43,13 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
public float FuelCapacity
|
||||
{
|
||||
get => _fuelCapacity;
|
||||
set => _fuelCapacity = value;
|
||||
set
|
||||
{
|
||||
_fuelCapacity = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
private float _fuelCapacity = 50;
|
||||
|
||||
/// <summary>
|
||||
@@ -51,9 +59,15 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
public float Fuel
|
||||
{
|
||||
get => _fuel;
|
||||
set => _fuel = value;
|
||||
set
|
||||
{
|
||||
_fuel = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
private float _fuel = 0;
|
||||
private bool _activated = false;
|
||||
|
||||
/// <summary>
|
||||
/// Default Cost of using the welder fuel for an action
|
||||
@@ -69,7 +83,15 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
/// Status of welder, whether it is ignited
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Activated { get; private set; } = false;
|
||||
public bool Activated
|
||||
{
|
||||
get => _activated;
|
||||
private set
|
||||
{
|
||||
_activated = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
//private string OnSprite { get; set; }
|
||||
//private string OffSprite { get; set; }
|
||||
@@ -87,6 +109,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
|
||||
serializer.DataField(ref _fuelCapacity, "Capacity", 50);
|
||||
serializer.DataField(ref _fuel, "Fuel", FuelCapacity);
|
||||
serializer.DataField(ref _activated, "Activated", false);
|
||||
}
|
||||
|
||||
public void OnUpdate(float frameTime)
|
||||
@@ -185,5 +208,10 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
||||
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||
.Play(file, AudioParams.Default.WithVolume(volume));
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new WelderComponentState(FuelCapacity, Fuel, Activated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user