public void InitParam(ProjectileParameters param) { m_param = param; if (m_trajectory_type == TrajectoryTypeBezier) { m_param.m_bezier_b = (m_param.m_start_position + m_param.m_target_position) / FixPoint.Two; m_param.m_bezier_b.y += m_extra_hight; } if (m_param.m_life_time <= FixPoint.Zero) { m_param.m_life_time = m_life_time; } PositionComponent position_component = ParentObject.GetComponent(PositionComponent.ID) as PositionComponent; GridGraph grid_graph = position_component.GetGridGraph(); GridNode node = grid_graph.Position2Node(position_component.CurrentPosition); m_previous_walkable = (node != null && node.Walkable); if (m_task == null) { m_task = LogicTask.Create <UpdateProjectileTask>(); } m_task.Construct(this, m_param.m_life_time); var schedeler = GetLogicWorld().GetTaskScheduler(); schedeler.Schedule(m_task, GetCurrentTime(), LOGIC_UPDATE_INTERVAL, LOGIC_UPDATE_INTERVAL); #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStartMoving(ParentObject.ID, true); GetLogicWorld().AddRenderMessage(msg); #endif }
public void Explode(Entity entity) { #if COMBAT_CLIENT if (m_collision_sound_cfgid > 0) { PlaySoundMessage sound_msg = RenderMessage.Create <PlaySoundMessage>(); sound_msg.Construct(GetOwnerEntityID(), m_collision_sound_cfgid, FixPoint.MinusOne); GetLogicWorld().AddRenderMessage(sound_msg); } #endif ApplyGenerator(entity); if (entity == null || !m_pierce_entity) { #if COMBAT_CLIENT LocomoteRenderMessage msg = RenderMessage.Create <LocomoteRenderMessage>(); msg.ConstructAsStopMoving(ParentObject.ID, true); GetLogicWorld().AddRenderMessage(msg); #endif if (m_task != null) { m_task.Cancel(); LogicTask.Recycle(m_task); m_task = null; } EntityUtil.KillEntity((Entity)ParentObject, ParentObject.ID); } }
protected override void OnDestruct() { if (m_param != null) { RecyclableObject.Recycle(m_param); m_param = null; } if (m_task != null) { m_task.Cancel(); LogicTask.Recycle(m_task); m_task = null; } }