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.

75 lines
2.0KB

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