mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
# Description Adds the watches, smuggler satchel, and rings from wizden. If I fucked anything up, tell me and I'll do my best to fix it, IF I CAN. I'll probably need some help. Yell at me really loudly if I managed to delete the entire repo or something --- # TODO - [x] Smuggler satchel - [x] Watches - [x] Rings --- https://github.com/user-attachments/assets/7d1e06a7-a049-4d74-9f7e-2b8f04d1e5d1 --- # Changelog 🆑 - add: Ported Smuggler Satchels from Wizden - add: Ported watches (both normal and gold) from Wizden - Ported rings from Wizden --------- Signed-off-by: bruhmogus <104110869+bruhmogus@users.noreply.github.com> Signed-off-by: VMSolidus <evilexecutive@gmail.com> Signed-off-by: Timfa <timfalken@hotmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Timfa <timfalken@hotmail.com> (cherry picked from commit 667013f9f82b3b291641b5501421653d7f79ddbd)
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using System.Linq;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.GameTicking;
|
|
|
|
namespace Content.Shared.Clock;
|
|
|
|
public abstract class SharedClockSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedGameTicker _ticker = default!;
|
|
|
|
/// <inheritdoc/>
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<ClockComponent, ExaminedEvent>(OnExamined);
|
|
}
|
|
|
|
private void OnExamined(Entity<ClockComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
if (!args.IsInDetailsRange)
|
|
return;
|
|
|
|
args.PushMarkup(Loc.GetString("clock-examine", ("time", GetClockTimeText(ent))));
|
|
}
|
|
|
|
public string GetClockTimeText(Entity<ClockComponent> ent)
|
|
{
|
|
var time = GetClockTime(ent);
|
|
switch (ent.Comp.ClockType)
|
|
{
|
|
case ClockType.TwelveHour:
|
|
return time.ToString(@"h\:mm");
|
|
case ClockType.TwentyFourHour:
|
|
return time.ToString(@"HH\:mm");
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
|
|
private TimeSpan GetGlobalTime()
|
|
{
|
|
return (EntityQuery<GlobalTimeManagerComponent>().FirstOrDefault()?.TimeOffset ?? TimeSpan.Zero) + _ticker.RoundDuration();
|
|
}
|
|
|
|
public TimeSpan GetClockTime(Entity<ClockComponent> ent)
|
|
{
|
|
var comp = ent.Comp;
|
|
|
|
if (comp.StuckTime != null)
|
|
return comp.StuckTime.Value;
|
|
|
|
var time = GetGlobalTime();
|
|
|
|
switch (comp.ClockType)
|
|
{
|
|
case ClockType.TwelveHour:
|
|
var adjustedHours = time.Hours % 12;
|
|
if (adjustedHours == 0)
|
|
adjustedHours = 12;
|
|
return new TimeSpan(adjustedHours, time.Minutes, time.Seconds);
|
|
case ClockType.TwentyFourHour:
|
|
return time;
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
}
|