1
0

SharedPAISystem.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Content.Shared.Actions;
  2. namespace Content.Shared.PAI
  3. {
  4. /// <summary>
  5. /// pAIs, or Personal AIs, are essentially portable ghost role generators.
  6. /// In their current implementation, they create a ghost role anyone can access,
  7. /// and that a player can also "wipe" (reset/kick out player).
  8. /// Theoretically speaking pAIs are supposed to use a dedicated "offer and select" system,
  9. /// with the player holding the pAI being able to choose one of the ghosts in the round.
  10. /// This seems too complicated for an initial implementation, though,
  11. /// and there's not always enough players and ghost roles to justify it.
  12. /// </summary>
  13. public abstract class SharedPAISystem : EntitySystem
  14. {
  15. [Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
  16. public override void Initialize()
  17. {
  18. base.Initialize();
  19. SubscribeLocalEvent<PAIComponent, MapInitEvent>(OnMapInit);
  20. SubscribeLocalEvent<PAIComponent, ComponentShutdown>(OnShutdown);
  21. }
  22. private void OnMapInit(EntityUid uid, PAIComponent component, MapInitEvent args)
  23. {
  24. _actionsSystem.AddAction(uid, ref component.MidiAction, component.MidiActionId);
  25. _actionsSystem.AddAction(uid, ref component.MapAction, component.MapActionId);
  26. }
  27. private void OnShutdown(EntityUid uid, PAIComponent component, ComponentShutdown args)
  28. {
  29. _actionsSystem.RemoveAction(uid, component.MidiAction);
  30. _actionsSystem.RemoveAction(uid, component.MapAction);
  31. }
  32. }
  33. }