2022-02-25 23:10:09 -06:00
|
|
|
|
using System.Linq;
|
2022-06-03 21:37:35 +10:00
|
|
|
|
using Content.Server.Chat;
|
2022-06-23 20:11:03 +10:00
|
|
|
|
using Content.Server.Chat.Systems;
|
2022-02-25 23:40:15 -06:00
|
|
|
|
using Content.Server.Ghost.Roles.Components;
|
2022-02-25 23:10:09 -06:00
|
|
|
|
using Content.Server.Mind.Commands;
|
2022-06-03 21:37:35 +10:00
|
|
|
|
using Content.Server.Station.Systems;
|
2022-02-25 23:10:09 -06:00
|
|
|
|
using Content.Server.StationEvents.Components;
|
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.StationEvents.Events;
|
|
|
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
|
public sealed class RandomSentience : StationEventSystem
|
2022-02-25 23:10:09 -06:00
|
|
|
|
{
|
2022-07-10 18:48:41 -07:00
|
|
|
|
public override string Prototype => "RandomSentience";
|
2022-02-25 23:10:09 -06:00
|
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
|
public override void Started()
|
2022-02-25 23:10:09 -06:00
|
|
|
|
{
|
2022-07-10 18:48:41 -07:00
|
|
|
|
base.Started();
|
2022-06-03 21:37:35 +10:00
|
|
|
|
HashSet<EntityUid> stationsToNotify = new();
|
2022-02-25 23:10:09 -06:00
|
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
|
var targetList = EntityManager.EntityQuery<SentienceTargetComponent>().ToList();
|
|
|
|
|
|
RobustRandom.Shuffle(targetList);
|
2022-02-25 23:10:09 -06:00
|
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
|
var toMakeSentient = RobustRandom.Next(2, 5);
|
2022-02-25 23:10:09 -06:00
|
|
|
|
var groups = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var target in targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (toMakeSentient-- == 0)
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2022-07-10 18:48:41 -07:00
|
|
|
|
MakeSentientCommand.MakeSentient(target.Owner, EntityManager);
|
|
|
|
|
|
EntityManager.RemoveComponent<SentienceTargetComponent>(target.Owner);
|
|
|
|
|
|
var comp = EntityManager.AddComponent<GhostTakeoverAvailableComponent>(target.Owner);
|
|
|
|
|
|
comp.RoleName = EntityManager.GetComponent<MetaDataComponent>(target.Owner).EntityName;
|
2022-02-25 23:40:15 -06:00
|
|
|
|
comp.RoleDescription = Loc.GetString("station-event-random-sentience-role-description", ("name", comp.RoleName));
|
2022-02-25 23:10:09 -06:00
|
|
|
|
groups.Add(target.FlavorKind);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (groups.Count == 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
var groupList = groups.ToList();
|
|
|
|
|
|
var kind1 = groupList.Count > 0 ? groupList[0] : "???";
|
|
|
|
|
|
var kind2 = groupList.Count > 1 ? groupList[1] : "???";
|
|
|
|
|
|
var kind3 = groupList.Count > 2 ? groupList[2] : "???";
|
2022-06-03 21:37:35 +10:00
|
|
|
|
|
2022-06-04 19:09:04 +10:00
|
|
|
|
var entSysMgr = IoCManager.Resolve<IEntitySystemManager>();
|
|
|
|
|
|
var stationSystem = entSysMgr.GetEntitySystem<StationSystem>();
|
|
|
|
|
|
var chatSystem = entSysMgr.GetEntitySystem<ChatSystem>();
|
2022-06-03 21:37:35 +10:00
|
|
|
|
foreach (var target in targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var station = stationSystem.GetOwningStation(target.Owner);
|
|
|
|
|
|
if(station == null) continue;
|
|
|
|
|
|
stationsToNotify.Add((EntityUid) station);
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach (var station in stationsToNotify)
|
|
|
|
|
|
{
|
|
|
|
|
|
chatSystem.DispatchStationAnnouncement(
|
|
|
|
|
|
(EntityUid) station,
|
|
|
|
|
|
Loc.GetString("station-event-random-sentience-announcement",
|
|
|
|
|
|
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
|
2022-07-10 18:48:41 -07:00
|
|
|
|
("data", Loc.GetString($"random-sentience-event-data-{RobustRandom.Next(1, 6)}")),
|
|
|
|
|
|
("strength", Loc.GetString($"random-sentience-event-strength-{RobustRandom.Next(1, 8)}"))),
|
2022-05-08 15:07:59 +10:00
|
|
|
|
playDefaultSound: false,
|
2022-04-10 13:54:07 -07:00
|
|
|
|
colorOverride: Color.Gold
|
2022-06-03 21:37:35 +10:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2022-02-25 23:10:09 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|