void CreateAttribute(int id, string base_value)
        {
            AttributeDefinition definition = AttributeSystem.Instance.GetDefinitionByID(id);

            if (definition == null)
            {
                return;
            }
            List <int> referenced_ids = definition.GetReferencedAttributes();

            for (int i = 0; i < referenced_ids.Count; ++i)
            {
                if (!m_attributes.ContainsKey(referenced_ids[i]))
                {
                    string referenced_attribute_base_value;
                    if (!m_base_value.TryGetValue(referenced_ids[i], out referenced_attribute_base_value))
                    {
                        referenced_attribute_base_value = null;
                    }
                    CreateAttribute(referenced_ids[i], referenced_attribute_base_value);
                }
            }
            Attribute attribute = RecyclableObject.Create <Attribute>();

            attribute.Construct(this, definition, base_value);
            m_attributes[id] = attribute;
        }
Esempio n. 2
0
        public void Construct(AttributeManagerComponent owner_component, AttributeDefinition definition, string base_value)
        {
            m_owner_component    = owner_component;
            m_definition         = definition;
            m_base_value_formula = RecyclableObject.Create <Formula>();
            m_base_value_formula.Compile(base_value);

            int count = 0;
            List <ExpressionVariable> variables = m_base_value_formula.GetAllVariables();

            if (variables != null)
            {
                count = variables.Count;
            }
            for (int i = 0; i < count; ++i)
            {
                ExpressionVariable variable = variables[i];
                if (variable.MaxIndex == 1 && variable[0] == ExpressionVariable.VID_LevelTable)
                {
                    m_is_level_based = true;
                }
            }

            ComputeValue();
            m_definition.Reflect(m_owner_component.ParentObject, this, true);
        }
Esempio n. 3
0
        public void OnEntityEnter(int entity_id)
        {
            Entity owner = GetOwnerEntity();

            if (ObjectUtil.IsDead(owner))
            {
                return;
            }
            if (m_enter_generator == null)
            {
                return;
            }
            Entity entity = GetLogicWorld().GetEntityManager().GetObject(entity_id);

            if (entity == null)
            {
                return;
            }
            if (ObjectUtil.IsDead(entity))
            {
                return;
            }
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            m_enter_generator.Activate(app_data, entity);
            RecyclableObject.Recycle(app_data);
        }
Esempio n. 4
0
 public void BuildSkillTargets()
 {
     ClearTargets();
     if (m_definition_component.m_target_gathering_param.m_type == TargetGatheringType.SpecifiedTarget)
     {
         if (m_definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalTarget)
         {
             int specified_target_id = m_definition_component.ExternalID;
             if (specified_target_id > 0)
             {
                 Target target = RecyclableObject.Create <Target>();
                 target.Construct();
                 target.SetEntityTarget(specified_target_id);
                 m_skill_targets.Add(target);
             }
         }
         else if (m_definition_component.ExternalDataType == SkillDefinitionComponent.NeedExternalOffset)
         {
             PositionComponent position_component = GetOwnerEntity().GetComponent(PositionComponent.ID) as PositionComponent;
             Target            target             = RecyclableObject.Create <Target>();
             target.Construct();
             target.SetPositionTarget(position_component.CurrentPosition + m_definition_component.ExternalVector);
             m_skill_targets.Add(target);
         }
     }
     else
     {
         TargetGatheringManager target_gathering_manager = GetLogicWorld().GetTargetGatheringManager();
         target_gathering_manager.BuildTargetList(GetOwnerEntity(), m_definition_component.m_target_gathering_param, m_skill_targets);
     }
 }
Esempio n. 5
0
        protected override void OnActionUpdate(FixPoint delta_time)
        {
            SkillComponent skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
            Skill          skill           = skill_component.GetOwnerSkill();
            Entity         attacker        = skill.GetOwnerEntity();
            List <Target>  targets         = skill.GetTargets();
            LogicWorld     logic_world     = skill.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;
                DamagableComponent damageable_component = current_target.GetComponent(DamagableComponent.ID) as DamagableComponent;
                if (damageable_component == null)
                {
                    continue;
                }
                Damage damage = RecyclableObject.Create <Damage>();
                damage.m_attacker_id         = attacker.ID;
                damage.m_defender_id         = current_target.ID;
                damage.m_damage_type         = m_damage_type_id;
                damage.m_damage_amount       = m_damage_amount.Evaluate(this);
                damage.m_damage_amount       = DamageSystem.Instance.CalculateDamageAmount(m_damage_type_id, damage.m_damage_amount, attacker, current_target);
                damage.m_render_effect_cfgid = m_damage_render_effect_cfgid;
                damage.m_sound_cfgid         = m_damage_sound_cfgid;
                damageable_component.TakeDamage(damage);
            }
            skill_component.CurrentTarget = null;
        }
