| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Diagnostics;
- using MongoDB.Bson.Serialization.Attributes;
- using UnityEngine;
- namespace ET
- {
- [ChildOf(typeof(UnitComponent))]
- [DebuggerDisplay("DebuggerDisplay,nq")]
- public class Unit: Entity, IAwake<int>
- {
- public int ConfigId { get; set; } //配置表id
- [BsonIgnore]
- public UnitConfig Config => UnitConfigCategory.Instance.Get(this.ConfigId);
- public UnitType Type => (UnitType)UnitConfigCategory.Instance.Get(this.ConfigId).Type;
- [BsonElement]
- private Vector3 position; //坐标
- [BsonIgnore]
- public Vector3 Position
- {
- get => this.position;
- set
- {
- Vector3 oldPos = this.position;
- this.position = value;
- Game.EventSystem.Publish(this.DomainScene(), new EventType.ChangePosition() { Unit = this, OldPos = oldPos });
- }
- }
- [BsonIgnore]
- public Vector3 Forward
- {
- get => this.Rotation * Vector3.forward;
- set => this.Rotation = Quaternion.LookRotation(value, Vector3.up);
- }
-
- [BsonElement]
- private Quaternion rotation;
-
- [BsonIgnore]
- public Quaternion Rotation
- {
- get => this.rotation;
- set
- {
- this.rotation = value;
- Game.EventSystem.Publish(this.DomainScene(), new EventType.ChangeRotation() { Unit = this });
- }
- }
- private string DebuggerDisplay => this.Config.Name;
-
- #if ENABLE_CODES
- protected override string ViewGoName
- {
- get
- {
- return $"{this.GetType().Name} ({this.Id})";
- }
- }
- #endif
- }
- }
|