cancelable brig timers (#26557)
brig timers now cancelable. also some screensystem yakshave
This commit is contained in:
@@ -112,17 +112,11 @@ public sealed class TextScreenSystem : VisualizerSystem<TextScreenVisualsCompone
|
||||
if (args.AppearanceData.TryGetValue(TextScreenVisuals.Color, out var color) && color is Color)
|
||||
component.Color = (Color) color;
|
||||
|
||||
// DefaultText: broadcast updates from comms consoles
|
||||
// ScreenText: the text accompanying shuttle timers e.g. "ETA"
|
||||
// DefaultText: fallback text e.g. broadcast updates from comms consoles
|
||||
if (args.AppearanceData.TryGetValue(TextScreenVisuals.DefaultText, out var newDefault) && newDefault is string)
|
||||
{
|
||||
string?[] defaultText = SegmentText((string) newDefault, component);
|
||||
component.Text = defaultText;
|
||||
component.TextToDraw = defaultText;
|
||||
ResetText(uid, component);
|
||||
BuildTextLayers(uid, component, args.Sprite);
|
||||
DrawLayers(uid, component.LayerStatesToDraw);
|
||||
}
|
||||
component.Text = SegmentText((string) newDefault, component);
|
||||
|
||||
// ScreenText: currently rendered text e.g. the "ETA" accompanying shuttle timers
|
||||
if (args.AppearanceData.TryGetValue(TextScreenVisuals.ScreenText, out var text) && text is string)
|
||||
{
|
||||
component.TextToDraw = SegmentText((string) text, component);
|
||||
|
||||
@@ -23,6 +23,12 @@ public sealed partial class SignalTimerComponent : Component
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public string Label = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Default max width of a label (how many letters can this render?)
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxLength = 5;
|
||||
|
||||
/// <summary>
|
||||
/// The port that gets signaled when the timer triggers.
|
||||
/// </summary>
|
||||
|
||||
@@ -39,6 +39,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
|
||||
private void OnInit(EntityUid uid, SignalTimerComponent component, ComponentInit args)
|
||||
{
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, component.Label);
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
||||
_signalSystem.EnsureSinkPorts(uid, component.Trigger);
|
||||
}
|
||||
@@ -66,11 +67,6 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
{
|
||||
RemComp<ActiveSignalTimerComponent>(uid);
|
||||
|
||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
{
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, signalTimer.Label, appearance);
|
||||
}
|
||||
|
||||
_audio.PlayPvs(signalTimer.DoneSound, uid);
|
||||
_signalSystem.InvokePort(uid, signalTimer.TriggerPort);
|
||||
|
||||
@@ -139,11 +135,16 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
if (!IsMessageValid(uid, args))
|
||||
return;
|
||||
|
||||
component.Label = args.Text[..Math.Min(5, args.Text.Length)];
|
||||
component.Label = args.Text[..Math.Min(component.MaxLength, args.Text.Length)];
|
||||
|
||||
if (!HasComp<ActiveSignalTimerComponent>(uid))
|
||||
{
|
||||
// could maybe move the defaulttext update out of this block,
|
||||
// if you delved deep into appearance update batching
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, component.Label);
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by <see cref="SignalTimerDelayChangedMessage"/> to change the <see cref="SignalTimerComponent"/>
|
||||
@@ -166,6 +167,14 @@ public sealed class SignalTimerSystem : EntitySystem
|
||||
{
|
||||
if (!IsMessageValid(uid, args))
|
||||
return;
|
||||
|
||||
// feedback received: pressing the timer button while a timer is running should cancel the timer.
|
||||
if (HasComp<ActiveSignalTimerComponent>(uid))
|
||||
{
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.TargetTime, _gameTiming.CurTime);
|
||||
Trigger(uid, component);
|
||||
}
|
||||
else
|
||||
OnStartTimer(uid, component);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ public sealed class ScreenSystem : EntitySystem
|
||||
)
|
||||
{
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, text);
|
||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user