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.

71 lines
2.3KB

  1. using Gamecraft.Damage;
  2. using RobocraftX.Common;
  3. using Svelto.ECS;
  4. namespace TechbloxModdingAPI
  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 : EcsObjectBase
  11. {
  12. public Cluster(EGID id) : base(id)
  13. {
  14. }
  15. public Cluster(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP))
  16. {
  17. }
  18. public float InitialHealth
  19. {
  20. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).initialHealth;
  21. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).initialHealth = value;
  22. }
  23. public float CurrentHealth
  24. {
  25. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).currentHealth;
  26. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).currentHealth = value;
  27. }
  28. public float HealthMultiplier
  29. {
  30. get => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).healthMultiplier;
  31. set => Block.BlockEngine.GetBlockInfo<HealthEntityComponent>(this).healthMultiplier = value;
  32. }
  33. /// <summary>
  34. /// Returns the simulation-time rigid bodies for the chunks in this cluster.
  35. /// </summary>
  36. /// <returns>An array of sim-bodies</returns>
  37. public SimBody[] GetSimBodies()
  38. {
  39. return Block.BlockEngine.GetClusterBodies(Id.entityID);
  40. }
  41. public override string ToString()
  42. {
  43. return $"{nameof(Id)}: {Id}";
  44. }
  45. protected bool Equals(Cluster other)
  46. {
  47. return Id.Equals(other.Id);
  48. }
  49. public override bool Equals(object obj)
  50. {
  51. if (ReferenceEquals(null, obj)) return false;
  52. if (ReferenceEquals(this, obj)) return true;
  53. if (obj.GetType() != this.GetType()) return false;
  54. return Equals((Cluster) obj);
  55. }
  56. public override int GetHashCode()
  57. {
  58. return Id.GetHashCode();
  59. }
  60. }
  61. }