Ejemplo n.º 1
0
        public FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (index == variable.MaxIndex)
            {
                if (vid == ExpressionVariable.VID_Value)
                {
                    return(Value);
                }
                else if (vid == ExpressionVariable.VID_BaseValue)
                {
                    return(BaseValue);
                }
                else
                {
                    return(ObjectUtil.GetVariable(m_owner_component.ParentObject, vid));
                }
            }
            else if (vid == ExpressionVariable.VID_LevelTable)
            {
                return(m_owner_component.GetLogicWorld().GetConfigProvider().GetLevelBasedNumber(variable[index + 1], ObjectUtil.GetLevel(m_owner_component.ParentObject)));
            }
            else if (vid == ExpressionVariable.VID_ModifierList)
            {
                ++index;
                vid = variable[index];
                return(GetModifierValueOfOneCategory(vid));
            }
            else
            {
                return(m_owner_component.GetVariable(variable, index));
            }
        }
Ejemplo n.º 2
0
        public FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (vid == ExpressionVariable.VID_Target)
            {
                if (m_current_target != null)
                {
                    return(m_current_target.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            else if (vid == ExpressionVariable.VID_Source)
            {
                if (m_current_source != null)
                {
                    return(m_current_source.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            else if (vid == ExpressionVariable.VID_BaseDamage)
            {
                return(m_current_basedamage);
            }
            return(FixPoint.Zero);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public List <int> BuildReferencedAttributes()
        {
            int count = 0;
            List <ExpressionVariable> variables = m_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;
                }
                else if (variable.MaxIndex >= 2 && variable[variable.MaxIndex - 2] == ExpressionVariable.VID_Attribute || variable.MaxIndex == 1)
                {
                    int attribute_id = variable[variable.MaxIndex - 1];
                    if (AttributeSystem.IsAttributeID(attribute_id))
                    {
                        m_referenced_attributes.Add(attribute_id);
                    }
                }
            }
            return(m_referenced_attributes);
        }
Ejemplo n.º 5
0
        public FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            if (m_context == null)
            {
                return(FixPoint.Zero);
            }
            int vid = variable[index];

            if (vid == ExpressionVariable.VID_BTContext)
            {
                if (index + 1 == variable.MaxIndex)
                {
                    return(m_context.GetData(variable[index + 1]));
                }
            }
            else
            {
                IExpressionVariableProvider provider = m_context.GetData <IExpressionVariableProvider>(BTContextKey.ExpressionVariableProvider);
                if (provider != null)
                {
                    return(provider.GetVariable(variable, index));
                }
            }
            return(FixPoint.Zero);
        }
Ejemplo n.º 6
0
        public FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (index == variable.MaxIndex)
            {
                if (vid == ExpressionVariable.VID_BaseDamage)
                {
                    return(m_value);
                }
            }
            else if (vid == ExpressionVariable.VID_Attacker)
            {
                if (m_attacker != null)
                {
                    return(m_attacker.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Defender)
            {
                if (m_defender != null)
                {
                    return(m_defender.GetVariable(variable, index + 1));
                }
            }
            return(FixPoint.Zero);
        }
Ejemplo n.º 7
0
        public override FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (vid == ExpressionVariable.VID_Target)
            {
                if (m_behavior_tree == null)
                {
                    return(FixPoint.Zero);
                }
                BTContext context = m_behavior_tree.Context;
                if (context == null)
                {
                    return(FixPoint.Zero);
                }
                int current_target_id = (int)(context.GetData(BTContextKey.CurrentTargetID));
                if (current_target_id <= 0)
                {
                    return(FixPoint.Zero);
                }
                Entity current_target = GetLogicWorld().GetEntityManager().GetObject(current_target_id);
                if (current_target == null)
                {
                    return(FixPoint.Zero);
                }
                return(current_target.GetVariable(variable, index + 1));
            }
            return(base.GetVariable(variable, index));
        }
Ejemplo n.º 8
0
        public override FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (vid == ExpressionVariable.VID_Target)
            {
                if (m_current_target != null)
                {
                    return(m_current_target.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            else if (vid == ExpressionVariable.VID_Source)
            {
                Object owner_entity = GetOwnerEntity();
                if (owner_entity != null)
                {
                    return(owner_entity.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            return(base.GetVariable(variable, index));
        }
Ejemplo n.º 9
0
 public void CopyFrom(ExpressionVariable rhs)
 {
     m_variable.Clear();
     for (int i = 0; i < rhs.m_variable.Count; ++i)
     {
         m_variable.Add(rhs.m_variable[i]);
     }
 }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public virtual FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (index == variable.MaxIndex)
            {
                FixPoint value;
                if (GetVariable(vid, out value))
                {
                    return(value);
                }
                else
                {
                    return(ObjectUtil.GetVariable(GetOwnerObject(), vid));
                }
            }
            else if (vid == ExpressionVariable.VID_LevelTable)
            {
                return(GetLogicWorld().GetConfigProvider().GetLevelBasedNumber(variable[index + 1], ObjectUtil.GetLevel(GetOwnerObject())));
            }
            else if (vid == ExpressionVariable.VID_Object)
            {
                Object owner_object = GetOwnerObject();
                if (owner_object != null)
                {
                    return(owner_object.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Entity)
            {
                Object owner_entity = GetOwnerEntity();
                if (owner_entity != null)
                {
                    return(owner_entity.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Player)
            {
                Object owner_player = GetOwnerPlayer();
                if (owner_player != null)
                {
                    return(owner_player.GetVariable(variable, index + 1));
                }
            }
            Object owner = GetOwnerObject();

            if (owner != null)
            {
                return(owner.GetVariable(variable, index));
            }
            else
            {
                return(FixPoint.Zero);
            }
        }
 public override FixPoint GetVariable(ExpressionVariable variable, int index)
 {
     if (index < variable.MaxIndex)
     {
         int       vid       = variable[index];
         Attribute attribute = GetAttributeByID(vid);
         if (attribute != null)
         {
             return(attribute.GetVariable(variable, index + 1));
         }
     }
     return(base.GetVariable(variable, index));
 }
Ejemplo n.º 13
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]);
     }
 }
Ejemplo n.º 14
0
        public override FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (vid == ExpressionVariable.VID_OriginalSource)
            {
                Entity original = GetLogicWorld().GetEntityManager().GetObject(((Effect)ParentObject).GetDefinitionComponent().OriginalEntityID);
                if (original != null)
                {
                    return(original.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            else if (vid == ExpressionVariable.VID_Source)
            {
                Entity source = GetLogicWorld().GetEntityManager().GetObject(((Effect)ParentObject).GetDefinitionComponent().SourceEntityID);
                if (source != null)
                {
                    return(source.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            else if (vid == ExpressionVariable.VID_Target)
            {
                Entity target = GetLogicWorld().GetEntityManager().GetObject(((Effect)ParentObject).GetDefinitionComponent().TargetEntityID);
                if (target != null)
                {
                    return(target.GetVariable(variable, index + 1));
                }
                else
                {
                    return(FixPoint.Zero);
                }
            }
            return(base.GetVariable(variable, index));
        }
Ejemplo n.º 15
0
 public override FixPoint GetVariable(ExpressionVariable variable, int index)
 {
     return(FixPoint.Zero);
 }
Ejemplo n.º 16
0
        public FixPoint GetVariable(ExpressionVariable variable, int index)
        {
            int vid = variable[index];

            if (index == variable.MaxIndex)
            {
                return(ObjectUtil.GetVariable(this, vid));
            }
            else if (vid == ExpressionVariable.VID_LevelTable)
            {
                return(GetLogicWorld().GetConfigProvider().GetLevelBasedNumber(variable[index + 1], ObjectUtil.GetLevel(this)));
            }
            else if (vid == ExpressionVariable.VID_Attribute)
            {
                AttributeManagerComponent cmp = GetComponent(AttributeManagerComponent.ID) as AttributeManagerComponent;
                if (cmp != null)
                {
                    return(cmp.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Object)
            {
                Object owner_object = GetOwnerObject();
                if (owner_object != null)
                {
                    return(owner_object.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Entity)
            {
                Object owner_entity = GetOwnerEntity();
                if (owner_entity != null)
                {
                    return(owner_entity.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Player)
            {
                Object owner_player = GetOwnerPlayer();
                if (owner_player != null)
                {
                    return(owner_player.GetVariable(variable, index + 1));
                }
            }
            else if (vid == ExpressionVariable.VID_Master)
            {
                Object master = GetOwnerEntity();
                SummonedEntityComponent summoned_component = GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;
                if (summoned_component != null)
                {
                    Entity entity = GetLogicWorld().GetEntityManager().GetObject(summoned_component.MasterID);
                    if (entity != null)
                    {
                        master = entity;
                    }
                }
                return(master.GetVariable(variable, index + 1));
            }
            else if (vid == ExpressionVariable.VID_UltimateMaster)
            {
                Object master = GetOwnerEntity();
                SummonedEntityComponent summoned_component = GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;
                while (summoned_component != null)
                {
                    Entity entity = GetLogicWorld().GetEntityManager().GetObject(summoned_component.MasterID);
                    if (entity == null)
                    {
                        break;
                    }
                    master             = entity;
                    summoned_component = entity.GetComponent(SummonedEntityComponent.ID) as SummonedEntityComponent;
                }
                return(master.GetVariable(variable, index + 1));
            }
            Object owner = GetOwnerObject();

            if (owner != null)
            {
                return(owner.GetVariable(variable, index));
            }
            else
            {
                return(FixPoint.Zero);
            }
        }