Пример #1
0
        public override void Inflict(FixPoint start_time)
        {
            Skill         skill       = GetOwnerSkill();
            List <Target> targets     = skill.GetTargets();
            LogicWorld    logic_world = GetLogicWorld();

            for (int i = 0; i < targets.Count; ++i)
            {
                m_current_target = targets[i].GetEntity(logic_world);
                if (m_current_target == null)
                {
                    continue;
                }
                EntityUtil.KillEntity(m_current_target, GetOwnerEntityID());
            }
            m_current_target = null;
        }
Пример #2
0
        public void DeactivateOnOneTarget(Entity target)
        {
            var enumerator = m_effect2entity.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current.Value != target.ID)
                {
                    continue;
                }
                RemoveEffectTask task = LogicTask.Create <RemoveEffectTask>();
                task.Construct(target.ID, enumerator.Current.Key);
                LogicWorld logic_world = m_generator.GetLogicWorld();
                var        schedeler   = logic_world.GetTaskScheduler();
                schedeler.Schedule(task, logic_world.GetCurrentTime(), FixPoint.Zero);
            }
        }
Пример #3
0
 public CellSpacePartition(LogicWorld logic_world, FixPoint x_size, FixPoint z_size, Vector3FP left_bottom_position)
 {
     m_logic_world          = logic_world;
     m_left_bottom_position = left_bottom_position;
     CELL_X_COUNT           = (int)((x_size + CELL_SIZE - FixPoint.PrecisionFP) / CELL_SIZE);
     CELL_Z_COUNT           = (int)((z_size + CELL_SIZE - FixPoint.PrecisionFP) / CELL_SIZE);
     MAX_X_INDEX            = CELL_X_COUNT - 1;
     MAX_Z_INDEX            = CELL_Z_COUNT - 1;
     m_cells = new Cell[CELL_X_COUNT, CELL_Z_COUNT];
     for (int x = 0; x < CELL_X_COUNT; ++x)
     {
         for (int z = 0; z < CELL_Z_COUNT; ++z)
         {
             m_cells[x, z] = new Cell();
         }
     }
 }
        public void Destruct()
        {
            m_id_generator.Destruct();
            m_id_generator = null;

            var enumerator = m_regions.GetEnumerator();

            while (enumerator.MoveNext())
            {
                EntityGatheringRegion region = enumerator.Current.Value;
                region.Deactivate();
                RecyclableObject.Recycle(region);
            }
            m_regions.Clear();
            m_active_region_bundles.Clear();

            m_logic_world = null;
        }
Пример #5
0
        public void SendSignal(int signal_type, System.Object signal = null)
        {
            if (m_all_type_listeners == null)
            {
                return;
            }
            List <SignalListenerContext> listeners;

            if (!m_all_type_listeners.TryGetValue(signal_type, out listeners))
            {
                return;
            }
            int cur_count = listeners.Count;

            if (cur_count == 0)
            {
                return;
            }
            LogicWorld logic_world = GetLogicWorldForSignal();
            int        index       = 0;

            while (index < cur_count)
            {
                SignalListenerContext context  = listeners[index];
                ISignalListener       listener = context.GetListener(logic_world);
                if (listener == null)
                {
                    listeners.RemoveAt(index);
                }
                else
                {
                    listener.ReceiveSignal(this, signal_type, signal);
                }
                int new_count = listeners.Count;
                if (new_count < cur_count)
                {
                    cur_count = new_count;
                }
                else
                {
                    ++index;
                }
            }
        }
Пример #6
0
 public void Activate(EffectApplicationData app_data, List <Target> default_targets)
 {
     if (m_data.m_target_gathering_param.m_type == TargetGatheringType.Default || m_data.m_target_gathering_param.m_type == 0)
     {
         LogicWorld logic_world = m_generator.GetLogicWorld();
         for (int i = 0; i < default_targets.Count; ++i)
         {
             Entity entity = default_targets[i].GetEntity(logic_world);
             if (entity != null)
             {
                 ActivateOnOneTatget(app_data, entity);
             }
         }
     }
     else
     {
         GatherTargetsAndActivate(app_data);
     }
 }
