Unit.cs 693 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using MongoDB.Bson.Serialization.Attributes;
  2. using PF;
  3. namespace ETModel
  4. {
  5. public enum UnitType
  6. {
  7. Hero,
  8. Npc
  9. }
  10. [ObjectSystem]
  11. public class UnitSystem : AwakeSystem<Unit, UnitType>
  12. {
  13. public override void Awake(Unit self, UnitType a)
  14. {
  15. self.Awake(a);
  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 EndDeSerialize()
  28. {
  29. Game.EventSystem.Add(this);
  30. }
  31. public override void Dispose()
  32. {
  33. if (this.IsDisposed)
  34. {
  35. return;
  36. }
  37. base.Dispose();
  38. }
  39. }
  40. }