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.

74 lines
2.3KB

  1. using Gamecraft.Damage;
  2. using RobocraftX.Common;
  3. using Svelto.ECS;
  4. namespace GamecraftModdingAPI
  5. {
  6. /// <summary>
  7. /// Represnts a cluster of blocks in time running mode, meaning blocks that are connected either directly or via joints.
  8. /// Only exists if a cluster destruction manager is present. Static blocks like grass and dirt aren't part of a cluster.
  9. /// </summary>
  10. public class Cluster
  11. {
  12. public EGID Id { get; }
  13. public Cluster(EGID id)
  14. {
  15. Id = id;
  16. }
  17. public Cluster(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP))
  18. {
  19. }
  20. public float InitialHealth
  21. {
  22. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).initialHealth;
  23. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).initialHealth = value;
  24. }
  25. public float CurrentHealth
  26. {
  27. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).currentHealth;
  28. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).currentHealth = value;
  29. }
  30. public float HealthMultiplier
  31. {
  32. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).healthMultiplier;
  33. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(Id).healthMultiplier = value;
  34. }
  35. /// <summary>
  36. /// Returns the simulation-time rigid bodies for the chunks in this cluster.
  37. /// </summary>
  38. /// <returns>An array of sim-bodies</returns>
  39. public SimBody[] GetSimBodies()
  40. {
  41. return Block.BlockEngine.GetClusterBodies(Id.entityID);
  42. }
  43. public override string ToString()
  44. {
  45. return $"{nameof(Id)}: {Id}";
  46. }
  47. protected bool Equals(Cluster other)
  48. {
  49. return Id.Equals(other.Id);
  50. }
  51. public override bool Equals(object obj)
  52. {
  53. if (ReferenceEquals(null, obj)) return false;
  54. if (ReferenceEquals(this, obj)) return true;
  55. if (obj.GetType() != this.GetType()) return false;
  56. return Equals((Cluster) obj);
  57. }
  58. public override int GetHashCode()
  59. {
  60. return Id.GetHashCode();
  61. }
  62. }
  63. }