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 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); } }