Package transientlibs.bindedobjects.core

Source Code of transientlibs.bindedobjects.core.Activator

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.bindedobjects.core;

import transientlibs.bindedobjects.gamecontent.Group;
import transientlibs.objects.creatures.items.Item;
import transientlibs.objects.primitives.MathOperator;
import transientlibs.objects.general.Node;
import transientlibs.tex.ActList;
import transientlibs.tex.StoryPoint;
import transientlibs.tex.StringAnalyst;
import transientlibs.bindedobjects.core.Binding;
import static transientlibs.bindedobjects.core.Activator.groupActivator;
import transientlibs.processors.tex.AbstractActivator;
import transientlibs.processors.misc.Detonator;
import transientlibs.maps.entities.Landmark;
import transientlibs.maps.implementation.BasicMap;
import transientlibs.preui.objects.gui.interfaces.IMarker;
import transientlibs.objects.primitives.IntSlot;
import transientlibs.slick2d.util.Log;

/**
*
* @author kibertoad
*/
public class Activator extends Node implements AbstractActivator {

    public final static int skillActivator = 1;
    public final static int valueActivator = 55;
    public final static int globalValueActivator = 3;
    public final static int stateTransitionActivator = 4;
    public final static int triggerActivator = 5;
    public final static int globalTriggerActivator = 6;
    public final static int techActivator = 7;
    public final static int storyActivator = 8;
    public final static int branchActivator = 9;
    public final static int missionActivator = 10;
    public final static int rngActivator = 11;
    public final static int eventActivator = 12;
    public final static int endGameActivator = 13;
    public final static int globalRngActivator = 14;
    public final static int soundActivator = 15;
    public final static int musicActivator = 16;
    public final static int terrainActivator = 17;
    public final static int effectMapMarkerActivator = 18; //set by map coords
    public final static int quitActivator = 19;
    public final static int placeItemActivator = 20;
    public final static int activeTileEffectActivator = 21; //set by active unit
    public final static int takeItemActivator = 22; //set by active unit
    public final static int placeCreatureActivator = 23;
    public final static int mapActivator = 24;
    public final static int moveActivator = 25;
    public final static int velocityActivator = 26;
    public final static int shootMissileActivator = 27;
    public final static int damageActivator = 28;
    public final static int healActivator = 29;
    public final static int directionActivator = 30;
    public final static int imageActivator = 31;

    public final static int toggleElementActivator = 32;
    public final static int moveElementActivator = 33;
    public final static int hideAllActivator = 34;
    public final static int placeLandmarkActivator = 35;

    public final static int musicVolumeActivator = 36;
    public final static int soundVolumeActivator = 37;

    public final static int setWinActivator = 38;
    public final static int setLossActivator = 39;

    public final static int groupActivator = 40;
    public final static int storyOverlayActivator = 41;
    public final static int moveByDeltaActivator = 42;

    boolean sign;
    int value;
    int value2;
    IntSlot linkedValue = null;
    IntSlot linkedValue2 = null;
    IntSlot linkedValue3 = null;
    MathOperator operator = null;

    public Activator(int setType, int setID, int setValue, int setValue2, boolean setSign) {
        ofType = setType;
        ID = setID;
        sign = setSign;
        value = setValue;
        value2 = setValue2;
    }

    public Activator(int setType, int setID, IntSlot setValue, MathOperator setOperator) {
        ofType = setType;
        ID = setID;

        linkedValue = setValue;

        operator = setOperator;
    }

    public Activator(int setType, int setID, IntSlot setValue, IntSlot setValue2, MathOperator setOperator) {

        ofType = setType;
        ID = setID;

        linkedValue = setValue;
        linkedValue2 = setValue2;

        operator = setOperator;
    }

    public Activator(int setType, IntSlot setValue, IntSlot setValue2, IntSlot setValue3, MathOperator setOperator) {

        ofType = setType;
        ID = -1;

        linkedValue = setValue;
        linkedValue2 = setValue2;
        linkedValue3 = setValue3;

        operator = setOperator;
    }

    public Activator(int setType, int setID, int setValue, boolean setSign) {
        ofType = setType;
        ID = setID;
        sign = setSign;
        value = setValue;
        value2 = 0;
    }

    public Activator(int setType, int setID, boolean setSign) {
        ofType = setType;
        ID = setID;
        sign = setSign;
        value = 0;
        value2 = 0;
    }