Пример #7
0
 public Vector3FP GetPosition(LogicWorld logic_world)
 {
     if (m_target_type == TargetType.EntityType)
     {
         Entity entity = logic_world.GetEntityManager().GetObject(m_object_id);
         if (entity == null)
         {
             return(new Vector3FP(FixPoint.Zero, FixPoint.Zero, FixPoint.Zero));
         }
         else
         {
             return((entity.GetComponent(PositionComponent.ID) as PositionComponent).CurrentPosition);
         }
     }
     else
     {
         return(m_position);
     }
 }
Пример #8
0
        protected override void OnActionUpdate(FixPoint delta_time)
        {
            SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
            Skill          skill           = skill_component.GetOwnerSkill();

            List <Target> targets     = skill.GetTargets();
            LogicWorld    logic_world = GetLogicWorld();

            for (int i = 0; i < targets.Count; ++i)
            {
                Entity current_target = targets[i].GetEntity(logic_world);
                if (current_target == null)
                {
                    continue;
                }
                skill_component.CurrentTarget = current_target;
                EntityUtil.KillEntity(current_target, skill.GetOwnerEntityID());
            }
            skill_component.CurrentTarget = null;
        }
Пример #9
0
        Effect CreateEffect(int target_entity_id)
        {
            LogicWorld      logic_world    = m_generator.GetLogicWorld();
            EffectManager   effect_manager = logic_world.GetEffectManager();
            IConfigProvider config         = logic_world.GetConfigProvider();
            ObjectTypeData  effect_data    = config.GetEffectData(m_data.m_effect_id);

            if (effect_data == null)
            {
                return(null);
            }
            ObjectCreationContext object_context = new ObjectCreationContext();

            //m_object_proxy_id
            object_context.m_object_type_id = m_data.m_effect_id;
            object_context.m_type_data      = effect_data;
            object_context.m_logic_world    = logic_world;
            object_context.m_owner_id       = target_entity_id;
            Effect effect = effect_manager.CreateObject(object_context);

            return(effect);
        }
Пример #10
0
        void GatherTargetsAndActivate(EffectApplicationData app_data)
        {
            LogicWorld logic_world   = m_generator.GetLogicWorld();
            Entity     source_entity = logic_world.GetEntityManager().GetObject(app_data.m_source_entity_id);

            if (source_entity == null)
            {
                return;
            }
            if (m_targets == null)
            {
                m_targets = new List <Target>();
            }
            m_generator.GetLogicWorld().GetTargetGatheringManager().BuildTargetList(source_entity, m_data.m_target_gathering_param, m_targets);
            for (int i = 0; i < m_targets.Count; ++i)
            {
                Entity entity = m_targets[i].GetEntity(logic_world);
                if (entity != null)
                {
                    ActivateOnOneTatget(app_data, entity);
                }
            }
            ClearTargets();
        }
Пример #11
0
 public TargetGatheringManager(LogicWorld logic_world)
 {
     m_logic_world    = logic_world;
     m_entity_manager = m_logic_world.GetEntityManager();
 }
Пример #12
0
 public void Destruct()
 {
     m_logic_world    = null;
     m_entity_manager = null;
 }
Пример #13
0
 public RegionCallbackManager(LogicWorld logic_world)
 {
     m_logic_world = logic_world;
 }
Пример #14
0
 public EntityManager(LogicWorld logic_world)
     : base(logic_world, IDGenerator.ENTITY_FIRST_ID)
 {
 }
Пример #15
0
 public void Construct(LogicWorld logic_world, BehaviorTree tree)
 {
     m_logic_world = logic_world;
     m_tree        = tree;
 }
Пример #16
0
 public SkillManager(LogicWorld logic_world)
     : base(logic_world, IDGenerator.SKILL_FIRST_ID)
 {
 }
Пример #17
0
 public CommandHandler(LogicWorld logic_world)
 {
     m_logic_world = logic_world;
 }
 public RenderMessageProcessor(RenderWorld render_world)
 {
     m_render_world          = render_world;
     m_logic_world           = render_world.GetLogicWorld();
     m_render_entity_manager = render_world.GetRenderEntityManager();
 }
Пример #19
0
 public void Destruct()
 {
     m_logic_world = null;
 }
