Event refactor (#9589)
* Station event refactor * Remove clientside `IStationEventManager` we can just use prototypes * Basic API idea * Cruft * first attempt at epicness * okay yeah this shit is really clean * sort out minor stuff * Convert `BreakerFlip` * `BureaucraticError` + general cleanup * `DiseaseOutbreak` * `FalseAlarm` * `GasLeak` * `KudzuGrowth` * `MeteorSwarm` * `MouseMigration` * misc errors * `PowerGridCheck` * `RandomSentience` * `VentClog` * `VentCritters` * `ZombieOutbreak` * Rewrite basic event scheduler * Minor fixes and logging * ooooops * errors + fix * linter * completions, `RuleStarted` property, update loop fixes * Tweaks * Fix #9462 * Basic scheduler update fix, and fixes #8174 * Add test * UI cleanup * really this was just for testing
This commit is contained in:
@@ -9,26 +9,19 @@ using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class RandomSentience : StationEvent
|
||||
public sealed class RandomSentience : StationEventSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
public override string Prototype => "RandomSentience";
|
||||
|
||||
public override string Name => "RandomSentience";
|
||||
|
||||
public override float Weight => WeightNormal;
|
||||
|
||||
protected override float EndAfter => 1.0f;
|
||||
|
||||
public override void Startup()
|
||||
public override void Started()
|
||||
{
|
||||
base.Startup();
|
||||
base.Started();
|
||||
HashSet<EntityUid> stationsToNotify = new();
|
||||
|
||||
var targetList = _entityManager.EntityQuery<SentienceTargetComponent>().ToList();
|
||||
_random.Shuffle(targetList);
|
||||
var targetList = EntityManager.EntityQuery<SentienceTargetComponent>().ToList();
|
||||
RobustRandom.Shuffle(targetList);
|
||||
|
||||
var toMakeSentient = _random.Next(2, 5);
|
||||
var toMakeSentient = RobustRandom.Next(2, 5);
|
||||
var groups = new HashSet<string>();
|
||||
|
||||
foreach (var target in targetList)
|
||||
@@ -36,10 +29,10 @@ public sealed class RandomSentience : StationEvent
|
||||
if (toMakeSentient-- == 0)
|
||||
break;
|
||||
|
||||
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;
|
||||
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;
|
||||
comp.RoleDescription = Loc.GetString("station-event-random-sentience-role-description", ("name", comp.RoleName));
|
||||
groups.Add(target.FlavorKind);
|
||||
}
|
||||
@@ -67,8 +60,8 @@ public sealed class RandomSentience : StationEvent
|
||||
(EntityUid) station,
|
||||
Loc.GetString("station-event-random-sentience-announcement",
|
||||
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
|
||||
("data", Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}")),
|
||||
("strength", Loc.GetString($"random-sentience-event-strength-{_random.Next(1, 8)}"))),
|
||||
("data", Loc.GetString($"random-sentience-event-data-{RobustRandom.Next(1, 6)}")),
|
||||
("strength", Loc.GetString($"random-sentience-event-strength-{RobustRandom.Next(1, 8)}"))),
|
||||
playDefaultSound: false,
|
||||
colorOverride: Color.Gold
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user