Esempio n. 6
0
        public override void InitializeVariable(Dictionary <string, string> variables)
        {
            string value;

            if (variables.TryGetValue("count", out value))
            {
                m_count            = int.Parse(value);
                m_modefier_configs = new AttributeModifierConfig[m_count];
                Prepare(m_count);
            }
            for (int i = 0; i < m_count; ++i)
            {
                AttributeModifierConfig modifier = RecyclableObject.Create <AttributeModifierConfig>();
                m_modefier_configs[i] = modifier;
                if (variables.TryGetValue(m_attribute_name_key[i], out value))
                {
                    modifier.m_attribute_id = (int)CRC.Calculate(value);
                }
                if (variables.TryGetValue(m_attribute_category_key[i], out value))
                {
                    modifier.m_attribute_category = (int)CRC.Calculate(value);
                }
                if (variables.TryGetValue(m_value_key[i], out value))
                {
                    modifier.m_value.Compile(value);
                }
            }
        }
        public EntityGatheringRegion CreateRegion()
        {
            EntityGatheringRegion region = RecyclableObject.Create <EntityGatheringRegion>();

            region.PreConstruct(this);
            m_regions[region.ID] = region;
            return(region);
        }
Esempio n. 8
0
        void ApplyGenerator(EffectGenerator generator)
        {
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = ParentObject.ID;
            app_data.m_source_entity_id   = ParentObject.ID;
            generator.Activate(app_data, GetOwnerEntity());
            RecyclableObject.Recycle(app_data);
        }
Esempio n. 9
0
        public static SignalListenerContext CreateForBehaviorTree(int listener_id, int tree_id)
        {
            SignalListenerContext context = RecyclableObject.Create <SignalListenerContext>();

            context.m_context_type = SignalListenerContextType.BehaviorTree;
            context.m_listener_id  = listener_id;
            context.m_object_id    = tree_id;
            return(context);
        }
Esempio n. 10
0
        public void OnEntityBeKilled(Entity the_killer, Entity the_dead)
        {
            KillingInfo info = RecyclableObject.Create <KillingInfo>();

            info.m_the_killer = the_killer;
            info.m_the_dead   = the_dead;
            SendSignal(SignalType.EntityBeKilled, info);
            RecyclableObject.Recycle(info);
        }
Esempio n. 11
0
 public void CopyFrom(Formula rhs)
 {
     m_constant = rhs.m_constant;
     if (rhs.m_program != null)
     {
         m_program = RecyclableObject.Create <ExpressionProgram>();
         m_program.CopyFrom(rhs.m_program);
     }
 }
