Refactor a bunch of stuff.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -13,26 +14,29 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Client.GameObjects.Components.Interactable
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ToolComponent : SharedToolComponent, IItemStatus
|
||||
public class MultiToolComponent : Component, IItemStatus
|
||||
{
|
||||
private Tool _behavior;
|
||||
private ToolQuality _behavior;
|
||||
private bool _statusShowBehavior;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
||||
[ViewVariables] public bool StatusShowBehavior => _statusShowBehavior;
|
||||
[ViewVariables] public override Tool Behavior => _behavior;
|
||||
[ViewVariables] public ToolQuality Behavior => _behavior;
|
||||
|
||||
public override string Name => "MultiTool";
|
||||
public override uint? NetID => ContentNetIDs.MULTITOOLS;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _statusShowBehavior, "statusShowBehavior", false);
|
||||
serializer.DataField(ref _statusShowBehavior, "statusShowBehavior", true);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||
{
|
||||
if (!(curState is ToolComponentState tool)) return;
|
||||
if (!(curState is MultiToolComponentState tool)) return;
|
||||
|
||||
_behavior = tool.Behavior;
|
||||
_behavior = tool.Quality;
|
||||
_uiUpdateNeeded = true;
|
||||
|
||||
}
|
||||
@@ -41,10 +45,10 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
|
||||
private sealed class StatusControl : Control
|
||||
{
|
||||
private readonly ToolComponent _parent;
|
||||
private readonly MultiToolComponent _parent;
|
||||
private readonly RichTextLabel _label;
|
||||
|
||||
public StatusControl(ToolComponent parent)
|
||||
public StatusControl(MultiToolComponent parent)
|
||||
{
|
||||
_parent = parent;
|
||||
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
|
||||
@@ -14,18 +14,17 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Client.GameObjects.Components.Interactable
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(ToolComponent))]
|
||||
public class WelderComponent : ToolComponent, IItemStatus
|
||||
public class WelderComponent : SharedToolComponent, IItemStatus
|
||||
{
|
||||
public override string Name => "Welder";
|
||||
public override uint? NetID => ContentNetIDs.WELDER;
|
||||
|
||||
private Tool _behavior;
|
||||
private ToolQuality _behavior;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private bool _uiUpdateNeeded;
|
||||
[ViewVariables] public float FuelCapacity { get; private set; }
|
||||
[ViewVariables] public float Fuel { get; private set; }
|
||||
[ViewVariables] public bool Activated { get; private set; }
|
||||
[ViewVariables] public override Tool Behavior => _behavior;
|
||||
[ViewVariables] public override ToolQuality Qualities => _behavior;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
@@ -39,7 +38,7 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
FuelCapacity = weld.FuelCapacity;
|
||||
Fuel = weld.Fuel;
|
||||
Activated = weld.Activated;
|
||||
_behavior = weld.Behavior;
|
||||
_behavior = weld.Quality;
|
||||
_uiUpdateNeeded = true;
|
||||
}
|
||||
|
||||
@@ -70,14 +69,11 @@ namespace Content.Client.GameObjects.Components.Interactable
|
||||
|
||||
_parent._uiUpdateNeeded = false;
|
||||
|
||||
if (_parent.Behavior == Tool.Welder)
|
||||
{
|
||||
var fuelCap = _parent.FuelCapacity;
|
||||
var fuel = _parent.Fuel;
|
||||
var fuelCap = _parent.FuelCapacity;
|
||||
var fuel = _parent.Fuel;
|
||||
|
||||
_label.SetMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color]",
|
||||
fuel < fuelCap / 4f ? "darkorange" : "orange", Math.Round(fuel), fuelCap));
|
||||
}
|
||||
_label.SetMarkup(Loc.GetString("Fuel: [color={0}]{1}/{2}[/color]",
|
||||
fuel < fuelCap / 4f ? "darkorange" : "orange", Math.Round(fuel), fuelCap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user