    @Override
    public void process() {

        if (ofType == setWinActivator) {
            Detonator.INSTANCE.storyOnWin = ID;
        }

        if (ofType == setLossActivator) {
            Detonator.INSTANCE.storyOnLoss = ID;
        }

        if (ofType == groupActivator) {
            Detonator.INSTANCE.encounteredGroups.add(Group.getGroupByID(ID));
        }

        if (ofType == storyOverlayActivator) {
            Detonator.INSTANCE.storyOverlay.toggle();
        }
       

        if (ofType == directionActivator) {

            if (Detonator.INSTANCE.activeUnit != null) {
                Detonator.INSTANCE.activeUnit.setDirection (ID);
            }

        }


        if (ofType == damageActivator) {

            if (Detonator.INSTANCE.activeUnit != null) {
                Detonator.INSTANCE.activeUnit.getDamage(ID);
            }

        }

        if (ofType == healActivator) {

            if (Detonator.INSTANCE.activeUnit != null) {
                Detonator.INSTANCE.activeUnit.getHealing(ID);
            }

        }



        if (ofType == skillActivator) {

            if (Detonator.INSTANCE.reqCreature != null) {

                if (sign) {
                    Detonator.INSTANCE.reqCreature.skills.get(ID).increase(value);
                } else {
                    Detonator.INSTANCE.reqCreature.skills.get(ID).decrease(value);
                }

            }
        }


        if (ofType == techActivator) {
            Detonator.INSTANCE.techResearched.get(ID).value = sign;
        }

        if (ofType == takeItemActivator) {

            //if (!(Detonator.instance.activeUnit.currentTile().items.items.isEmpty())) {
            if (Detonator.INSTANCE.activeUnit.getActionTarget() != null) {
                Detonator.INSTANCE.activeUnit.getInventory().passItem((Item) (Detonator.INSTANCE.activeUnit.getActionTarget()));
                Detonator.INSTANCE.activeUnit.currentTile().items.items.remove((Item) (Detonator.INSTANCE.activeUnit.getActionTarget()));
            }



        }

        if (ofType == shootMissileActivator) {
            Detonator.INSTANCE.creatureFactory.produceBullet

                    (Detonator.INSTANCE.activeUnit.getCreatures().shootingDamage.value, ID, Detonator.INSTANCE.activeUnit.getMapCoords().getIntX(),
                    Detonator.INSTANCE.activeUnit.getMapCoords().getIntY(),

                    Detonator.INSTANCE.activeUnit.multiplyVectorByDirection(value).x, Detonator.INSTANCE.activeUnit.multiplyVectorByDirection(value).y,

                    Detonator.INSTANCE.activeUnit.getSide().value, Detonator.INSTANCE.currentMap);
        }



        if (ofType == soundVolumeActivator) {
            //Sounds.setVolume(ID);
            Detonator.INSTANCE.musicPlayer.setSoundVolume (ID);
        }

        if (ofType == musicVolumeActivator) {
            //MusicTrack.setVolume(ID);
            Detonator.INSTANCE.musicPlayer.setMusicVolume (ID);
        }


        if (ofType == moveActivator) {
            //if (Detonator.instance.activeUnit. != null) {

            Detonator.INSTANCE.activeUnit.performMove(Detonator.INSTANCE.activeUnit.multiplyVectorByDirection(ID).x / 1000, Detonator.INSTANCE.activeUnit.multiplyVectorByDirection(ID).y / 1000);
            //}
        }

        if (ofType == moveByDeltaActivator) {
            //if (Detonator.instance.activeUnit. != null) {

            Detonator.INSTANCE.activeUnit.performMove(ID, value);
            //}
        }
       
       
        if (ofType == velocityActivator) {

            Detonator.INSTANCE.activeUnit.getVerticalVelocity().value = Detonator.INSTANCE.activeUnit.getVerticalVelocity().value + ID ;

            //Log.info("velocity: "+Detonator.instance.activeUnit.verticalVelocity.value);
        }


        if (ofType == triggerActivator) {
            Detonator.INSTANCE.localTriggers.get(ID).referencedBoolean.value = sign;
        }

        if (ofType == globalTriggerActivator) {
            Detonator.INSTANCE.getBindedTrigger(ID).value = sign;
        }

        if (ofType == missionActivator) {
            Detonator.INSTANCE.missionAvailable.get(ID).value = sign;
        }

        if (ofType == soundActivator) {
            //Sounds.play(Sounds.getSoundByID(ID));
            Detonator.INSTANCE.musicPlayer.playSound(ID);
        }

        if (ofType == musicActivator) {
            //MusicTrack.play(MusicTrack.getMusicByID(ID));
            Detonator.INSTANCE.musicPlayer.playMusic(ID);
        }

        if (ofType == rngActivator) {
            //Log.info("Process RNG activator!");
            Detonator.INSTANCE.localVars.get(ID).referencedInt.value = Detonator.INSTANCE.rng.nextInt(value2 - value) + value;
        }

        if (ofType == globalRngActivator) {
            //Log.info("Process RNG activator!");
            Detonator.INSTANCE.vars.get(ID).referencedInt.value = Detonator.INSTANCE.rng.nextInt(value2 - value) + value;
        }



        if (ofType == valueActivator) {

            //Log.info("blast the value: "+linkedValue.referencedInt);

            //linkedValue -> to what value
            //linkedvalue2 -> what value
            //ID - primitive value
            //operator -> operation to perform
           
            if (linkedValue3 != null) {
                operator.process(linkedValue.referencedInt, linkedValue2.referencedInt, linkedValue3.referencedInt);
            } else if ((linkedValue2 != null) && (ID != -1)) {

                //Log.info("LV1:"+linkedValue.value);
                //Log.info("LV2:"+linkedValue2.value);
                //Log.info("ID:"+ID);

                operator.process(linkedValue.referencedInt, linkedValue2.referencedInt, ID);
            } else if (ID != -1) {
                operator.process(linkedValue.referencedInt, ID);
            }
            else {linkedValue.referencedInt.value = linkedValue2.referencedInt.value;} //value = value
        }






        if (ofType == activeTileEffectActivator) {

            if (sign == true) {
                Detonator.INSTANCE.activeUnit.currentTile().addEffect(ID, Detonator.INSTANCE.getBindedLocalValue(value).value);
            } else {
                Detonator.INSTANCE.activeUnit.currentTile().removeEffect(ID, Detonator.INSTANCE.getBindedLocalValue(value).value);
            }
        }


        if (ofType == quitActivator) {
            //QuitState.quitProtocol();
            Detonator.INSTANCE.currentGenericGame.changeState("quit");
        }


        if (ofType == stateTransitionActivator) {

            if (ID == 0) {
                Log.error("Unknown state");
            }

            Detonator.INSTANCE.SwitchStateDetonator = ID;
        }

        if (ofType == effectMapMarkerActivator) {
            if (sign == true) {
                Detonator.INSTANCE.currentMap.getTile(value, value2).addEffect(ID);
            } else {
                Detonator.INSTANCE.currentMap.getTile(value, value2).removeEffect(ID);
            }
            Log.debug("adding effect: " + ID);
        }

        if (ofType == terrainActivator) {
            Detonator.INSTANCE.currentMap.getTile(value, value2).changeTerrain(ID);
        }

        if (ofType == placeItemActivator) {
            Detonator.INSTANCE.creatureFactory.produceItem(ID, value, value2, (BasicMap)Detonator.INSTANCE.currentMap);
            //Maps.currentMap.tile[value][value2].items.addItemByID(ID);
            Log.debug("adding item: " + ID);
        }

        if (ofType == placeCreatureActivator) {
            //Maps.currentMap.tile[value][value2].c.addItemByID(ID);

            if (Detonator.INSTANCE.currentMap == null) {
                Log.error("Trying to place unit on null map!");
            }

            Detonator.INSTANCE.creatureFactory.produceUnit(ID, value, value2, Detonator.INSTANCE.currentMap);

            //Log.debug("adding item: " + ID);
        }

        if (ofType == placeLandmarkActivator) {
            //Log.info("EXPLODE "+ID);
            Landmark newLandmark = Detonator.INSTANCE.creatureFactory.produceLandmark(ID, value, value2, Detonator.INSTANCE.currentMap);
            newLandmark.bindValues();
        }




        if (ofType == storyActivator) {
            //Detonator.instance.switchStoryDetonator = ID;

            //Log.info("Story activator processed! ID"+ID);

            //GolemPhase.addPhase(GolemPhase.storyPhase, ID, -1);

            StoryPoint.queueStory(ID);
        }

        if (ofType == branchActivator) {

            //Log.debug("Branch switch detonator activated: " + ID);

            Detonator.INSTANCE.switchBranchDetonator = ID;
        }


        if (ofType == imageActivator) {
            //Detonator.INSTANCE.interfaceElementList.get(ID).setImage(Images.getImageByID(value));
            Detonator.INSTANCE.getGlobalInterfaceElement(ID).setBothImages(Detonator.INSTANCE.imageProvider.getImage(value));
           
            //Log.warn("element: "+Detonator.INSTANCE.getGlobalInterfaceElement(ID).getStringID());
            //Log.warn("picture: "+Detonator.INSTANCE.imageProvider.getImage(value).getName());
           
            //Log.warn("IMAGE POWA");

            //Log.info("Element: "+ID);
        }

        if (ofType == moveElementActivator) {
            Detonator.INSTANCE.interfaceElementList.get(ID).moveMarker(value, value2);
        }

        if (ofType == toggleElementActivator) {
            Detonator.INSTANCE.getGlobalInterfaceElement(ID).setIsDrawn (sign);
           
            //Log.warn("Element "+Detonator.INSTANCE.getGlobalInterfaceElement(ID).getStringID()+" is now "+Detonator.INSTANCE.getGlobalInterfaceElement(ID).isDrawn());
        }

        if (ofType == hideAllActivator) {
            //Log.info("CLEAR ALL");
            Log.notImplemented();
            //for (IMarker m : Detonator.INSTANCE.currentGenericGame.getStoryState().imagePoints) {
            //    m.setIsDrawn (false);
                //Log.info("disabled!");
            //}
        }



        if (ofType == eventActivator) {
            //Log.debug("Process event activator!");

            StoryPoint.storeNewStory(ID, -1, StoryPoint.Story_Type);

            Detonator.INSTANCE.switchStoryDetonator = StoryPoint.currentPoint.ID;

        }

        if (ofType == endGameActivator) {
            //System.exit(0);
            if (Detonator.INSTANCE.useGDXImages == false) {
            //Detonator.INSTANCE.currentGame.enterState(Detonator.INSTANCE.currentGenericGame.getQuitStateID());
                Detonator.INSTANCE.currentGenericGame.changeState(Detonator.INSTANCE.currentGenericGame.getQuitStateID());
            } else {
            Detonator.INSTANCE.currentTransientGame.changeState(Detonator.INSTANCE.currentGenericGame.getQuitStateID());   
            }
        }

        if (ofType == mapActivator) {

            Detonator.INSTANCE.SwitchStateDetonator = Detonator.INSTANCE.StoredTiledMapStateID;

            BasicMap.selectMap(ID);

            //you shouldn't load the same map twice, so if you get crash here, implement check "is it loaded yet?"
            //Maps.loadMap(ID);
        }


    }