Esempio n. 12
0
        public void Impact()
        {
#if COMBAT_CLIENT
            if (m_render_effect_cfgid > 0)
            {
                if (m_remain_attack_cnt != m_combo_attack_cnt)
                {
                    PlayRenderEffectMessage stop_msg = RenderMessage.Create <PlayRenderEffectMessage>();
                    stop_msg.ConstructAsStop(GetOwnerEntityID(), m_render_effect_cfgid);
                    GetLogicWorld().AddRenderMessage(stop_msg);
                }
                PlayRenderEffectMessage start_msg = RenderMessage.Create <PlayRenderEffectMessage>();
                start_msg.ConstructAsPlay(GetOwnerEntityID(), m_render_effect_cfgid, FixPoint.MinusOne);
                GetLogicWorld().AddRenderMessage(start_msg);
            }
#endif
            --m_remain_attack_cnt;
            if (m_remain_attack_cnt <= 0)
            {
                if (m_combo_task != null)
                {
                    m_combo_task.Cancel();
                }
            }
            Skill skill = GetOwnerSkill();
            if (!skill.GetDefinitionComponent().NeedGatherTargets)
            {
                skill.BuildSkillTargets();
            }
            Entity        attacker    = GetOwnerEntity();
            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;
                }
                DamagableComponent damageable_component = m_current_target.GetComponent(DamagableComponent.ID) as DamagableComponent;
                if (damageable_component == null)
                {
                    continue;
                }
                Damage damage = RecyclableObject.Create <Damage>();
                damage.m_attacker_id         = attacker.ID;
                damage.m_defender_id         = m_current_target.ID;
                damage.m_damage_type         = m_damage_type_id;
                damage.m_damage_amount       = m_damage_amount.Evaluate(this);
                damage.m_damage_amount       = DamageSystem.Instance.CalculateDamageAmount(m_damage_type_id, damage.m_damage_amount, attacker, m_current_target);
                damage.m_render_effect_cfgid = m_damage_render_effect_cfgid;
                damage.m_sound_cfgid         = m_damage_sound_cfgid;
                damageable_component.TakeDamage(damage);
            }
            m_current_target = null;
        }
Esempio n. 13
0
        public static SignalListenerContext CreateForEffectComponent(int listener_id, int effect_id, int component_type_id)
        {
            SignalListenerContext context = RecyclableObject.Create <SignalListenerContext>();

            context.m_context_type      = SignalListenerContextType.EffectComponent;
            context.m_listener_id       = listener_id;
            context.m_object_id         = effect_id;
            context.m_component_type_id = component_type_id;
            return(context);
        }
Esempio n. 14
0
        int AddVariable(List <string> raw_variable)
        {
            ExpressionVariable variable = RecyclableObject.Create <ExpressionVariable>();

            variable.Construct(raw_variable);
            int index = m_variables.Count;

            m_variables.Add(variable);
            return(index);
        }
Esempio n. 15
0
        public void KillOwner(int killer_id)
        {
            //ZZWTODO Resurrect

            if (m_die_task != null)
            {
                m_die_task.Cancel();
            }
            LogicWorld logic_world = GetLogicWorld();

            Entity killer = logic_world.GetEntityManager().GetObject(killer_id);

            if (!DieSilently && killer_id != ParentObject.ID && m_killer_generator != null && killer != null)
            {
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = ParentObject.ID;
                app_data.m_source_entity_id   = ParentObject.ID;
                m_killer_generator.Activate(app_data, killer);
                RecyclableObject.Recycle(app_data);
            }

            var schedeler = logic_world.GetTaskScheduler();

            if (DieSilently)
            {
                logic_world.AddSimpleRenderMessage(RenderMessageType.Hide, ParentObject.ID);
            }
            else
            {
                HideEntityTask hide_task = LogicTask.Create <HideEntityTask>();
                hide_task.Construct(ParentObject.ID);
                schedeler.Schedule(hide_task, GetCurrentTime(), m_hide_delay);
            }

            ParentObject.DeletePending = true;
            ParentObject.SendSignal(SignalType.Die);
            logic_world.AddSimpleRenderMessage(RenderMessageType.Die, ParentObject.ID);

            StateComponent state_component = ParentObject.GetComponent(StateComponent.ID) as StateComponent;

            if (state_component != null)
            {
                state_component.AddState(StateSystem.DEAD_STATE, 0);
            }

            if (!m_can_resurrect)
            {
                DeleteEntityTask delete_task = LogicTask.Create <DeleteEntityTask>();
                delete_task.Construct(ParentObject.ID);
                schedeler.Schedule(delete_task, GetCurrentTime(), m_delete_delay);
            }

            logic_world.OnKillEntity(killer, GetOwnerEntity());
        }
Esempio n. 16
0
        protected override void OnActionUpdate(FixPoint delta_time)
        {
            if (m_program == null)
            {
                m_program = RecyclableObject.Create <ExpressionProgram>();
                m_program.Compile(m_context_value_expression);
            }
            FixPoint context_value = m_program.Evaluate(this);

            m_context.SetData(m_context_key, context_value);
        }
