protected override void PostInitializeComponent() { ModelComponent model_component = ParentObject.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } GameObject go = model_component.GetUnityGameObject(); if (go == null) { return; } Transform child = go.transform.FindChild(m_animator_path); if (child == null) { return; } m_unity_animator_cmp = child.GetComponent <Animator>(); LocomotorComponent locomotor_componnet = GetLogicEntity().GetComponent(LocomotorComponent.ID) as LocomotorComponent; if (locomotor_componnet != null) { m_locomotor_animation_speed = (float)locomotor_componnet.LocomotorSpeedRate; } }
protected override void PostInitializeComponent() { ModelComponent model_component = ParentObject.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } GameObject go = model_component.GetUnityGameObject(); if (go == null) { return; } m_bodyCtrl_trans = go.transform.FindChild(m_root_path); if (m_rotate_turret_asset != null) { m_is_aiming_line_state = false; m_rotate_turret_trans = go.transform.FindChild(m_rotate_turret_asset); Transform aiming_line_parent = go.transform.FindChild(m_aiming_line_parent_path); LoadAimingLine(aiming_line_parent); } else { bool isLocal = GetLogicEntity().GetCreationContext().m_is_local; if (isLocal) { Transform aiming_line_parent = go.transform.FindChild(m_aiming_line_parent_path); LoadAimingLine(aiming_line_parent); } m_is_aiming_line_state = true; } }
void ProcessRenderMessage_ChangePosition(ChangePositionRenderMessage msg) { RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent; if (predic_component != null) { if (msg.m_micro_adjusting && predic_component.HasMovementPredict) { return; } else { predic_component.ClearAllPrediction(); } } ModelComponent model_component = render_entity.GetComponent <ModelComponent>(); if (model_component == null) { return; } model_component.UpdatePosition(); }
void ProcessRenderMessage_StopMoving(LocomoteRenderMessage msg) { RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } m_render_world.UnregisterMovingEntity(model_component); if (msg.m_block_animation) { return; } PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent; if (msg.m_reason == LocomoteRenderMessage.NotFromCommand || predic_component == null || !predic_component.HasMovementPredict) { PlayIdleAnimation(render_entity); } }
void ProcessRenderMessage_StartMoving(LocomoteRenderMessage msg) { RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } m_render_world.RegisterMovingEntity(model_component); PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent; if (msg.m_reason == LocomoteRenderMessage.NotLocomotion || msg.m_block_animation) { model_component.UpdateAngle(); if (predic_component != null) { predic_component.OnLogicMove(); } } else if (msg.m_reason == LocomoteRenderMessage.NotFromCommand) { model_component.UpdateAngle(); PlayLocomotorAnimation(render_entity); if (predic_component != null) { predic_component.OnLogicMove(); } } else if (msg.m_reason == LocomoteRenderMessage.UnblockAnimation) { model_component.UpdateAngle(); PlayLocomotorAnimation(render_entity); } else if (predic_component == null || !predic_component.HasMovementPredict) { model_component.UpdateAngle(); PlayLocomotorAnimation(render_entity); } }
protected override void PostInitializeComponent() { m_model_component = ParentObject.GetComponent(ModelComponent.ID) as ModelComponent; if (m_model_component == null) { return; } GameObject go = m_model_component.GetUnityGameObject(); if (go == null) { return; } m_interpolation_tr = go.transform; m_model_component.SetPredictComponent(this); Entity entity = GetLogicEntity(); m_position_component = entity.GetComponent(PositionComponent.ID) as PositionComponent; m_locomotor_component = entity.GetComponent(LocomotorComponent.ID) as LocomotorComponent; }
void ProcessRenderMessage_ChangeDirection(ChangeDirectionRenderMessage msg) { //ZZWTODO 移动动作和朝向 RenderEntity render_entity = m_render_entity_manager.GetObject(msg.EntityID); if (render_entity == null) { return; } PredictLogicComponent predic_component = render_entity.GetComponent(PredictLogicComponent.ID) as PredictLogicComponent; if (predic_component != null && predic_component.HasMovementPredict) { return; } ModelComponent model_component = render_entity.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } model_component.UpdateAngle(); }
public void PlayRenderEffect(int render_effect_cfg_id, FixPoint play_time) { //ZZWTODO 为了精准识别每一个effect,可以考虑在逻辑端生成一个id RenderEffectData config = GetRenderWorld().GetRenderEffectData(render_effect_cfg_id); if (config == null) { return; } RenderEffectNode node; if (!m_nodes.TryGetValue(config.m_binding, out node)) { string path; if (!m_binding_name_to_path.TryGetValue(config.m_binding, out path)) { return; } ModelComponent model_component = ParentObject.GetComponent(ModelComponent.ID) as ModelComponent; if (model_component == null) { return; } Transform tr = model_component.GetUnityGameObject().transform.FindChild(path); if (tr == null) { return; } node = new RenderEffectNode(); node.m_parent_tr = tr; m_nodes[config.m_binding] = node; } //RenderEffectInfo info = null; //for (int i = 0; i < node.m_render_effects.Count; ++i) //{ // if (node.m_render_effects[i].m_render_effect_cfgid == render_effect_cfg_id) // { // info = node.m_render_effects[i]; // break; // } //} //if (info != null) //{ //} GameObject effect_go = UnityResourceManager.Instance.CreateGameObject(config.m_prefab); if (effect_go == null) { return; } effect_go.transform.parent = node.m_parent_tr; effect_go.transform.localPosition = Vector3.zero; effect_go.transform.localScale = Vector3.one; effect_go.transform.localEulerAngles = Vector3.zero; RenderEffectInfo info = RecyclableObject.Create <RenderEffectInfo>(); info.m_render_effect_cfgid = render_effect_cfg_id; info.m_go = effect_go; if (play_time > FixPoint.Zero) { var task_scheduler = GetRenderWorld().GetTaskScheduler(); RemoveRenderEffectTask task = RenderTask.Create <RemoveRenderEffectTask>(); task.Construct(this, render_effect_cfg_id); task_scheduler.Schedule(task, GetRenderWorld().CurrentTime, play_time); info.m_task = task; } node.m_render_effects.Add(info); }
public void UnregisterMovingEntity(ModelComponent model_component) { m_moving_entities.Remove(model_component); }
public void RegisterMovingEntity(ModelComponent model_component) { m_moving_entities.Add(model_component); }