Revert "Merge pull request #252 from frosty-dev/CRAB17"
This reverts commitf1f191270d, reversing changes made tobc2857f546.
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.StationEvents.Events;
|
||||
using Content.Server.GameTicking.Components;
|
||||
using Content.Shared._Amour.ProtocolCRAB17;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared._White.Economy;
|
||||
using Content.Server._White.Economy;
|
||||
|
||||
namespace Content.Server._Amour.ProtocolCRAB17;
|
||||
|
||||
public sealed class ProtocolCRAB17Rule : StationEventSystem<ProtocolCRAB17RuleComponent>
|
||||
{
|
||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly BankCardSystem _bankCardSystem = default!;
|
||||
|
||||
public TimeSpan? LastTimeExecuted;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
protected override void Added(EntityUid uid, ProtocolCRAB17RuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
||||
{
|
||||
base.Added(uid, component, gameRule, args);
|
||||
|
||||
if (TryGetRandomStation(out var stationUid))
|
||||
{
|
||||
component.TargetStation = stationUid;
|
||||
}
|
||||
|
||||
var query = AllEntityQuery<ProtocolCRAB17Component>();
|
||||
while (query.MoveNext(out _, out var comp))
|
||||
{
|
||||
if (comp.BankAccountId == null)
|
||||
continue;
|
||||
|
||||
component.Callers.Add((int) comp.BankAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Started(EntityUid uid, ProtocolCRAB17RuleComponent component, GameRuleComponent gameRule,
|
||||
GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
|
||||
if (component.TargetStation == null)
|
||||
{
|
||||
ForceEndSelf(uid, gameRule);
|
||||
return;
|
||||
}
|
||||
|
||||
_chatSystem.DispatchStationAnnouncement((EntityUid) component.TargetStation, Loc.GetString("protocol-CRAB17-stage-1"),
|
||||
colorOverride: Color.OrangeRed, sender: "Центральное Командование", announcementSound: ProtocolCRAB17RuleComponent.Announcement);
|
||||
}
|
||||
|
||||
protected override void Ended(EntityUid uid, ProtocolCRAB17RuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
||||
{
|
||||
base.Ended(uid, component, gameRule, args);
|
||||
|
||||
var allMoneyStolen = 0;
|
||||
|
||||
var query = AllEntityQuery<BankCardComponent>();
|
||||
while (query.MoveNext(out _, out var bankCardComponent))
|
||||
{
|
||||
if (bankCardComponent.AccountId == null)
|
||||
continue;
|
||||
|
||||
if (component.Callers.Contains((int) bankCardComponent.AccountId))
|
||||
continue;
|
||||
|
||||
var money = _bankCardSystem.GetBalance((int) bankCardComponent.AccountId);
|
||||
allMoneyStolen += money;
|
||||
|
||||
_bankCardSystem.TryChangeBalance((int) bankCardComponent.AccountId, -money);
|
||||
}
|
||||
|
||||
var callersCount = component.Callers.Count;
|
||||
|
||||
foreach (var caller in component.Callers)
|
||||
{
|
||||
_bankCardSystem.TryChangeBalance(caller, (int) Math.Floor((double) (allMoneyStolen / callersCount)));
|
||||
}
|
||||
|
||||
if (component.TargetStation != null)
|
||||
_chatSystem.DispatchStationAnnouncement((EntityUid) component.TargetStation, Loc.GetString("protocol-CRAB17-stage-2", ("amount", allMoneyStolen)),
|
||||
colorOverride: Color.OrangeRed, sender: "Центральное Командование");
|
||||
|
||||
var ertsys = _entities.System<ProtocolCRAB17Rule>();
|
||||
ertsys.LastTimeExecuted = _timing.CurTime;
|
||||
component.Callers.Clear();
|
||||
}
|
||||
|
||||
public bool CanStartEvent()
|
||||
{
|
||||
var ertsys = _entities.System<ProtocolCRAB17Rule>();
|
||||
|
||||
if (ertsys.LastTimeExecuted == null)
|
||||
return true;
|
||||
|
||||
else if (ertsys.LastTimeExecuted < _timing.CurTime - ProtocolCRAB17RuleComponent.TimeBetweenEvents)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server._Amour.ProtocolCRAB17;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class ProtocolCRAB17RuleComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimal time between events.
|
||||
/// </summary>
|
||||
public static TimeSpan TimeBetweenEvents = TimeSpan.FromMinutes(20);
|
||||
|
||||
public static SoundSpecifier Announcement = new SoundPathSpecifier("/Audio/_Amour/ProtocolCRAB17/Bogdanoff_is_calling.ogg");
|
||||
|
||||
[ViewVariables]
|
||||
public EntityUid? TargetStation;
|
||||
[ViewVariables]
|
||||
public HashSet<int> Callers = new();
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using Content.Shared._Amour.ProtocolCRAB17;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Popups;
|
||||
|
||||
namespace Content.Server._Amour.ProtocolCRAB17;
|
||||
|
||||
public sealed class ProtocolCRAB17System : SharedProtocolCRAB17System
|
||||
{
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly ProtocolCRAB17Rule _protocolCRAB17Rule = default!;
|
||||
|
||||
public override void OnDoAfter(Entity<ProtocolCRAB17Component> ent, ref ProtocolCRAB17DoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled || args.Handled)
|
||||
return;
|
||||
|
||||
if (_gameTicker.IsGameRuleActive("ProtocolCRAB17Event"))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("protocol-CRAB17-event-running"), ent, args.User);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_protocolCRAB17Rule.CanStartEvent())
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("protocol-CRAB17-timeout"), ent, args.User);
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("protocol-CRAB17-activated"), ent, args.User);
|
||||
_gameTicker.AddGameRule("ProtocolCRAB17Event");
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user