mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
* fix: thermals and night vision now work * fix: it has to be this way Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: I hate the way they are separated * fix: now cult actions close examine menu (#1046) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: railins and some other things now dont snap to south upon being built (#1029) * fix: who did this translation wtf * fix: assball bat can now wideswing (#1030) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: spend flares are actually spent now (#959) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: made part exchange system a bit less shitty I really have no time or interest in it to rewrite it completely rn Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: fixed cult factories timers being broken Also fixed them being openable by anyone. Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * Apply suggestions from code review Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> Co-authored-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com> --------- Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> Co-authored-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com>
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using Content.Shared._White.RadialSelector;
|
|
using Content.Shared.Hands.EntitySystems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.RadialSelector;
|
|
using Content.Shared.UserInterface;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Shared._White.BloodCult.TimedFactory;
|
|
|
|
public sealed class TimedFactorySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly INetManager _netManager = default!;
|
|
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<TimedFactoryComponent, ActivatableUIOpenAttemptEvent>(OnTryOpenMenu);
|
|
SubscribeLocalEvent<TimedFactoryComponent, RadialSelectorSelectedMessage>(OnPrototypeSelected);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
var factoryQuery = EntityQueryEnumerator<TimedFactoryComponent>();
|
|
while (factoryQuery.MoveNext(out var uid, out var factory))
|
|
{
|
|
if (factory.Active)
|
|
return;
|
|
|
|
factory.CooldownRemain -= frameTime;
|
|
Dirty(uid, factory);
|
|
if (factory.CooldownRemain > 0)
|
|
return;
|
|
|
|
factory.Active = true;
|
|
_appearance.SetData(uid, GenericCultVisuals.State, true);
|
|
}
|
|
}
|
|
|
|
private void OnTryOpenMenu(Entity<TimedFactoryComponent> factory, ref ActivatableUIOpenAttemptEvent args)
|
|
{
|
|
if (!factory.Comp.Active)
|
|
{
|
|
_popup.PopupClient(Loc.GetString("timed-factory-cooldown", ("cooldown", (int) factory.Comp.CooldownRemain)),
|
|
factory,
|
|
args.User);
|
|
args.Cancel();
|
|
return;
|
|
}
|
|
|
|
_ui.SetUiState(factory.Owner, RadialSelectorUiKey.Key, new TrackedRadialSelectorState(factory.Comp.Entries));
|
|
}
|
|
|
|
private void OnPrototypeSelected(Entity<TimedFactoryComponent> factory, ref RadialSelectorSelectedMessage args)
|
|
{
|
|
if (!factory.Comp.Active)
|
|
return;
|
|
|
|
factory.Comp.Active = false;
|
|
factory.Comp.CooldownRemain = factory.Comp.Cooldown;
|
|
_appearance.SetData(factory, GenericCultVisuals.State, false);
|
|
_ui.CloseUi(factory.Owner, RadialSelectorUiKey.Key);
|
|
|
|
if (!_netManager.IsServer)
|
|
return;
|
|
|
|
var product = Spawn(args.SelectedItem, Transform(args.Actor).Coordinates);
|
|
_hands.TryPickupAnyHand(args.Actor, product);
|
|
}
|
|
}
|