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)
|
if (args.AppearanceData.TryGetValue(TextScreenVisuals.Color, out var color) && color is Color)
|
||||||
component.Color = (Color) color;
|
component.Color = (Color) color;
|
||||||
|
|
||||||
// DefaultText: broadcast updates from comms consoles
|
// DefaultText: fallback text e.g. broadcast updates from comms consoles
|
||||||
// ScreenText: the text accompanying shuttle timers e.g. "ETA"
|
|
||||||
if (args.AppearanceData.TryGetValue(TextScreenVisuals.DefaultText, out var newDefault) && newDefault is string)
|
if (args.AppearanceData.TryGetValue(TextScreenVisuals.DefaultText, out var newDefault) && newDefault is string)
|
||||||
{
|
component.Text = SegmentText((string) newDefault, component);
|
||||||
string?[] defaultText = SegmentText((string) newDefault, component);
|
|
||||||
component.Text = defaultText;
|
// ScreenText: currently rendered text e.g. the "ETA" accompanying shuttle timers
|
||||||
component.TextToDraw = defaultText;
|
|
||||||
ResetText(uid, component);
|
|
||||||
BuildTextLayers(uid, component, args.Sprite);
|
|
||||||
DrawLayers(uid, component.LayerStatesToDraw);
|
|
||||||
}
|
|
||||||
if (args.AppearanceData.TryGetValue(TextScreenVisuals.ScreenText, out var text) && text is string)
|
if (args.AppearanceData.TryGetValue(TextScreenVisuals.ScreenText, out var text) && text is string)
|
||||||
{
|
{
|
||||||
component.TextToDraw = SegmentText((string) text, component);
|
component.TextToDraw = SegmentText((string) text, component);
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ public sealed partial class SignalTimerComponent : Component
|
|||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public string Label = string.Empty;
|
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>
|
/// <summary>
|
||||||
/// The port that gets signaled when the timer triggers.
|
/// The port that gets signaled when the timer triggers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public sealed class SignalTimerSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInit(EntityUid uid, SignalTimerComponent component, ComponentInit args)
|
private void OnInit(EntityUid uid, SignalTimerComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
|
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, component.Label);
|
||||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
||||||
_signalSystem.EnsureSinkPorts(uid, component.Trigger);
|
_signalSystem.EnsureSinkPorts(uid, component.Trigger);
|
||||||
}
|
}
|
||||||
@@ -66,11 +67,6 @@ public sealed class SignalTimerSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
RemComp<ActiveSignalTimerComponent>(uid);
|
RemComp<ActiveSignalTimerComponent>(uid);
|
||||||
|
|
||||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
|
||||||
{
|
|
||||||
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, signalTimer.Label, appearance);
|
|
||||||
}
|
|
||||||
|
|
||||||
_audio.PlayPvs(signalTimer.DoneSound, uid);
|
_audio.PlayPvs(signalTimer.DoneSound, uid);
|
||||||
_signalSystem.InvokePort(uid, signalTimer.TriggerPort);
|
_signalSystem.InvokePort(uid, signalTimer.TriggerPort);
|
||||||
|
|
||||||
@@ -139,10 +135,15 @@ public sealed class SignalTimerSystem : EntitySystem
|
|||||||
if (!IsMessageValid(uid, args))
|
if (!IsMessageValid(uid, args))
|
||||||
return;
|
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))
|
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);
|
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -166,7 +167,15 @@ public sealed class SignalTimerSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (!IsMessageValid(uid, args))
|
if (!IsMessageValid(uid, args))
|
||||||
return;
|
return;
|
||||||
OnStartTimer(uid, component);
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSignalReceived(EntityUid uid, SignalTimerComponent component, ref SignalReceivedEvent args)
|
private void OnSignalReceived(EntityUid uid, SignalTimerComponent component, ref SignalReceivedEvent args)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public sealed class ScreenSystem : EntitySystem
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, text);
|
_appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, text);
|
||||||
|
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user