public virtual void Initialize(IOutsideWorld outside_world, int world_seed, bool need_render_message) { #if ALLOW_UPDATE AddComponent <LogicWorldEveryFrameUpdater>(true); #endif m_outside_world = outside_world; m_random_generator_int = new RandomGeneratorI(world_seed); m_random_generator_fp = new RandomGeneratorFP(world_seed); m_need_render_message = need_render_message; if (m_need_render_message) { m_render_messages = new List <RenderMessage>(); } m_scheduler = new TaskScheduler <LogicWorld>(this); m_signal_listener_id_generator = new IDGenerator(IDGenerator.SIGNAL_LISTENER_FIRST_ID); m_attribute_modifier_id_generator = new IDGenerator(IDGenerator.ATTRIBUTE_MODIFIER_FIRST_ID); m_damage_modifier_id_generator = new IDGenerator(IDGenerator.DAMAGE_MODIFIER_FIRST_ID); m_behavior_tree_id_generator = new IDGenerator(IDGenerator.BEHAVIOR_TREE_FIRST_ID); m_player_manager = new PlayerManager(this); m_entity_manager = new EntityManager(this); m_skill_manager = new SkillManager(this); m_effect_manager = new EffectManager(this); m_faction_manager = new FactionManager(this); m_target_gathering_manager = new TargetGatheringManager(this); m_region_callback_manager = new RegionCallbackManager(this); m_command_handler = CreateCommandHandler(); PostInitialize(); }
bool RandomPosition(ref Vector2FP random_position) { //ZZWTODO 随机分布,分成grid,随机选一个然后标志占用 RandomGeneratorFP random_generator_fp = GetLogicWorld().GetRandomGeneratorFP(); for (int i = 0; i < 50; ++i) { random_position.x = random_generator_fp.RandBetween(m_min_x, m_max_x); random_position.z = random_generator_fp.RandBetween(m_min_z, m_max_z); bool overlap = false; var enumerator = m_current_objects.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current.Value.FastDistance(ref random_position) < m_object_distance) { overlap = true; break; } } if (!overlap) { return(true); } } return(false); }
public virtual void Destruct() { m_collapsing = true; m_scheduler.Destruct(); m_scheduler = null; m_random_generator_int.Destruct(); m_random_generator_int = null; m_random_generator_fp.Destruct(); m_random_generator_fp = null; m_signal_listener_id_generator.Destruct(); m_signal_listener_id_generator = null; m_attribute_modifier_id_generator.Destruct(); m_attribute_modifier_id_generator = null; m_damage_modifier_id_generator.Destruct(); m_damage_modifier_id_generator = null; m_behavior_tree_id_generator.Destruct(); m_behavior_tree_id_generator = null; m_entity_manager.Destruct(); m_entity_manager = null; m_player_manager.Destruct(); m_player_manager = null; m_skill_manager.Destruct(); m_skill_manager = null; m_effect_manager.Destruct(); m_effect_manager = null; m_faction_manager.Destruct(); m_faction_manager = null; m_target_gathering_manager.Destruct(); m_target_gathering_manager = null; m_region_callback_manager.Destruct(); m_region_callback_manager = null; m_command_handler.Destruct(); m_command_handler = null; m_active_behavior_trees.Clear(); DestroyAllGeneralComponent(); }