Факс синдиката
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.StationEvents.Events;
|
||||
using Content.Server._White.GhostRecruitment;
|
||||
@@ -26,6 +27,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 GameTicker _ticker = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
private ISawmill _logger = default!;
|
||||
|
||||
@@ -36,8 +39,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 +54,6 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
|
||||
if (IsDisabled)
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
|
||||
component.IsBlocked = true;
|
||||
return;
|
||||
}
|
||||
@@ -73,9 +73,9 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
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);
|
||||
ForceEndSelf(uid, gameRule);
|
||||
_logger.Debug("oopsie doopsie we make a poopie poopie on starting event!");
|
||||
return;
|
||||
}
|
||||
@@ -83,12 +83,18 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
if (_recruitment.GetEventSpawners(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer)
|
||||
{
|
||||
_logger.Debug("Not enough spawners!");
|
||||
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
_chatSystem.DispatchStationAnnouncement(component.TargetStation.Value,Loc.GetString("ert-wait-message"),colorOverride: Color.Gold);
|
||||
if (_ticker.RoundDuration() < TimeSpan.FromMinutes(component.EarliestStart))
|
||||
{
|
||||
_logger.Debug("Not enough time passed!");
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
_chatSystem.DispatchStationAnnouncement(component.TargetStation.Value, Loc.GetString("ert-wait-message"), colorOverride: Color.Gold);
|
||||
|
||||
/*
|
||||
if (TryComp<ShuttleComponent>(component.Shuttle, out var shuttle) && component.Outpost != null)
|
||||
@@ -104,49 +110,57 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
|
||||
{
|
||||
base.Ended(uid, component, gameRule, args);
|
||||
|
||||
if (component.IsBlocked || _recruitment.GetAllRecruited(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer ||
|
||||
!_recruitment.EndRecruitment(ERTRecruitmentRuleComponent.EventName))
|
||||
var check1 = component.IsBlocked;
|
||||
|
||||
var check2 = _recruitment.GetAllRecruited(ERTRecruitmentRuleComponent.EventName).Count() < component.MinPlayer;
|
||||
|
||||
if (check1 || check2)
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
DeclineERT(component.TargetStation.Value);
|
||||
_recruitment.Cleanup(ERTRecruitmentRuleComponent.EventName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (component.TargetStation != null)
|
||||
AcceptERT(component.TargetStation.Value);
|
||||
|
||||
_recruitment.EndRecruitment(ERTRecruitmentRuleComponent.EventName);
|
||||
var ertsys = _entities.System<ERTRecruitmentRule>();
|
||||
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;
|
||||
|
||||
@@ -13,6 +13,8 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
|
||||
|
||||
[DataField("minPlayer")] public int MinPlayer = 4;
|
||||
|
||||
[DataField("earliestStart")] public int EarliestStart = 45;
|
||||
|
||||
public static SoundSpecifier ERTYes = new SoundPathSpecifier("/Audio/Announcements/ert_yes.ogg");
|
||||
public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg");
|
||||
|
||||
@@ -21,8 +23,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,31 @@ 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 maxCount = 1;
|
||||
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 +112,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 +131,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 +166,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 +197,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