    public static void analyzeStringForActs(StringAnalyst analyst) {
        analyzeStringForActs("-NO-", analyst);
    }

    public static boolean analyzeStringForActs(String getString, StringAnalyst analyst) {

        if (!"-NO-".equals(getString)) {
            analyst.loadNewString(getString);
        }

        analyst.getNextString();
        String nowStr = analyst.lastStr;
        boolean withResult = false;


        int setID;
        int setValue;
        int setValue2;

        //Log.info("Start act analysis");
        //Log.info("String to analyse: "+nowStr);



        if (nowStr.equals("v")) {

            //Main variable
            IntSlot setInt = analyst.getNextBindedValue();

            //=
            MathOperator mainOperator = analyst.getNextMathOperator();

            //If next is bindedValue, get it
            if (!(analyst.checkIfNextIsNumber())) {
                IntSlot setInt2 = analyst.getNextBindedValue();


           //if is bindedValue, get an operation to perform with it
                MathOperator operator = analyst.getNextMathOperator();

                //Int setInt3 = analyst.getNextBindedValue();


                if (!(analyst.checkIfNextIsNumber())) {

                    IntSlot setInt3;

                    if (operator != null) {setInt3 = analyst.getNextBindedValue();} else {setInt3 = null;}
                    //ReqList.lastReqList.add(new Req(valueReq2, setInt, setInt2, comp, true));
                    ActList.lastActList.add(new Activator(valueActivator, setInt, setInt2, setInt3, operator));
                } else {
                    setValue = analyst.getNextNumber();
                    //ReqList.lastReqList.add(new Req(valueReq2, setValue, setInt, comp, true));
                    ActList.lastActList.add(new Activator(valueActivator, setValue, setInt, setInt2, operator));


                }

            } else //you only set variable here
            {
                setValue = analyst.getNextNumber();

                ActList.lastActList.add(new Activator(valueActivator, setValue, setInt, mainOperator));
            }



            withResult = true;
        }

        if (nowStr.equals("damage")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(damageActivator, setValue, true));

            withResult = true;
        }