Пример #20
0
 public ObjectManager(LogicWorld logic_world, int first_id)
 {
     m_logic_world  = logic_world;
     m_id_generator = new IDGenerator(first_id);
 }
 public SpaceWithoutPartition(LogicWorld logic_world)
 {
     m_logic_world = logic_world;
 }
Пример #22
0
 public EffectManager(LogicWorld logic_world)
     : base(logic_world, IDGenerator.EFFECT_FIRST_ID)
 {
     m_generator_id_generator = new IDGenerator(IDGenerator.EFFECT_GENERATOR_FIRST_ID);
 }
Пример #23
0
        public ISignalListener GetListener(LogicWorld logic_world)
        {
            switch (m_context_type)
            {
            case SignalListenerContextType.PlayerComponent:
            {
                Player player = logic_world.GetPlayerManager().GetObject(m_object_id);
                if (player == null)
                {
                    return(null);
                }
                Component component = player.GetComponent(m_component_type_id);
                if (component == null)
                {
                    return(null);
                }
                return(component as ISignalListener);
            }

            case SignalListenerContextType.EntityComponent:
            {
                Entity entity = logic_world.GetEntityManager().GetObject(m_object_id);
                if (entity == null)
                {
                    return(null);
                }
                Component component = entity.GetComponent(m_component_type_id);
                if (component == null)
                {
                    return(null);
                }
                return(component as ISignalListener);
            }

            case SignalListenerContextType.EffectComponent:
            {
                Effect effect = logic_world.GetEffectManager().GetObject(m_object_id);
                if (effect == null)
                {
                    return(null);
                }
                Component component = effect.GetComponent(m_component_type_id);
                if (component == null)
                {
                    return(null);
                }
                return(component as ISignalListener);
            }

            case SignalListenerContextType.BehaviorTree:
            {
                BehaviorTree tree = logic_world.GetBehaviorTree(m_object_id);
                if (tree == null)
                {
                    return(null);
                }
                return(tree);
            }

            default:
                return(null);
            }
        }
Пример #24
0
 public RenderEntityManager(LogicWorld logic_world, RenderWorld render_world)
     : base(logic_world, IDGenerator.INVALID_FIRST_ID)
 {
     m_render_world = render_world;
 }
Пример #25
0
 public PlayerManager(LogicWorld logic_world)
     : base(logic_world, IDGenerator.PLAYER_FIRST_ID)
 {
 }
 public void Destruct()
 {
     m_collection.Clear();
     m_entities.Clear();
     m_logic_world = null;
 }
