Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Zliver
- {
- public class ResourceBuff extends Zliver.BuffZliver
- {
- public function ResourceBuff(arg1:String)
- {
- m_resourceModifiers = new Array();
- super(arg1);
- return;
- }
- protected function loadModifiersXML(arg1:XML):void
- {
- var loc3:*;
- loc3 = null;
- var loc4:*;
- loc4 = null;
- var loc1:*;
- loc1 = MULTIPLIER_SUFFIX.length;
- var loc2:*;
- loc2 = ADDITION_SUFFIX.length;
- var loc5:*;
- loc5 = 0;
- var loc6:*;
- loc6 = arg1.attributes();
- for each (loc3 in loc6)
- {
- if ((loc4 = loc3.name().toString()).substr(0 - loc1) == MULTIPLIER_SUFFIX)
- {
- setMultiplier(loc4.substr(0, loc4.length - loc1), Number(loc3));
- continue;
- }
- if (loc4.substr(0 - loc2) != ADDITION_SUFFIX)
- {
- continue;
- }
- setAddition(loc4.substr(0, loc4.length - loc2), Number(loc3));
- }
- return;
- }
- protected function restoreModifiers(arg1:Object):void
- {
- var loc1:*;
- loc1 = null;
- var loc2:*;
- loc2 = 0;
- var loc3:*;
- loc3 = arg1;
- for (loc1 in loc3)
- {
- m_resourceModifiers[loc1] = new Array();
- m_resourceModifiers[loc1]["addition"] = int(arg1[loc1].@addition);
- m_resourceModifiers[loc1]["multiplier"] = int(arg1[loc1].@multiplier);
- }
- return;
- }
- public function setMultiplier(arg1:String, arg2:Number):void
- {
- if (!(m_resourceModifiers[arg1] as Array))
- {
- m_resourceModifiers[arg1] = new Array();
- }
- m_resourceModifiers[arg1]["multiplier"] = arg2;
- return;
- }
- public override function resourceAdjustment(arg1:Object, arg2:Object):void
- {
- if (m_resourceModifiers[arg1.resourceName])
- {
- arg2.multiplier = arg2.multiplier + (m_resourceModifiers[arg1.resourceName]["multiplier"] ? m_resourceModifiers[arg1.resourceName]["multiplier"] : 0);
- arg2.addition = arg2.addition + (m_resourceModifiers[arg1.resourceName]["addition"] ? m_resourceModifiers[arg1.resourceName]["addition"] : 0);
- }
- return;
- }
- public function setAddition(arg1:String, arg2:Number):void
- {
- if (!(m_resourceModifiers[arg1] as Array))
- {
- m_resourceModifiers[arg1] = new Array();
- }
- m_resourceModifiers[arg1]["addition"] = arg2;
- return;
- }
- public static function createFromXML(arg1:XML):Zliver.ResourceBuff
- {
- var loc1:*;
- loc1 = new ResourceBuff(arg1.name);
- loc1.loadModifiersXML(arg1);
- return loc1;
- }
- public static function createFromName(arg1:String):Zliver.ResourceBuff
- {
- var buffXML:XML;
- var name:String;
- var loc1:*;
- buffXML = null;
- name = arg1;
- var loc3:*;
- loc3 = 0;
- var loc4:*;
- loc4 = Global.gameSettings.getXML().newBuffs.buff;
- var loc2:*;
- loc2 = new XMLList("");
- for each (loc3 in loc4)
- {
- if (loc3.@name == name)
- {
- buffXML = loc3;
- break;
- }
- }
- //buffXML = loc2[0];
- if (buffXML)
- {
- return createFromXML(buffXML);
- }
- return null;
- }
- public static function restoreCreate(arg1:Object):Zliver.ResourceBuff
- {
- var loc1:*;
- loc1 = new ResourceBuff(arg1.data.name);
- loc1.restoreModifiers(arg1.data.modifiers);
- return loc1;
- }
- protected static const ADDITION_SUFFIX:String="_addition";
- protected static const multLen:int=MULTIPLIER_SUFFIX.length;
- protected static const addLen:int=ADDITION_SUFFIX.length;
- protected static const MULTIPLIER_SUFFIX:String="_multiplier";
- protected var m_resourceModifiers:Array;
- }
- }
Add Comment
Please, Sign In to add comment