   if (nowStr.equals("moveelement")) {

       setID = Binding.getBinding(Binding.interfaceElementBinding, analyst.getNextString());
       int value = analyst.getNextNumber();
       int value2 = analyst.getNextNumber();

       ActList.lastActList.add(new Activator(moveElementActivator, setID, value, value2, true));

                withResult = true;
   }

   if (nowStr.equals("showelement")) {
       setID = Binding.getBinding(Binding.globalInterfaceElementBinding, analyst.getNextString());

       ActList.lastActList.add(new Activator(toggleElementActivator, setID, true));

       withResult = true;
   }

   if (nowStr.equals("hideelement")) {
       setID = Binding.getBinding(Binding.globalInterfaceElementBinding, analyst.getNextString());

       ActList.lastActList.add(new Activator(toggleElementActivator, setID, false));

       withResult = true;
   }

      if (nowStr.equals("clearscene")) {
       ActList.lastActList.add(new Activator(hideAllActivator, -1, false));

       withResult = true;
      }


      if (nowStr.equals("setwinstory")) {

       setValue = analyst.getBinding(Binding.storyBinding);
       ActList.lastActList.add(new Activator(setWinActivator, setValue, true));

       withResult = true;
      }


      if (nowStr.equals("setlossstory")) {

       setValue = analyst.getBinding(Binding.storyBinding);
       ActList.lastActList.add(new Activator(setLossActivator, setValue, true));

       withResult = true;
      }