Esempio n. 17
0
 public void Construct(LogicWorld logic_world, int id, EffectGeneratorData data)
 {
     m_logic_world = logic_world;
     m_id          = id;
     m_data        = data;
     for (int i = 0; i < m_data.m_entries.Count; ++i)
     {
         EffectGeneratorEntry entry = RecyclableObject.Create <EffectGeneratorEntry>();
         entry.Construct(this, m_data.m_entries[i], i);
         m_entries.Add(entry);
     }
 }
Esempio n. 18
0
 public void BuildTargetList(ISpacePartition partition, Player player, Vector3FP position, Vector2FP facing, TargetGatheringParam param, List <Target> targets)
 {
     m_temp_targets.Clear();
     GatherGeneral(partition, player, position, facing, param, m_temp_targets);
     for (int i = 0; i < m_temp_targets.Count; ++i)
     {
         Target target = RecyclableObject.Create <Target>();
         target.Construct();
         target.SetEntityTarget(m_temp_targets[i]);
         targets.Add(target);
     }
     m_temp_targets.Clear();
 }
Esempio n. 19
0
 public void Construct(LogicWorld logic_world)
 {
     if (m_context == null)
     {
         BTContext context = RecyclableObject.Create <BTContext>();
         context.Construct(logic_world, this);
         SetContext(context);
     }
     if (m_task == null)
     {
         m_task = LogicTask.Create <BehaviorTreeTask>();
         m_task.Construct(this);
     }
 }
        public override void InitializeComponent()
        {
            if (m_mana_type == 0)
            {
                m_mana_type = ManaComponent.DEFAULT_MANA_TYPE_ID;
            }

            m_timers.Clear();
            for (int i = 0; i < SkillTimer.TimerCount; ++i)
            {
                SkillTimer timer = RecyclableObject.Create <SkillTimer>();
                m_timers.Add(timer);
            }
        }
Esempio n. 21
0
 public virtual bool Compile(string formula_string)
 {
     m_error_occurred = false;
     m_tokenizer      = RecyclableObject.Create <Tokenizer>();
     m_tokenizer.Construct(formula_string);
     m_token      = null;
     m_token_type = TokenType.ERROR;
     GetToken();
     ParseExpression();
     RecyclableObject.Recycle(m_tokenizer);
     m_tokenizer  = null;
     m_token      = null;
     m_token_type = TokenType.ERROR;
     m_raw_variable.Clear();
     return(!m_error_occurred);
 }
Esempio n. 22
0
 public void CopyFrom(ExpressionProgram rhs)
 {
     m_error_occurred = rhs.m_error_occurred;
     RecycleVariable();
     for (int i = 0; i < rhs.m_variables.Count; ++i)
     {
         ExpressionVariable variable = RecyclableObject.Create <ExpressionVariable>();
         variable.CopyFrom(rhs.m_variables[i]);
         m_variables.Add(variable);
     }
     m_instructions.Clear();
     for (int i = 0; i < rhs.m_instructions.Count; ++i)
     {
         m_instructions.Add(rhs.m_instructions[i]);
     }
 }
        void ApplyGenerator(Entity entity)
        {
            LogicWorld      logic_world = GetLogicWorld();
            EffectGenerator generator   = logic_world.GetEffectManager().GetGenerator(m_param.m_generator_id);

            if (generator == null)
            {
                return;
            }
            EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = m_param.m_source_entity_id;
            app_data.m_source_entity_id   = GetOwnerEntityID();
            generator.Activate(app_data, entity);
            RecyclableObject.Recycle(app_data);
        }
Esempio n. 24
0
 public bool MoveByDirection(Vector3FP direction)
 {
     if (!IsEnable())
     {
         return(false);
     }
     if (m_movement_provider as MovementByDirection == null)
     {
         ClearMovementProvider();
         m_movement_provider = RecyclableObject.Create <MovementByDirection>();
         m_movement_provider.SetCallback(this);
         m_movement_provider.SetMaxSpeed(m_current_max_speed);
     }
     m_movement_provider.MoveByDirection(direction);
     StartMoving();
     return(true);
 }
