protected override void PostInitialize() { m_turn_scheduler = new TaskScheduler <LogicWorld>(this); FixPoint grid_size = FixPoint.One; FixPoint seeker_radius = FixPoint.One / FixPoint.FixPointDigit[4]; FixPoint x_size = new FixPoint(40); FixPoint z_size = new FixPoint(30); Vector3FP left_bottom_position = new Vector3FP(new FixPoint(-20), FixPoint.Zero, new FixPoint(-15)); SquareGridGraph grid_graph = new SquareGridGraph(); //HexagonGridGraph grid_graph = new HexagonGridGraph(); grid_graph.GenerateAsPlaneMap(grid_size, x_size, z_size, FixPoint.Zero, left_bottom_position, seeker_radius); grid_graph.CoverArea(new Vector3FP(FixPoint.Zero, FixPoint.Zero, FixPoint.FixPointDigit[5]), new Vector3FP(FixPoint.FixPointDigit[7] + FixPoint.Half, FixPoint.Zero, FixPoint.Half)); grid_graph.CoverArea(new Vector3FP(FixPoint.FixPointDigit[7] + FixPoint.Half, FixPoint.Zero, FixPoint.Zero), new Vector3FP(FixPoint.Half, FixPoint.Zero, FixPoint.FixPointDigit[5])); grid_graph.CoverArea(new Vector3FP(-FixPoint.FixPointDigit[7] - FixPoint.Half, FixPoint.Zero, FixPoint.Two), new Vector3FP(FixPoint.Half, FixPoint.Zero, FixPoint.FixPointDigit[7] + FixPoint.Half)); CellSpacePartition space_partition = new CellSpacePartition(this, x_size, z_size, left_bottom_position); m_scene_space = new SceneSpace(); m_scene_space.m_space_id = 0; m_scene_space.m_min_position = left_bottom_position; m_scene_space.m_max_position = new Vector3FP(left_bottom_position.x + x_size, FixPoint.Zero, left_bottom_position.z + z_size); m_scene_space.m_graph = grid_graph; m_scene_space.m_paitition = space_partition; }
public override void Destruct() { m_turn_scheduler.Destruct(); m_turn_scheduler = null; base.Destruct(); m_scene_space.Destruct(); m_scene_space = null; }
public override void InitializeComponent() { BirthPositionInfo birth_info = ParentObject.GetCreationContext().m_birth_info; if (birth_info != null) { m_current_position = birth_info.m_birth_position; m_base_angle = birth_info.m_birth_angle; m_current_space = birth_info.m_space; } else { ParentObject.GetCreationContext().m_birth_info = new BirthPositionInfo(m_current_position.x, m_current_position.y, m_current_position.z, m_base_angle); } if (m_current_space == null) { m_current_space = GetLogicWorld().GetDefaultSceneSpace(); } ObjectProtoData proto_data = ParentObject.GetCreationContext().m_proto_data; if (proto_data != null) { var dic = proto_data.m_component_variables; if (dic != null) { string value; if (dic.TryGetValue("radius", out value)) { m_radius = FixPoint.Parse(value); } } } if (m_collision_sender && m_current_space != null) { m_current_space.m_paitition.AddEntiy(this); } }
public void Teleport(SceneSpace space, Vector3FP new_position) { if (m_collision_sender) { if (space != m_current_space) { if (m_current_space != null) { m_current_space.m_paitition.RemoveEntity(this); } m_current_position = new_position; m_current_space = space; if (m_current_space != null) { m_current_space.m_paitition.AddEntiy(this); } } else { if (m_current_space != null) { m_current_space.m_paitition.UpdateEntity(this, new_position); } m_current_position = new_position; } } else { m_current_position = new_position; } #if COMBAT_CLIENT ChangePositionRenderMessage msg = RenderMessage.Create <ChangePositionRenderMessage>(); msg.Construct(GetOwnerEntityID(), new_position); GetLogicWorld().AddRenderMessage(msg); #endif }
protected override void OnDestruct() { m_current_space = null; }
public void CopyFrom(BirthPositionInfo rhs) { m_birth_position = rhs.m_birth_position; m_birth_angle = rhs.m_birth_angle; m_space = rhs.m_space; }
public void ClearSpace() { m_current_space = null; }
public BirthPositionInfo(FixPoint x, FixPoint y, FixPoint z, FixPoint angle, SceneSpace space = null) { m_birth_position = new Vector3FP(x, y, z); m_birth_angle = angle; m_space = space; }