Thrusters (shuttle go nyoom) (#5352)

This commit is contained in:
metalgearsloth
2021-11-21 17:09:49 +11:00
committed by GitHub
parent c21a9e32b1
commit bdead40a80
37 changed files with 1100 additions and 140 deletions

View File

@@ -10,7 +10,9 @@ using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BaseButton;
using static Robust.Client.UserInterface.Controls.BoxContainer;
@@ -146,6 +148,15 @@ namespace Content.Client.Cargo.UI
foreach (var order in Owner.Orders.Orders)
{
var productName = Owner.Market.GetProduct(order.ProductId)?.Name;
if (productName == null)
{
DebugTools.Assert(false);
Logger.ErrorS("cargo", $"Unable to find product name for {order.ProductId}");
continue;
}
var row = new CargoOrderRow
{
Order = order,
@@ -154,7 +165,7 @@ namespace Content.Client.Cargo.UI
{
Text = Loc.GetString(
"cargo-console-menu-populate-orders-cargo-order-row-product-name-text",
("productName", Owner.Market.GetProduct(order.ProductId)?.Name!),
("productName", productName),
("orderAmount", order.Amount),
("orderRequester", order.Requester))
},

View File

@@ -101,6 +101,7 @@ namespace Content.Client.Entry
"Lock",
"PresetIdCard",
"SolarControlConsole",
"Thruster",
"FlashOnTrigger",
"SoundOnTrigger",
"TriggerOnCollide",

View File

@@ -1,4 +1,5 @@
using Content.Shared.Shuttles;
using Content.Shared.Shuttles.Components;
using Robust.Shared.GameObjects;
namespace Content.Client.Shuttles

View File

@@ -0,0 +1,67 @@
using Content.Shared.Shuttles.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Shuttles
{
public sealed class ThrusterVisualizer : AppearanceVisualizer
{
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (!component.Owner.TryGetComponent(out SpriteComponent? spriteComponent)) return;
component.TryGetData(ThrusterVisualState.State, out bool state);
switch (state)
{
case true:
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustOn, true);
if (component.TryGetData(ThrusterVisualState.Thrusting, out bool thrusting) && thrusting)
{
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.Thrusting, out _))
{
spriteComponent.LayerSetVisible(ThrusterVisualLayers.Thrusting, true);
}
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.ThrustingUnshaded, out _))
{
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustingUnshaded, true);
}
}
else
{
DisableThrusting(component, spriteComponent);
}
break;
case false:
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustOn, false);
DisableThrusting(component, spriteComponent);
break;
}
}
private void DisableThrusting(AppearanceComponent component, SpriteComponent spriteComponent)
{
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.Thrusting, out _))
{
spriteComponent.LayerSetVisible(ThrusterVisualLayers.Thrusting, false);
}
if (spriteComponent.LayerMapTryGet(ThrusterVisualLayers.ThrustingUnshaded, out _))
{
spriteComponent.LayerSetVisible(ThrusterVisualLayers.ThrustingUnshaded, false);
}
}
}
public enum ThrusterVisualLayers : byte
{
Base,
ThrustOn,
Thrusting,
ThrustingUnshaded,
}
}