   if (nowStr.equals("storyoverlay")) {
            ActList.lastActList.add(new Activator(storyOverlayActivator, -1, -1, true));

            withResult = true;     
   }
     
   if (nowStr.equals("setimage")) {

            String elementID = analyst.getNextString();
            int setPoint = Binding.getBinding(Binding.globalInterfaceElementBinding, elementID);
            String imageID = analyst.getNextString();
            //setID = Binding.getBinding(Binding.transientImageBinding, imageID);
            setID = Binding.getBinding(Binding.transientImageBinding, imageID);

            ActList.lastActList.add(new Activator(imageActivator, setPoint, setID, true));

            withResult = true;
        }     
     
   if (nowStr.equals("setimageLEGACY")) {

            String elementID = analyst.getNextString();
            int setPoint = Binding.getBinding(Binding.interfaceElementBinding, elementID);
            String imageID = analyst.getNextString();
            setID = Binding.getBinding(Binding.transientImageBinding, imageID);

            //Log.info("ElementID: "+elementID);
            //Log.info("ImageID: "+imageID);


            ActList.lastActList.add(new Activator(imageActivator, setPoint, setID, true));

            //StoryState.getImagePoint(setPoint).setImage(Images.getImageByID(setID));

            withResult = true;
        }

        if (nowStr.equals("setdirection")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(directionActivator, setValue, true));

