A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6KB

  1. using RobocraftX.Character;
  2. using RobocraftX.Character.Movement;
  3. using RobocraftX.Common.Input;
  4. using Svelto.ECS;
  5. using TechbloxModdingAPI.Engines;
  6. namespace TechbloxModdingAPI.Players
  7. {
  8. public class PlayerEventsEngine : IApiEngine, IReactOnSwap<CharacterPilotSeatEntityStruct>, IReactOnAddAndRemove<PlayerIDStruct>
  9. {
  10. public void Ready()
  11. {
  12. }
  13. public EntitiesDB entitiesDB { get; set; }
  14. public void Dispose()
  15. {
  16. }
  17. public string Name => "TechbloxModdingAPIPlayerEventsEngine";
  18. public bool isRemovable => false;
  19. public void MovedTo(ref CharacterPilotSeatEntityStruct entityComponent, ExclusiveGroupStruct previousGroup, EGID egid)
  20. {
  21. entitiesDB.TryGetEGID(entityComponent.pilotSeatEntity, out var seatId); //TODO: Can't get EGID
  22. var player = Player.GetInstance(egid.entityID);
  23. if (previousGroup == CharacterExclusiveGroups.InPilotSeatGroup)
  24. player.seatExited.Invoke(this, new PlayerSeatEventArgs { SeatId = seatId});
  25. else if (egid.groupID == CharacterExclusiveGroups.InPilotSeatGroup)
  26. player.seatEntered.Invoke(this, new PlayerSeatEventArgs { SeatId = seatId });
  27. }
  28. public void Add(ref PlayerIDStruct entityComponent, EGID egid)
  29. {
  30. Player.joined.Invoke(this, new PlayerEventArgs { PlayerId = egid });
  31. }
  32. public void Remove(ref PlayerIDStruct entityComponent, EGID egid)
  33. {
  34. Player.left.Invoke(this, new PlayerEventArgs { PlayerId = egid });
  35. }
  36. }
  37. }