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.

77 lines
2.4KB

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