using Game; using UnityEngine; public partial class GameEntity { public int ID() { return iD.Value; } public string CfgId() { return iD.Data.CfgId; } public bool IsMaster() { return ID() == Util.GetMasterID(); } public bool IsMasterSoul() { return ID() == Util.GetMasterSoulID(); } public Vector3 Pos() { return view.PositionLogic; } public Vector3 PosView() { return view.PositionView; } public Vector3 PosGround() { var pos = view.PositionLogic; return new Vector3(pos.x, 0, pos.z); } public Vector3 PosPre() { return view.PositionPre; } public void SetPos(Vector3 pos) { view.GameObject.transform.position = pos; } public void SetFixedPos(Vector3 pos) { RaycastHit hitInfo; var isHit = Physics.Raycast(pos + Vector3.up * 1, Vector3.down, out hitInfo, 2, UtilPhysics.LayerMaskDefault); if (isHit) { SetPos(hitInfo.point); } else { SetPos(pos); } } public void OnCreate() { SendAliveMsg(true); } public void OnDie() { SendAliveMsg(false); } public void SetTarget(int target) { iD.Data.Target = target; } public int Target() { return iD.Data.Target; } public void SetOwner(int owner) { iD.Data.Owner = owner; } public int Owner() { return iD.Data.Owner; } public void SetTeam(ETeam team) { iD.Data.Team = team; } public ETeam Team() { return iD.Data.Team; } private void SendAliveMsg(bool isAlive) { var param = new PEntityAlive() { Entity = ID(), IsAlive = isAlive, }; EventManager.Instance.SendEvent(EEvent.EntityAlive, param); } }