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.

45 lines
1.6KB

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