Unit.cs 633 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Numerics;
  2. using MongoDB.Bson.Serialization.Attributes;
  3. namespace Model
  4. {
  5. public enum UnitType
  6. {
  7. Hero,
  8. Npc
  9. }
  10. [ObjectSystem]
  11. public class UnitSystem : ObjectSystem<Unit>, IAwake<UnitType>
  12. {
  13. public void Awake(UnitType unitType)
  14. {
  15. this.Get().Awake(unitType);
  16. }
  17. }
  18. public sealed class Unit: Entity
  19. {
  20. public UnitType UnitType { get; private set; }
  21. [BsonIgnore]
  22. public Vector3 Position { get; set; }
  23. public void Awake(UnitType unitType)
  24. {
  25. this.UnitType = unitType;
  26. }
  27. public override void Dispose()
  28. {
  29. if (this.IsDisposed)
  30. {
  31. return;
  32. }
  33. base.Dispose();
  34. }
  35. }
  36. }