public void Create(EntityInfo entity) { if (null != entity) { m_Entity = entity; MovementStateInfo msi = m_Entity.GetMovementStateInfo(); ScriptRuntime.Vector3 pos = msi.GetPosition3D(); float dir = msi.GetFaceDir(); CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度)); if (null != Actor) { m_Agent = Actor.GetComponent <NavMeshAgent>(); if (m_Agent == null) { m_Agent = Actor.AddComponent <NavMeshAgent>(); m_Agent.angularSpeed = c_AngularSpeed; m_Agent.acceleration = c_Acceleration; m_Agent.radius = entity.GetRadius(); m_Agent.speed = entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度); m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; } m_Animator = Actor.GetComponentInChildren <Animator>(); EntityDrawGizmos gizmos = Actor.GetComponent <EntityDrawGizmos>(); if (null == gizmos) { gizmos = Actor.AddComponent <EntityDrawGizmos>(); gizmos.npcInfo = m_Entity; } else { gizmos.npcInfo = m_Entity; } SetMoveAgentEnable(true); try{ if (null != m_Agent) { m_Agent.ResetPath(); } } catch { m_Agent.enabled = true; } } } }
public void CreateEntityView(int objId) { if (objId <= 0) { LogSystem.Error("Error:CreateEntityView objId<=0 !!!"); Helper.LogCallStack(); return; } if (!m_EntityViews.ContainsKey(objId)) { EntityInfo obj = PluginFramework.Instance.EntityManager.GetEntityInfo(objId); if (null != obj) { EntityViewModel view = new EntityViewModel(); view.Create(obj); m_EntityViews.Add(objId, view); if (null != view.Actor) { if (m_Object2Ids.ContainsKey(view.Actor)) { m_Object2Ids[view.Actor] = objId; } else { m_Object2Ids.Add(view.Actor, objId); } } else { LogSystem.Warn("CreateEntityView:{0}, model:{1}, actor is null", objId, obj.GetModel()); } } } }
internal void Create(EntityInfo entity) { if (null != entity) { m_Entity = entity; MovementStateInfo msi = m_Entity.GetMovementStateInfo(); ScriptRuntime.Vector3 pos = msi.GetPosition3D(); float dir = msi.GetFaceDir(); CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), m_Entity.GetActualProperty().MoveSpeed); if (null != Actor) { m_Agent = Actor.GetComponent<NavMeshAgent>(); if (m_Agent == null) { m_Agent = Actor.AddComponent<NavMeshAgent>(); m_Agent.angularSpeed = c_AngularSpeed; m_Agent.acceleration = c_Acceleration; m_Agent.radius = entity.GetRadius(); m_Agent.speed = entity.GetActualProperty().MoveSpeed; m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; m_Agent.ResetPath(); } m_Animator = Actor.GetComponentInChildren<Animator>(); EntityDrawGizmos gizmos = Actor.GetComponent<EntityDrawGizmos>(); if (null == gizmos) { gizmos = Actor.AddComponent<EntityDrawGizmos>(); gizmos.npcInfo = m_Entity; } else { gizmos.npcInfo = m_Entity; } SetMoveAgentEnable(true); } } }