            withResult = true;
        }


        if (nowStr.equals("heal")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(healActivator, setValue, true));

            withResult = true;
        }


        if (nowStr.equals("shootmissile")) {

            int setVectorSize = analyst.getNextNumber();

            int setType = analyst.getBinding(Binding.missileBinding);

            ActList.lastActList.add(new Activator(shootMissileActivator, setType, setVectorSize, true));

            withResult = true;
        }

        if (nowStr.equals("group")) {
            setID = analyst.getBinding(Binding.groupBinding);

            ActList.lastActList.add(new Activator(groupActivator, setID, true));

            withResult = true;
        }

        if (nowStr.equals("setterrain")) {

            int setX = analyst.getNextNumber();
            int setY = analyst.getNextNumber();

            setID = analyst.getBinding(Binding.terrainBinding);

            ActList.lastActList.add(new Activator(terrainActivator, setID, setX, setY, true));

            withResult = true;

        }


        if (nowStr.equals("effect+")) {
            setID = analyst.getBinding(Binding.effectBinding);
            setValue = analyst.getBinding(Binding.valueBinding);

            ActList.lastActList.add(new Activator(activeTileEffectActivator, setID, setValue, true));

            withResult = true;
        }

        if (nowStr.equals("effect-")) {
            setID = analyst.getBinding(Binding.effectBinding);
            setValue = analyst.getBinding(Binding.valueBinding);

            ActList.lastActList.add(new Activator(activeTileEffectActivator, setID, setValue, false));

            withResult = true;
        }



        if (nowStr.equals("addmarker")) {

            int setX = analyst.getNextNumber();
            int setY = analyst.getNextNumber();

            setID = analyst.getBinding(Binding.effectBinding);

            ActList.lastActList.add(new Activator(effectMapMarkerActivator, setID, setX, setY, true));

            withResult = true;

        }


        if (nowStr.equals("map")) {
            ActList.lastActList.add(new Activator(mapActivator, analyst.getBinding(Binding.mapBinding), true));
            withResult = true;
        }

        if (nowStr.equals("takeitem")) {
            ActList.lastActList.add(new Activator(takeItemActivator, -1, true));
            withResult = true;
        }

        if (nowStr.equals("placeitem")) {

            int setX = analyst.getNextNumber();
            int setY = analyst.getNextNumber();

            setID = analyst.getBinding(Binding.itemBinding);

            ActList.lastActList.add(new Activator(placeItemActivator, setID, setX, setY, true));

            withResult = true;

        }


         if (nowStr.equals("spawnlandmark")) {
            int setX = analyst.getNextNumber();
            int setY = analyst.getNextNumber();

            setID = analyst.getBinding(Binding.landmarkBinding);


            ActList.lastActList.add(new Activator(placeLandmarkActivator, setID, setX, setY, true));

            withResult = true;
         }



        if (nowStr.equals("spawncreature")) {

            int setX = analyst.getNextNumber();
            int setY = analyst.getNextNumber();

            setID = analyst.getBinding(Binding.creatureBinding);

            ActList.lastActList.add(new Activator(placeCreatureActivator, setID, setX, setY, true));

            withResult = true;
        }





        if (nowStr.equals("processtex"))  {
            //Log.debug("add tex processing");
           
            Log.warn("PROCESSTEX GOT DONE");
           
            String setString = analyst.restOfRow();

            ActList.lastActList.add(new StringActivator(StringActivator.texProcessorActivator, -1, setString));

            withResult = true;

        }
       
        if (nowStr.equals("skillroll"))  {
            //Log.debug("add tex processing");
           
            Log.warn("PROCESSSKILL GOT DONE");
           
            String setString = analyst.restOfRow();

            ActList.lastActList.add(new StringActivator(StringActivator.skillProcessorActivator, -1, setString));
           
            //Log.warn("Added skillroll to: "+ActList.lastActList.hostID);

            withResult = true;

        }       

        if ((nowStr.equals("string")) || (nowStr.equals("s"))) {
            setID = analyst.getBinding(Binding.stringBinding);
            String setString = analyst.restOfRow();

            ActList.lastActList.add(new StringActivator(StringActivator.assignStringActivator, setID, setString));

            withResult = true;
        }


        if ((nowStr.equals("t+")) || (nowStr.equals("trigger"))) {

            analyst.getNextString();

        if ((analyst.lastStr.charAt(0) == 'l') && (analyst.lastStr.charAt(1) == '_')) {
                        ActList.lastActList.add(new Activator(triggerActivator, Binding.getBinding(Binding.localTriggerBinding, analyst.lastStr), true));
        } else {
            ActList.lastActList.add(new Activator(globalTriggerActivator, Binding.getBinding(Binding.globalTriggerBinding, analyst.lastStr), true));
        }


            withResult = true;
        }



        if (nowStr.equals("t-")) {
            analyst.getNextString();

        if ((analyst.lastStr.charAt(0) == 'l') && (analyst.lastStr.charAt(1) == '_')) {
                        ActList.lastActList.add(new Activator(triggerActivator, Binding.getBinding(Binding.localTriggerBinding, analyst.lastStr), false));
        } else {
            ActList.lastActList.add(new Activator(globalTriggerActivator, Binding.getBinding(Binding.globalTriggerBinding, analyst.lastStr), false));
        }
            withResult = true;
        }



        if (nowStr.equals("q+")) {
            setID = analyst.getBinding(Binding.missionBinding);
            ActList.lastActList.add(new Activator(missionActivator, setID, true));

            withResult = true;
        }

        if (nowStr.equals("q-")) {
            setID = analyst.getBinding(Binding.missionBinding);
            ActList.lastActList.add(new Activator(missionActivator, setID, false));

            withResult = true;
        }


        if (nowStr.equals("jump")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(velocityActivator, setValue, true));

            withResult = true;
        }

        if (nowStr.equals("move")) {
            setValue = analyst.getNextNumber();


            ActList.lastActList.add(new Activator(moveActivator, setValue, true));

            withResult = true;
        }

       
        if (nowStr.equals("moveunitbydelta")) {
            setValue  = analyst.getNextNumber();
            setValue2 = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(moveByDeltaActivator, setValue, setValue2, true));

            withResult = true;
        }
       
       

        if (nowStr.equals("rng")) {

            setID = analyst.getBinding(Binding.valueBinding);
            setValue = analyst.getNextNumber();
            setValue2 = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(rngActivator, setID, setValue, setValue2, false));

            withResult = true;
        }

        if (nowStr.equals("grng")) {

            setID = analyst.getBinding(Binding.globalValueBinding);
            setValue = analyst.getNextNumber();
            setValue2 = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(globalRngActivator, setID, setValue, setValue2, false));

            withResult = true;
        }




        if (nowStr.equals("event")) {
            setID = analyst.getBinding(Binding.storyBinding);

            //Log.info("Added new event");

            //Log.info("Actlist size pre: " + ActList.lastActList.size());
            ActList.lastActList.add(new Activator(eventActivator, setID, true));
            //Log.info("Actlist size post: " + ActList.lastActList.size());

            withResult = true;
        }

        if ((nowStr.equals("sw")) || (nowStr.equals("switchbranch")) ||
                (nowStr.equals("setbranch"))) {
            setID = analyst.getBinding(Binding.branchBinding);
            ActList.lastActList.add(new Activator(branchActivator, setID, true));

            withResult = true;
        }

        if (nowStr.equals("state")) {
            setID = analyst.getBinding(Binding.stateBinding);
            if (setID == 0) {Log.error("Unknown state: "+analyst.lastStr);
            }

            //addStateTransition (setID);
            ActList.lastActList.add(new Activator(stateTransitionActivator, setID, true));
            withResult = true;
        }



        if (nowStr.equals("quit")) {
            ActList.lastActList.add(new Activator(quitActivator, -1, true));

            withResult = true;
        }

        if (nowStr.equals("sound")) {
            setID = analyst.getBinding(Binding.soundBinding);

            ActList.lastActList.add(new Activator(soundActivator, setID, true));
            withResult = true;
        }


        if (nowStr.equals("music")) {
            setID = analyst.getBinding(Binding.musicBinding);

            ActList.lastActList.add(new Activator(musicActivator, setID, true));
            withResult = true;
        }




        if (nowStr.equals("skill+")) {
            setID = analyst.getBinding(Binding.skillBinding);
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(skillActivator, setID, setValue, true));
            withResult = true;
        }


        if (nowStr.equals("musicvolume")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(musicVolumeActivator, setValue, true));
            withResult = true;
        }

        if (nowStr.equals("soundvolume")) {
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(soundVolumeActivator, setValue, true));
            withResult = true;
        }



        if (nowStr.equals("skill-")) {
            setID = analyst.getBinding(Binding.skillBinding);
            setValue = analyst.getNextNumber();

            ActList.lastActList.add(new Activator(skillActivator, setID, setValue, false));
            withResult = true;
        }


        if (nowStr.equals("tech+")) {
            setID = analyst.getBinding(Binding.techBinding);

            //addStateTransition (setID);
            ActList.lastActList.add(new Activator(techActivator, setID, true));
            withResult = true;
        }

        if (nowStr.equals("tech-")) {
            setID = analyst.getBinding(Binding.techBinding);

            //addStateTransition (setID);
            ActList.lastActList.add(new Activator(techActivator, setID, false));
            withResult = true;
        }


        if (nowStr.equals("endgame")) {
            ActList.lastActList.add(new Activator(endGameActivator, -1, false));
            withResult = true;
        }


        return withResult;

    }
//    public static void addStateTransition (int toState) {
//        ActList.lastActList.add(new Activator(stateTransitionActivator, toState, true));
//    }

    @Override
    public int getID() {
        return ID;
    }
}
TOP

Related Classes of transientlibs.bindedobjects.core.Activator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.