Пример #27
0
        public static Entity CreateEntityForSkillAndEffect(Component caller_component, Entity owner_entity, Target projectile_target, Vector3FP position_offset, FixPoint angle_offset, int object_type_id, int object_proto_id, FixPoint object_life_time, EffectGenerator attached_generator)
        {
            LogicWorld      logic_world = owner_entity.GetLogicWorld();
            IConfigProvider config      = logic_world.GetConfigProvider();
            ObjectTypeData  type_data   = config.GetObjectTypeData(object_type_id);

            if (type_data == null)
            {
                return(null);
            }

            PositionComponent owner_position_cmp = owner_entity.GetComponent(PositionComponent.ID) as PositionComponent;
            Vector3FP         source_pos         = owner_position_cmp.CurrentPosition;

            Vector2FP xz_facing;
            FixPoint  angle;
            Vector3FP facing;

            if (projectile_target == null)
            {
                xz_facing = owner_position_cmp.Facing2D;
                angle     = owner_position_cmp.FacingAngle;
                facing.x  = xz_facing.x;
                facing.y  = FixPoint.Zero;
                facing.z  = xz_facing.z;
            }
            else
            {
                Vector3FP target_pos = projectile_target.GetPosition(logic_world);
                xz_facing.x = target_pos.x - source_pos.x;
                xz_facing.z = target_pos.z - source_pos.z;
                xz_facing.Normalize();
                angle  = xz_facing.ToDegree();
                facing = target_pos - source_pos;
                facing.Normalize();
            }
            Vector2FP side      = xz_facing.Perpendicular();
            Vector2FP xz_offset = xz_facing * position_offset.z + side * position_offset.x;

            if (angle_offset != FixPoint.Zero)
            {
                angle += angle_offset;
                FixPoint radian = FixPoint.Degree2Radian(-angle);
                facing.x = FixPoint.Cos(radian);
                facing.z = FixPoint.Sin(radian);
            }

            Vector3FP         birth_position = new Vector3FP(source_pos.x + xz_offset.x, source_pos.y + position_offset.y, source_pos.z + xz_offset.z);
            BirthPositionInfo birth_info     = new BirthPositionInfo(birth_position.x, birth_position.y, birth_position.z, angle, owner_position_cmp.GetCurrentSceneSpace());

            ProjectileComponent owner_entity_projectile_component = owner_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (owner_entity_projectile_component != null)
            {
                Entity original_owner = logic_world.GetEntityManager().GetObject(owner_entity_projectile_component.SourceEntityID);
                if (original_owner != null)
                {
                    owner_entity = original_owner;
                }
            }

            Player owner_player = owner_entity.GetOwnerPlayer();
            ObjectCreationContext object_context = new ObjectCreationContext();

            object_context.m_object_proxy_id = owner_player.ProxyID;
            object_context.m_object_type_id  = object_type_id;
            object_context.m_object_proto_id = object_proto_id;
            object_context.m_birth_info      = birth_info;
            object_context.m_type_data       = type_data;
            object_context.m_proto_data      = config.GetObjectProtoData(object_proto_id);
            object_context.m_logic_world     = logic_world;
            object_context.m_owner_id        = owner_player.ID;
            object_context.m_is_ai           = true;
            object_context.m_is_local        = owner_player.IsLocal;

            Entity created_entity = logic_world.GetEntityManager().CreateObject(object_context);

            DeathComponent death_component = created_entity.GetComponent(DeathComponent.ID) as DeathComponent;

            if (death_component != null && object_life_time > FixPoint.Zero)
            {
                death_component.SetLifeTime(object_life_time);
            }

            SummonedEntityComponent summoned_component = created_entity.GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;

            if (summoned_component != null)
            {
                summoned_component.SetMaster(owner_entity);
            }

            ProjectileComponent projectile_component = created_entity.GetComponent(ProjectileComponent.ID) as ProjectileComponent;

            if (projectile_component != null)
            {
                ProjectileParameters param = RecyclableObject.Create <ProjectileParameters>();
                param.m_start_time       = logic_world.GetCurrentTime();
                param.m_life_time        = object_life_time;
                param.m_source_entity_id = owner_entity.ID;
                param.m_start_position   = birth_position;
                param.m_fixed_facing     = facing;
                if (projectile_target != null)
                {
                    param.m_target_entity_id = projectile_target.GetEntityID();
                    param.m_target_position  = projectile_target.GetPosition(logic_world);
                }
                else
                {
                    Skill          owner_skill     = null;
                    SkillComponent skill_componnet = caller_component as SkillComponent;
                    if (skill_componnet != null)
                    {
                        owner_skill = skill_componnet.GetOwnerSkill();
                    }
                    if (owner_skill != null && owner_skill.GetDefinitionComponent().ExternalDataType == SkillDefinitionComponent.NeedExternalTarget)
                    {
                        param.m_target_entity_id = 0;
                        FixPoint range = owner_skill.GetDefinitionComponent().MaxRange;
                        if (range <= 0)
                        {
                            range = FixPoint.Ten;  //ZZWTODO
                        }
                        if (projectile_component.Speed > FixPoint.Zero)
                        {
                            param.m_life_time = range / projectile_component.Speed;
                        }
                        param.m_target_position = param.m_start_position + param.m_fixed_facing * range;
                    }
                }
                param.m_generator_id = attached_generator == null ? 0 : attached_generator.ID;
                projectile_component.InitParam(param);
            }
            else if (attached_generator != null)
            {
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = owner_entity.ID;
                app_data.m_source_entity_id   = owner_entity.ID;
                attached_generator.Activate(app_data, created_entity);
                RecyclableObject.Recycle(app_data);
            }
            return(created_entity);
        }
Пример #28
0
 public FactionManager(LogicWorld logic_world)
 {
     m_logic_world = logic_world;
 }