Esempio n. 25
0
 public bool MoveAlongPath(List <Vector3FP> path, bool from_command)
 {
     //不可以保存path
     if (!IsEnable())
     {
         return(false);
     }
     if (m_movement_provider as MovementAlongPath == null)
     {
         ClearMovementProvider();
         m_movement_provider = RecyclableObject.Create <MovementAlongPath>();
         m_movement_provider.SetCallback(this);
         m_movement_provider.SetMaxSpeed(m_current_max_speed);
     }
     m_movement_provider.MoveAlongPath(path);
     StartMoving(from_command);
     return(true);
 }
        protected override bool IsSatisfy()
        {
            if (m_program == null)
            {
                m_program = RecyclableObject.Create <ExpressionProgram>();
                m_program.Compile(m_expression);
            }
            FixPoint result = m_program.Evaluate(this);

            if (result != FixPoint.Zero)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 27
0
        int AddModifier(AttributeModifierConfig modifier_config, FixPoint modifier_value)
        {
            AttributeModifier attribute_modifier = RecyclableObject.Create <AttributeModifier>();

            attribute_modifier.Construct(GetLogicWorld().GetAttributeModifierIDGenerator().GenID(), modifier_config.m_attribute_category, modifier_value);

            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EntityManager             entity_manager       = GetLogicWorld().GetEntityManager();
            Entity    owner_entity = entity_manager.GetObject(definition_component.TargetEntityID);
            Attribute attribute    = EntityUtil.GetAttribute(owner_entity, modifier_config.m_attribute_id);

            if (attribute == null)
            {
                return(0);
            }
            attribute.AddModifier(attribute_modifier);
            return(attribute_modifier.ID);
        }
Esempio n. 28
0
        void ApplyOnce()
        {
            if (m_remain_count > 0)
            {
                --m_remain_count;
            }
            if (m_remain_count == 0)
            {
                CancelTask();
            }
            Entity owner = GetOwnerEntity();
            EffectDefinitionComponent definition_component = ((Effect)ParentObject).GetDefinitionComponent();
            EffectApplicationData     app_data             = RecyclableObject.Create <EffectApplicationData>();

            app_data.m_original_entity_id = definition_component.OriginalEntityID;
            app_data.m_source_entity_id   = owner.ID;
            m_generator.Activate(app_data, owner);
            RecyclableObject.Recycle(app_data);
        }
Esempio n. 29
0
        public bool Compile(string formula_string)
        {
            ExpressionProgram program = RecyclableObject.Create <ExpressionProgram>();

            if (!program.Compile(formula_string))
            {
                return(false);
            }
            if (program.IsConstant())
            {
                m_constant = program.Evaluate(null);
                m_program  = null;
                RecyclableObject.Recycle(program);
            }
            else
            {
                m_program = program;
            }
            return(true);
        }
Esempio n. 30
0
        void DetectCollision(ISpacePartition partition, Vector3FP position, FixPoint radius)
        {
            if (partition == null)
            {
                return;
            }
            SkillComponent           skill_component = m_context.GetData <SkillComponent>(BTContextKey.OwnerSkillComponent);
            Skill                    skill           = skill_component.GetOwnerSkill();
            List <PositionComponent> list            = partition.CollectEntity_SurroundingRing(position, radius, FixPoint.Zero, skill.GetOwnerEntityID());

            if (list.Count == 0)
            {
                return;
            }
            for (int i = 0; i < list.Count; ++i)
            {
                PositionComponent position_component = list[i];
                Entity            entity             = position_component.GetOwnerEntity();
                if (m_collided_targets.Contains(entity.ID))
                {
                    continue;
                }
                m_collided_targets.Add(entity.ID);
                if (position_component.Height <= FixPoint.Zero) //ZZWTODO
                {
                    continue;
                }
                if (!FactionRelation.IsFactionSatisfied(skill.GetOwnerPlayer().GetFaction(entity.GetOwnerPlayerID()), FactionRelation.NotAlly))
                {
                    continue;
                }
                Entity current_target = entity;
                skill_component.CurrentTarget = current_target;
                EffectApplicationData app_data = RecyclableObject.Create <EffectApplicationData>();
                app_data.m_original_entity_id = skill.GetOwnerEntityID();
                app_data.m_source_entity_id   = app_data.m_original_entity_id;
                m_collision_target_generator.Activate(app_data, entity);
                RecyclableObject.Recycle(app_data);
            }
            skill_component.CurrentTarget = null;
        }