Merge remote-tracking branch 'WD-core/master' into upstream-core
This commit is contained in:
@@ -8,9 +8,11 @@ using Content.Shared.Database;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared._White.AuthPanel;
|
||||
using Content.Shared._White.GhostRecruitment;
|
||||
using Content.Shared.Ghost;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.AuthPanel;
|
||||
|
||||
@@ -21,25 +23,42 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
[Dependency] private readonly AccessReaderSystem _access = default!;
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ERTRecruitmentRule _ert = default!;
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
|
||||
public Dictionary<AuthPanelAction, HashSet<EntityUid>> Counter = new();
|
||||
public Dictionary<AuthPanelAction, HashSet<int>> CardIndexes = new();
|
||||
public string Reason = "";
|
||||
/// <summary>
|
||||
/// Minimal Amount of votes needed for action.
|
||||
/// </summary>
|
||||
public static int MinCount = 3;
|
||||
|
||||
public static int MaxCount = 2;
|
||||
/// <summary>
|
||||
/// Amount of minutes before action can be called. Counting from round start.
|
||||
/// </summary>
|
||||
public static int EarliestStart = 45;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of seconds before action can be called. Counting from previous vote.
|
||||
/// </summary>
|
||||
public static int DelayDuration = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of minutes before action can be called. Counting from previous call for vote.
|
||||
/// </summary>
|
||||
public static int TimeoutDuration = 10;
|
||||
private TimeSpan? _delay;
|
||||
|
||||
private TimeSpan? _timeout;
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<AuthPanelComponent,AuthPanelButtonPressedMessage>(OnButtonPressed);
|
||||
SubscribeLocalEvent<AuthPanelComponent,AuthPanelPerformActionEvent>(OnPerformAction);
|
||||
SubscribeLocalEvent<RecruitedComponent,ERTRecruitedReasonEvent>(OnReason);
|
||||
SubscribeLocalEvent<AuthPanelComponent, AuthPanelButtonPressedMessage>(OnButtonPressed);
|
||||
SubscribeLocalEvent<AuthPanelComponent, AuthPanelPerformActionEvent>(OnPerformAction);
|
||||
SubscribeLocalEvent<RecruitedComponent, ERTRecruitedReasonEvent>(OnReason);
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRestart);
|
||||
}
|
||||
@@ -55,13 +74,54 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
CardIndexes.Clear();
|
||||
|
||||
_delay = null;
|
||||
_timeout = null;
|
||||
}
|
||||
|
||||
private void ClearPanel()
|
||||
{
|
||||
Counter.Clear();
|
||||
CardIndexes.Clear();
|
||||
|
||||
_delay = null;
|
||||
_timeout = null;
|
||||
|
||||
var action = new AuthPanelConfirmationAction(AuthPanelAction.ERTRecruit, 0, MinCount, "");
|
||||
var query = EntityQueryEnumerator<AuthPanelComponent>();
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
if (!_ui.HasUi(uid, AuthPanelUiKey.Key))
|
||||
continue;
|
||||
|
||||
var state = new AuthPanelConfirmationActionState(action);
|
||||
_ui.SetUiState(uid, AuthPanelUiKey.Key, state);
|
||||
_appearance.SetData(uid, AuthPanelVisualLayers.Confirm, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPerformAction(EntityUid uid, AuthPanelComponent component, AuthPanelPerformActionEvent args)
|
||||
{
|
||||
if (args.Action is AuthPanelAction.ERTRecruit)
|
||||
{
|
||||
if (_random.Next(10) < 2)
|
||||
|
||||
if (_ticker.RoundDuration() < TimeSpan.FromMinutes(EarliestStart))
|
||||
{
|
||||
var station = _station.GetStationInMap(Transform(uid).MapID);
|
||||
|
||||
if (station != null)
|
||||
_ert.DeclineERT(station.Value);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough time passed");
|
||||
return;
|
||||
}
|
||||
|
||||
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
|
||||
var ghostList = new List<EntityUid>();
|
||||
while (query.MoveNext(out var ghost, out _, out _))
|
||||
{
|
||||
ghostList.Add(ghost);
|
||||
}
|
||||
|
||||
var playerCount = _playerManager.PlayerCount;
|
||||
if (playerCount - ghostList.Count > playerCount / 2 && ghostList.Count > MinCount)
|
||||
{
|
||||
_gameTicker.AddGameRule(ERTRecruitmentRuleComponent.EventName);
|
||||
}
|
||||
@@ -71,6 +131,7 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
|
||||
if (station != null)
|
||||
_ert.DeclineERT(station.Value);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough ghosts");
|
||||
}
|
||||
|
||||
foreach (var entities in Counter.Values)
|
||||
@@ -91,7 +152,7 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
if (!access.Contains("Command"))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("auth-panel-no-access"),
|
||||
args.Actor,args.Actor);
|
||||
args.Actor, args.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,22 +173,22 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
if (!Counter.TryGetValue(args.Button, out var hashSet))
|
||||
{
|
||||
hashSet = new HashSet<EntityUid>();
|
||||
Counter.Add(args.Button,hashSet);
|
||||
Counter.Add(args.Button, hashSet);
|
||||
}
|
||||
|
||||
if(hashSet.Count == MaxCount)
|
||||
if (hashSet.Count >= MinCount)
|
||||
return;
|
||||
|
||||
if (!CardIndexes.TryGetValue(args.Button, out var cardSet))
|
||||
{
|
||||
cardSet = new HashSet<int>();
|
||||
CardIndexes.Add(args.Button,cardSet);
|
||||
CardIndexes.Add(args.Button, cardSet);
|
||||
}
|
||||
|
||||
if (cardSet.Contains(access.Count))
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("auth-panel-used-ID"),
|
||||
args.Actor,args.Actor);
|
||||
args.Actor, args.Actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,47 +200,50 @@ public sealed class AuthPanelSystem : EntitySystem
|
||||
}
|
||||
|
||||
cardSet.Add(access.Count);
|
||||
_delay = _timing.CurTime + TimeSpan.FromSeconds(5);
|
||||
_delay = _timing.CurTime + TimeSpan.FromSeconds(DelayDuration);
|
||||
|
||||
Reason = args.Reason;
|
||||
UpdateUserInterface(args.Button);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"{ToPrettyString(args.Actor):player} vote for {args.Button}. Reason: {Reason}");
|
||||
|
||||
if (hashSet.Count == MaxCount)
|
||||
if (hashSet.Count >= MinCount)
|
||||
{
|
||||
var ev = new AuthPanelPerformActionEvent(args.Button);
|
||||
RaiseLocalEvent(uid,ev);
|
||||
RaiseLocalEvent(uid, ev);
|
||||
_timeout = _timing.CurTime + TimeSpan.FromMinutes(TimeoutDuration);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUserInterface(AuthPanelAction rawaction)
|
||||
{
|
||||
if(!Counter.TryGetValue(rawaction,out var hashSet))
|
||||
if (!Counter.TryGetValue(rawaction, out var hashSet))
|
||||
return;
|
||||
|
||||
var action = new AuthPanelConfirmationAction(rawaction, hashSet.Count, MaxCount,Reason);
|
||||
var action = new AuthPanelConfirmationAction(rawaction, hashSet.Count, MinCount, Reason);
|
||||
|
||||
var query = EntityQueryEnumerator<AuthPanelComponent>();
|
||||
while (query.MoveNext(out var uid,out _))
|
||||
while (query.MoveNext(out var uid, out _))
|
||||
{
|
||||
if (!_ui.HasUi(uid, AuthPanelUiKey.Key))
|
||||
return;
|
||||
continue;
|
||||
|
||||
var state = new AuthPanelConfirmationActionState(action);
|
||||
|
||||
_ui.SetUiState(uid, AuthPanelUiKey.Key, state);
|
||||
_appearance.SetData(uid,AuthPanelVisualLayers.Confirm,true);
|
||||
_appearance.SetData(uid, AuthPanelVisualLayers.Confirm, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
if (_delay == null)
|
||||
return;
|
||||
|
||||
if (_timing.CurTime >= _delay)
|
||||
if (_delay != null && _timing.CurTime >= _delay)
|
||||
{
|
||||
_delay = null;
|
||||
}
|
||||
|
||||
if (_timeout != null && _timing.CurTime >= _timeout)
|
||||
{
|
||||
ClearPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.StationEvents.Events;
|
||||
using Content.Server._White.GhostRecruitment;
|
||||
using Content.Server.GameTicking.Components;
|
||||
using Content.Shared._White;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared._White.GhostRecruitment;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -26,6 +26,8 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
[Dependency] private readonly MapLoaderSystem _map = default!;
|
||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
private ISawmill _logger = default!;
|
||||
|
||||
@@ -36,8 +38,8 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
base.Initialize();
|
||||
|
||||
_logger = Logger.GetSawmill("ERTRecruit");
|
||||
//SubscribeLocalEvent<RoundStartAttemptEvent>(OnStartAttempt);
|
||||
SubscribeLocalEvent<RecruitedComponent,GhostRecruitmentSuccessEvent>(OnRecruitmentSuccess);
|
||||
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
|
||||
SubscribeLocalEvent<RecruitedComponent, GhostRecruitmentSuccessEvent>(OnRecruitmentSuccess);
|
||||
}
|
||||
|
||||
protected override void Added(EntityUid uid, ERTRecruitmentRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
||||
@@ -51,9 +53,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
|
||||
if (IsDisabled)
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
|
||||
component.IsBlocked = true;
|
||||
return;
|
||||
}
|
||||
@@ -71,24 +70,22 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
GameRuleStartedEvent args)
|
||||
{
|
||||
base.Started(uid, component, gameRule, args);
|
||||
_logger.Debug("Event is started");
|
||||
|
||||
if (component.TargetStation == null || component.IsBlocked)
|
||||
if (component.TargetStation == null || component.IsBlocked || IsDisabled)
|
||||
{
|
||||
ForceEndSelf(uid,gameRule);
|
||||
_logger.Debug("oopsie doopsie we make a poopie poopie on starting event!");
|
||||
ForceEndSelf(uid, gameRule);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Event disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_recruitment.GetEventSpawners(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer)
|
||||
if (_recruitment.GetEventSpawners(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayers)
|
||||
{
|
||||
_logger.Debug("Not enough spawners!");
|
||||
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough spawners");
|
||||
return;
|
||||
}
|
||||
|
||||
_chatSystem.DispatchStationAnnouncement(component.TargetStation.Value,Loc.GetString("ert-wait-message"),colorOverride: Color.Gold);
|
||||
_chatSystem.DispatchStationAnnouncement(component.TargetStation.Value, Loc.GetString("ert-wait-message"), colorOverride: Color.Gold);
|
||||
|
||||
/*
|
||||
if (TryComp<ShuttleComponent>(component.Shuttle, out var shuttle) && component.Outpost != null)
|
||||
@@ -103,50 +100,67 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
protected override void Ended(EntityUid uid, ERTRecruitmentRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
||||
{
|
||||
base.Ended(uid, component, gameRule, args);
|
||||
var ertsys = _entities.System<ERTRecruitmentRule>();
|
||||
|
||||
if (component.IsBlocked || _recruitment.GetAllRecruited(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer ||
|
||||
!_recruitment.EndRecruitment(ERTRecruitmentRuleComponent.EventName))
|
||||
var check1 = component.IsBlocked || ertsys.IsDisabled;
|
||||
|
||||
var check2 = _recruitment.GetAllRecruited(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayers;
|
||||
|
||||
if (check1)
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"{"ERT Declined - Event disabled"}");
|
||||
_recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName);
|
||||
return;
|
||||
}
|
||||
if (check2)
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
_adminLogger.Add(LogType.EventStarted, LogImpact.High, $"ERT Declined - Not enough ghosts willing to play ERT");
|
||||
_recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
AcceptERT(component.TargetStation.Value);
|
||||
|
||||
_recruitment.EndRecruitment(ERTRecruitmentRuleComponent.EventName);
|
||||
ertsys.IsDisabled = true;
|
||||
}
|
||||
|
||||
if (component.TargetStation != null)
|
||||
AcceptERT(component.TargetStation.Value);
|
||||
}
|
||||
|
||||
private void OnRecruitmentSuccess(EntityUid uid, RecruitedComponent component, GhostRecruitmentSuccessEvent args)
|
||||
{
|
||||
var ev = new ERTRecruitedReasonEvent();
|
||||
RaiseLocalEvent(uid,ev);
|
||||
RaiseLocalEvent(uid, ev);
|
||||
|
||||
if (args.PlayerSession != null)
|
||||
{
|
||||
|
||||
_chat.DispatchServerMessage(args.PlayerSession, Loc.GetString("ert-description"));
|
||||
_chat.DispatchServerMessage(args.PlayerSession, Loc.GetString("ert-reason", ("reason", ev.Reason)));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStartAttempt(RoundStartAttemptEvent ev)
|
||||
private void OnRoundStart(RoundStartingEvent ev)
|
||||
{
|
||||
if(_cfgManager.GetCVar(WhiteCVars.LoadErtMap))
|
||||
SpawnMap();
|
||||
//if (_cfgManager.GetCVar(WhiteCVars.LoadErtMap))
|
||||
SpawnMap();
|
||||
}
|
||||
|
||||
|
||||
public void AcceptERT(EntityUid targetStation)
|
||||
{
|
||||
_chatSystem.DispatchStationAnnouncement(targetStation,Loc.GetString("ert-accept-message"),
|
||||
colorOverride: Color.Gold,announcementSound:ERTRecruitmentRuleComponent.ERTYes);
|
||||
_chatSystem.DispatchStationAnnouncement(targetStation, Loc.GetString("ert-accept-message"),
|
||||
colorOverride: Color.Gold, announcementSound: ERTRecruitmentRuleComponent.ERTYes);
|
||||
}
|
||||
|
||||
public void DeclineERT(EntityUid targetStation)
|
||||
{
|
||||
_chatSystem.DispatchStationAnnouncement(targetStation,Loc.GetString("ert-deny-message"),
|
||||
colorOverride: Color.Gold,announcementSound:ERTRecruitmentRuleComponent.ERTNo);
|
||||
_chatSystem.DispatchStationAnnouncement(targetStation, Loc.GetString("ert-deny-message"),
|
||||
colorOverride: Color.Gold, announcementSound: ERTRecruitmentRuleComponent.ERTNo);
|
||||
}
|
||||
|
||||
private bool SpawnMap()
|
||||
@@ -161,7 +175,7 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
|
||||
if (!_map.TryLoad(mapId, ERTMapComponent.OutpostMap.ToString(), out var outpostGrids, options) || outpostGrids.Count == 0)
|
||||
{
|
||||
_logger.Error( $"Error loading map {ERTMapComponent.OutpostMap}!");
|
||||
_logger.Error($"Error loading map {ERTMapComponent.OutpostMap}!");
|
||||
return false;
|
||||
}
|
||||
_logger.Debug($"Loaded map {ERTMapComponent.OutpostMap} on {mapId}!");
|
||||
@@ -192,7 +206,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
var ertMap = EnsureComp<ERTMapComponent>(outpost);
|
||||
ertMap.MapId = mapId;
|
||||
//ERTMap.Shuttle = shuttleId;
|
||||
|
||||
@@ -11,7 +11,10 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
|
||||
[ViewVariables]
|
||||
public MapId? MapId = null;
|
||||
|
||||
[DataField("minPlayer")] public int MinPlayer = 4;
|
||||
/// <summary>
|
||||
/// Minimal amount of players, who will become ERT recruits.
|
||||
/// </summary>
|
||||
[DataField] public int MinPlayers = 3;
|
||||
|
||||
public static SoundSpecifier ERTYes = new SoundPathSpecifier("/Audio/Announcements/ert_yes.ogg");
|
||||
public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg");
|
||||
@@ -21,8 +24,8 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
|
||||
|
||||
[ViewVariables]
|
||||
public EntityUid? Outpost;
|
||||
//[ViewVariables]
|
||||
// public EntityUid? Shuttle;
|
||||
//[ViewVariables]
|
||||
// public EntityUid? Shuttle;
|
||||
[ViewVariables]
|
||||
public EntityUid? TargetStation;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
/// <param name="recruitmentName">name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
|
||||
public void StartRecruitment(string recruitmentName)
|
||||
{
|
||||
var query = EntityQueryEnumerator<GhostComponent,ActorComponent>();
|
||||
while (query.MoveNext(out var uid,out _,out var actorComponent))
|
||||
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
|
||||
while (query.MoveNext(out var uid, out _, out var actorComponent))
|
||||
{
|
||||
OpenEui(uid,recruitmentName,actorComponent);
|
||||
OpenEui(uid, recruitmentName, actorComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="recruitmentName">name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
|
||||
public void Recruit(EntityUid uid,string recruitmentName)
|
||||
public void Recruit(EntityUid uid, string recruitmentName)
|
||||
{
|
||||
EnsureComp<GhostRecruitedComponent>(uid).RecruitmentName = recruitmentName;
|
||||
}
|
||||
@@ -63,31 +63,30 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
|
||||
var count = 0;
|
||||
|
||||
var maxCount = Math.Max(3, _playerManager.PlayerCount / 6);
|
||||
|
||||
var maxCount = Math.Max(3, _playerManager.PlayerCount / 8);
|
||||
var query = EntityQueryEnumerator<GhostRecruitedComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid,out var ghostRecruitedComponent))
|
||||
while (query.MoveNext(out var uid, out var ghostRecruitedComponent))
|
||||
{
|
||||
if(ghostRecruitedComponent.RecruitmentName != recruitmentName)
|
||||
if (ghostRecruitedComponent.RecruitmentName != recruitmentName)
|
||||
continue;
|
||||
|
||||
if (!TryComp<ActorComponent>(uid, out var actorComponent))
|
||||
continue;
|
||||
|
||||
// if there are too many recruited, then just skip
|
||||
if(count >= spawners.Count || count >= maxCount)
|
||||
if (count >= spawners.Count || count >= maxCount)
|
||||
continue;
|
||||
|
||||
var (spawnerUid, spawnerComponent) = spawners[count];
|
||||
|
||||
TransferMind(uid,spawnerUid,spawnerComponent);
|
||||
TransferMind(uid, spawnerUid, spawnerComponent);
|
||||
count++;
|
||||
|
||||
EnsureComp<RecruitedComponent>(uid).RecruitmentName = recruitmentName;
|
||||
|
||||
var ghostEvent = new GhostRecruitmentSuccessEvent(recruitmentName,actorComponent.PlayerSession);
|
||||
RaiseLocalEvent(uid,ghostEvent);
|
||||
var ghostEvent = new GhostRecruitmentSuccessEvent(recruitmentName, actorComponent.PlayerSession);
|
||||
RaiseLocalEvent(uid, ghostEvent);
|
||||
}
|
||||
|
||||
var ghostsEvent = new GhostsRecruitmentSuccessEvent(recruitmentName);
|
||||
@@ -112,14 +111,14 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void TransferMind(EntityUid from,EntityUid spawnerUid,GhostRecruitmentSpawnPointComponent? component = null)
|
||||
private void TransferMind(EntityUid from, EntityUid spawnerUid, GhostRecruitmentSpawnPointComponent? component = null)
|
||||
{
|
||||
if (!Resolve(spawnerUid, ref component) || !TryComp<ActorComponent>(from,out var actorComponent))
|
||||
if (!Resolve(spawnerUid, ref component) || !TryComp<ActorComponent>(from, out var actorComponent))
|
||||
return;
|
||||
|
||||
var entityUid = Spawn(spawnerUid, component);
|
||||
|
||||
if(!entityUid.HasValue)
|
||||
if (!entityUid.HasValue)
|
||||
return;
|
||||
|
||||
var mind = actorComponent.PlayerSession.GetMind();
|
||||
@@ -131,7 +130,7 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
_mind.UnVisit(mind.Value);
|
||||
}
|
||||
|
||||
private EntityUid? Spawn(EntityUid spawnerUid,GhostRecruitmentSpawnPointComponent? component = null)
|
||||
private EntityUid? Spawn(EntityUid spawnerUid, GhostRecruitmentSpawnPointComponent? component = null)
|
||||
{
|
||||
if (!Resolve(spawnerUid, ref component))
|
||||
return null;
|
||||
@@ -166,27 +165,27 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenEui(EntityUid uid,string recruitmentName,ActorComponent? actorComponent = null)
|
||||
public void OpenEui(EntityUid uid, string recruitmentName, ActorComponent? actorComponent = null)
|
||||
{
|
||||
if(!Resolve(uid,ref actorComponent))
|
||||
if (!Resolve(uid, ref actorComponent))
|
||||
return;
|
||||
var eui = new GhostRecruitmentEuiAccept(uid, recruitmentName, this);
|
||||
|
||||
Logger.Debug("Added EUI to "+ uid);
|
||||
if(_openUis.TryAdd(actorComponent.PlayerSession,eui))
|
||||
_eui.OpenEui(eui,actorComponent.PlayerSession);
|
||||
Logger.Debug("Added EUI to " + uid);
|
||||
if (_openUis.TryAdd(actorComponent.PlayerSession, eui))
|
||||
_eui.OpenEui(eui, actorComponent.PlayerSession);
|
||||
}
|
||||
|
||||
public void ClearEui(string recruitmentName)
|
||||
{
|
||||
foreach (var (session,eui) in _openUis)
|
||||
foreach (var (session, eui) in _openUis)
|
||||
{
|
||||
if (session.AttachedEntity != null)
|
||||
CloseEui(session.AttachedEntity.Value, recruitmentName);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseEui(EntityUid uid,string recruitmentName,ActorComponent? actorComponent = null)
|
||||
public void CloseEui(EntityUid uid, string recruitmentName, ActorComponent? actorComponent = null)
|
||||
{
|
||||
if (!Resolve(uid, ref actorComponent))
|
||||
return;
|
||||
@@ -197,7 +196,7 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
||||
if (!_openUis.ContainsKey(session))
|
||||
return;
|
||||
|
||||
Logger.Debug("Removed EUI from "+ uid);
|
||||
Logger.Debug("Removed EUI from " + uid);
|
||||
_openUis.Remove(session, out var eui);
|
||||
|
||||
eui?.Close();
|
||||
|
||||
Reference in New Issue
Block a user