Advertisement
Chiddix

ActorDefinition

Mar 16th, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 15.99 KB | None | 0 0
  1. package com.runescape.cache.parser;
  2.  
  3. /**
  4.  * Represents an actor.
  5.  */
  6. public final class ActorDefinition {
  7.  
  8.     /**
  9.      * The actor definitions.
  10.      */
  11.     private static ActorDefinition[] definitions;
  12.    
  13.     /**
  14.      * Initializes the class with the specified set of definitions.
  15.      * @param definitions The definitions.
  16.      * @throws RuntimeException if there is an id mismatch.
  17.      */
  18.     public static void init(ActorDefinition[] definitions) {
  19.         ActorDefinition.definitions = definitions;
  20.         for (int id = 0; id < definitions.length; id++) {
  21.             ActorDefinition def = definitions[id];
  22.             if (def.getId() != id) {
  23.                 throw new RuntimeException("Actor definition id mismatch!");
  24.             }
  25.         }
  26.     }
  27.    
  28.     /**
  29.      * Gets the total number of actors.
  30.      * @return The total number of actors.
  31.      */
  32.     public static int count() {
  33.         return definitions.length;
  34.     }
  35.    
  36.     /**
  37.      * Gets the actor definition for the specified id.
  38.      * @param id The id.
  39.      * @return The definition.
  40.      * @throws IndexOutOfBoundsException if the id is out of bounds.
  41.      */
  42.     public static ActorDefinition forId(int id) {
  43.         if (id < 0 || id >= definitions.length) {
  44.             throw new IndexOutOfBoundsException();
  45.         }
  46.         return definitions[id];
  47.     }
  48.    
  49.     /**
  50.      * The actor's id.
  51.      */
  52.     private final int id;
  53.  
  54.     /**
  55.      * The model id's of the actor.
  56.      */
  57.     private int[] modelIds;
  58.    
  59.     /**
  60.      * The name of the actor.
  61.      */
  62.     private String name;
  63.  
  64.     /**
  65.      * The description of the actor.
  66.      */
  67.     private String description;
  68.    
  69.     /**
  70.      * The actor's size.
  71.      */
  72.     private int size = -1;
  73.    
  74.     /**
  75.      * The actor's stand animation id.
  76.      */
  77.     private int standAnimationId = -1;
  78.    
  79.     /**
  80.      * The actor's walk animation id.
  81.      */
  82.     private int walkAnimationId = -1;
  83.    
  84.     /**
  85.      * The actor's turn around animation id.
  86.      */
  87.     private int turnAroundAnimationId = -1;
  88.    
  89.     /**
  90.      * The actor's turn right animation id.
  91.      */
  92.     private int turnRightAnimationId = -1;
  93.    
  94.     /**
  95.      * The actor's turn left animation id.
  96.      */
  97.     private int turnLeftAnimationId = -1;
  98.    
  99.     /**
  100.      * The actor's actions.
  101.      */
  102.     private String[] actions = new String[5];
  103.    
  104.     /**
  105.      * The original model colors of the actor.
  106.      */
  107.     private int[] originalModelColors;
  108.    
  109.     /**
  110.      * The modified model colors of the actor.
  111.      */
  112.     private int[] modifiedModelColors;
  113.    
  114.     /**
  115.      * The head model id's of the actor.
  116.      */
  117.     private int[] headModelIds;
  118.    
  119.     /**
  120.      * Whether or not the actor is visible on the minimap.
  121.      */
  122.     private boolean visibleOnMinimap = true;
  123.    
  124.     /**
  125.      * The combat level of the actor.
  126.      */
  127.     private int combatLevel = -1;
  128.    
  129.     /**
  130.      * The x size of the actor.
  131.      */
  132.     private int sizeX = 128;
  133.    
  134.     /**
  135.      * The y size of the actor.
  136.      */
  137.     private int sizeY = 128;
  138.    
  139.     /**
  140.      * Whether or not the actor is visible.
  141.      */
  142.     private boolean visible = false;
  143.    
  144.     /**
  145.      * The brightness of the actor.
  146.      */
  147.     private int brightness;
  148.    
  149.     /**
  150.      * The contrast of the actor.
  151.      */
  152.     private int contrast;
  153.    
  154.     /**
  155.      * The head icon of the actor.
  156.      */
  157.     private int headIcon = -1;
  158.    
  159.     /**
  160.      * The amount of degrees to turn for the actor.
  161.      */
  162.     private int degreesToTurn = 32;
  163.    
  164.     /**
  165.      * The var bit id of the actor.
  166.      */
  167.     private int varBitId = -1;
  168.    
  169.     /**
  170.      * The setting id of the actor.
  171.      */
  172.     private int settingId = -1;
  173.    
  174.     /**
  175.      * The children id's of the actor.
  176.      */
  177.     private int[] childrenIds;
  178.    
  179.     /**
  180.      * Whether or not the actor is clickable.
  181.      */
  182.     private boolean clickable = true;
  183.    
  184.     /**
  185.      * Creates an actor definition with the default values.
  186.      * @param id The actor's id.
  187.      */
  188.     public ActorDefinition(int id) {
  189.         this.id = id;
  190.     }
  191.    
  192.     /**
  193.      * Gets the actor's id.
  194.      * @return The actor's id.
  195.      */
  196.     public int getId() {
  197.         return id;
  198.     }
  199.    
  200.     /**
  201.      * Sets the model id size of this actor.
  202.      * @param size The size of the actor's model id array.
  203.      */
  204.     public void setModelIdSize(int size) {
  205.         this.modelIds = new int[size];
  206.     }
  207.    
  208.     /**
  209.      * Sets a model id of this actor.
  210.      * @param index The actor's model index.
  211.      * @param modelId The actor's model id.
  212.      */
  213.     public void setModelId(int index, int modelId) {
  214.         this.modelIds[index] = modelId;
  215.     }
  216.  
  217.     /**
  218.      * Gets a model id of this actor.
  219.      * @param index The index of the actor's model id.
  220.      * @return The model id of this actor with the specified index.
  221.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  222.      */
  223.     public int getModelId(int index) {
  224.         if (index < 0 || index >= modelIds.length) {
  225.             throw new IndexOutOfBoundsException();
  226.         }
  227.         return modelIds[index];
  228.     }
  229.    
  230.     /**
  231.      * Sets the name of this actor.
  232.      * @param name The actor's name.
  233.      */
  234.     public void setName(String name) {
  235.         this.name = name;
  236.     }
  237.  
  238.     /**
  239.      * Gets the name of this actor.
  240.      * @return The name of this actor, or {@code null} if it has no name.
  241.      */
  242.     public String getName() {
  243.         return name;
  244.     }
  245.  
  246.     /**
  247.      * Sets the description of this actor.
  248.      * @param description The actor's description.
  249.      */
  250.     public void setDescription(String description) {
  251.         this.description = description;
  252.     }
  253.  
  254.     /**
  255.      * Gets the description of this actor.
  256.      * @return The actor's description.
  257.      */
  258.     public String getDescription() {
  259.         return description;
  260.     }
  261.    
  262.     /**
  263.      * Sets the size of this actor.
  264.      * @param size The actor's name.
  265.      */
  266.     public void setSize(int size) {
  267.         this.size = size;
  268.     }
  269.  
  270.     /**
  271.      * Gets the size of this actor.
  272.      * @return The size of this actor.
  273.      */
  274.     public int getSize() {
  275.         return size;
  276.     }
  277.    
  278.     /**
  279.      * Sets the stand animation id of this actor.
  280.      * @param standAnimationId The actor's stand animation id.
  281.      */
  282.     public void setStandAnimationId(int standAnimationId) {
  283.         this.standAnimationId = standAnimationId;
  284.     }
  285.  
  286.     /**
  287.      * Gets the stand animation id of this actor.
  288.      * @return The stand animation id of this actor.
  289.      */
  290.     public int getStandAnimationId() {
  291.         return standAnimationId;
  292.     }
  293.    
  294.     /**
  295.      * Sets the walk animation id of this actor.
  296.      * @param walkAnimationId The actor's walk animation id.
  297.      */
  298.     public void setWalkAnimationId(int walkAnimationId) {
  299.         this.walkAnimationId = walkAnimationId;
  300.     }
  301.  
  302.     /**
  303.      * Gets the walk animation id of this actor.
  304.      * @return The walk animation id of this actor.
  305.      */
  306.     public int getWalkAnimationId() {
  307.         return walkAnimationId;
  308.     }
  309.    
  310.     /**
  311.      * Sets the turn around animation id of this actor.
  312.      * @param turnAroundAnimationId The actor's turn around animation id.
  313.      */
  314.     public void setTurnAroundAnimationId(int turnAroundAnimationId) {
  315.         this.walkAnimationId = turnAroundAnimationId;
  316.     }
  317.  
  318.     /**
  319.      * Gets the turn around animation id of this actor.
  320.      * @return The turn around animation id of this actor.
  321.      */
  322.     public int getTurnAroundAnimationId() {
  323.         return turnAroundAnimationId;
  324.     }
  325.    
  326.     /**
  327.      * Sets the turn right animation id of this actor.
  328.      * @param turnRightAnimationId The actor's turn right animation id.
  329.      */
  330.     public void setTurnRightAnimationId(int turnRightAnimationId) {
  331.         this.walkAnimationId = turnRightAnimationId;
  332.     }
  333.  
  334.     /**
  335.      * Gets the turn right animation id of this actor.
  336.      * @return The right around animation id of this actor.
  337.      */
  338.     public int getTurnRightAnimationId() {
  339.         return turnRightAnimationId;
  340.     }
  341.    
  342.     /**
  343.      * Sets the turn left animation id of this actor.
  344.      * @param turnLeftAnimationId The actor's turn left animation id.
  345.      */
  346.     public void setTurnLeftAnimationId(int turnLeftAnimationId) {
  347.         this.turnLeftAnimationId = turnLeftAnimationId;
  348.     }
  349.  
  350.     /**
  351.      * Gets the turn left animation id of this actor.
  352.      * @return The left around animation id of this actor.
  353.      */
  354.     public int getTurnLeftAnimationId() {
  355.         return turnLeftAnimationId;
  356.     }
  357.    
  358.     /**
  359.      * Sets a action.
  360.      * @param index The index of the action.
  361.      * @param action The action.
  362.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  363.      */
  364.     public void setAction(int index, String action) {
  365.         if (index < 0 || index >= actions.length) {
  366.             System.out.println(index + ":" + actions.length);
  367.             throw new IndexOutOfBoundsException();
  368.         }
  369.         actions[index] = action;
  370.     }
  371.  
  372.     /**
  373.      * Gets a action.
  374.      * @param index The id.
  375.      * @return The action.
  376.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  377.      */
  378.     public String getAction(int index) {
  379.         if (index < 0 || index >= actions.length) {
  380.             throw new IndexOutOfBoundsException();
  381.         }
  382.         return actions[index];
  383.     }
  384.    
  385.     /**
  386.      * Sets the original model color of this actor.
  387.      * @param index The original model color of the actor.
  388.      */
  389.     public void setOriginalModelColorSize(int index) {
  390.         this.originalModelColors = new int[index];
  391.     }
  392.    
  393.     /**
  394.      * Sets a original model color of this actor.
  395.      * @param index The actor's original model color index.
  396.      * @param modelId The actor's original model color.
  397.      */
  398.     public void setOriginalModelColor(int index, int modelId) {
  399.         this.originalModelColors[index] = modelId;
  400.     }
  401.  
  402.     /**
  403.      * Gets a original model color of this actor.
  404.      * @param index The index of the actor's original model color.
  405.      * @return The original model color of this actor with the specified index.
  406.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  407.      */
  408.     public int getOriginalModelColor(int index) {
  409.         if (index < 0 || index >= originalModelColors.length) {
  410.             throw new IndexOutOfBoundsException();
  411.         }
  412.         return originalModelColors[index];
  413.     }
  414.    
  415.     /**
  416.      * Sets the modified model color of this actor.
  417.      * @param index The modified model color of the actor.
  418.      */
  419.     public void setModifiedModelColorSize(int index) {
  420.         this.modifiedModelColors = new int[index];
  421.     }
  422.    
  423.     /**
  424.      * Sets a modified model color of this actor.
  425.      * @param index The actor's modified model color index.
  426.      * @param modelId The actor's modified model color.
  427.      */
  428.     public void setModifiedModelColor(int index, int modelId) {
  429.         this.modifiedModelColors[index] = modelId;
  430.     }
  431.  
  432.     /**
  433.      * Gets a modified model color of this actor.
  434.      * @param index The index of the actor's modified model color.
  435.      * @return The modified model color of this actor with the specified index.
  436.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  437.      */
  438.     public int getModifiedModelColor(int index) {
  439.         if (index < 0 || index >= modifiedModelColors.length) {
  440.             throw new IndexOutOfBoundsException();
  441.         }
  442.         return modifiedModelColors[index];
  443.     }
  444.    
  445.     /**
  446.      * Sets the head model id size of this actor.
  447.      * @param size The size of the actor's head model id array.
  448.      */
  449.     public void setHeadModelIdSize(int size) {
  450.         this.headModelIds = new int[size];
  451.     }
  452.    
  453.     /**
  454.      * Sets a head model id of this actor.
  455.      * @param index The actor's head model index.
  456.      * @param modelId The actor's head model id.
  457.      */
  458.     public void setHeadModelId(int index, int modelId) {
  459.         this.headModelIds[index] = modelId;
  460.     }
  461.  
  462.     /**
  463.      * Gets a head model id of this actor.
  464.      * @param index The index of the actor's head model id.
  465.      * @return The head model id of this actor with the specified index.
  466.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  467.      */
  468.     public int getHeadModelId(int index) {
  469.         if (index < 0 || index >= headModelIds.length) {
  470.             throw new IndexOutOfBoundsException();
  471.         }
  472.         return headModelIds[index];
  473.     }
  474.  
  475.     /**
  476.      * Checks whether or not the actor is visible on the minimap.
  477.      * @return Whether or not the actor is visible on the minimap.
  478.      */
  479.     public boolean isVisibleOnMinimap() {
  480.         return visibleOnMinimap;
  481.     }
  482.    
  483.     /**
  484.      * Sets whether or not the actor is visible on the minimap.
  485.      * @param visibleOnMinimap Whether or not the actor is visible on the minimap.
  486.      */
  487.     public void setVisibleOnMinimap(boolean visibleOnMinimap) {
  488.         this.visibleOnMinimap = visibleOnMinimap;
  489.     }
  490.  
  491.     /**
  492.      * Gets the combat level of the actor.
  493.      * @return The combat level of the actor.
  494.      */
  495.     public int getCombatLevel() {
  496.         return combatLevel;
  497.     }
  498.    
  499.     /**
  500.      * Sets the combat level of the actor.
  501.      * @param combatLevel The combat level of the actor.
  502.      */
  503.     public void setCombatLevel(int combatLevel) {
  504.         this.combatLevel = combatLevel;
  505.     }
  506.    
  507.     /**
  508.      * Gets the x size of the actor.
  509.      * @return The x size of the actor.
  510.      */
  511.     public int getSizeX() {
  512.         return sizeX;
  513.     }
  514.    
  515.     /**
  516.      * Sets the x size of the actor.
  517.      * @param sizeX The x size of the actor.
  518.      */
  519.     public void setSizeX(int sizeX) {
  520.         this.sizeX = sizeX;
  521.     }
  522.    
  523.     /**
  524.      * Gets the y size of the actor.
  525.      * @return The y size of the actor.
  526.      */
  527.     public int getSizeY() {
  528.         return sizeY;
  529.     }
  530.    
  531.     /**
  532.      * Sets the y size of the actor.
  533.      * @param sizeY The y size of the actor.
  534.      */
  535.     public void setSizeY(int sizeY) {
  536.         this.sizeY = sizeY;
  537.     }
  538.    
  539.     /**
  540.      * Checks whether or not the actor is visible.
  541.      * @return Whether or not the actor is visible.
  542.      */
  543.     public boolean isVisible() {
  544.         return visible;
  545.     }
  546.    
  547.     /**
  548.      * Sets whether or not the actor is visible.
  549.      * @param visible Whether or not the actor is visible.
  550.      */
  551.     public void setVisible(boolean visible) {
  552.         this.visible = visible;
  553.     }
  554.    
  555.     /**
  556.      * Gets the brightness of the actor.
  557.      * @return The brightness of the actor.s
  558.      */
  559.     public int getBrightness() {
  560.         return brightness;
  561.     }
  562.    
  563.     /**
  564.      * Sets the brightness of the actor.
  565.      * @param brightness The brightness of the actor.
  566.      */
  567.     public void setBrightness(int brightness) {
  568.         this.brightness = brightness;
  569.     }
  570.    
  571.     /**
  572.      * Gets the contrast of the actor.
  573.      * @return The contrast of the actor.
  574.      */
  575.     public int getContrast() {
  576.         return contrast;
  577.     }
  578.    
  579.     /**
  580.      * Sets the contrast of the actor.
  581.      * @param contrast The contrast of the actor.
  582.      */
  583.     public void setContrast(int contrast) {
  584.         this.contrast = contrast;
  585.     }
  586.    
  587.     /**
  588.      * Gets the head icon of the actor.
  589.      * @return The head icon of the actor.
  590.      */
  591.     public int getHeadIcon() {
  592.         return headIcon;
  593.     }
  594.    
  595.     /**
  596.      * Sets the head icon of the actor.
  597.      * @param headIcon The head icon of the actor.
  598.      */
  599.     public void setHeadIcon(int headIcon) {
  600.         this.headIcon = headIcon;
  601.     }
  602.    
  603.     /**
  604.      * Gets the amount of degrees for the actor to turn.
  605.      * @return The amount of degrees for the actor to turn.
  606.      */
  607.     public int getDegreesToTurn() {
  608.         return degreesToTurn;
  609.     }
  610.    
  611.     /**
  612.      * Sets the amount of degrees for the actor to turn.
  613.      * @param degreesToTurn The amount of degrees for the actor to turn.
  614.      */
  615.     public void setDegreesToTurn(int degreesToTurn) {
  616.         this.degreesToTurn = degreesToTurn;
  617.     }
  618.    
  619.     /**
  620.      * Gets the var bit id of the actor.
  621.      * @return The var bit id of the actor.
  622.      */
  623.     public int getVarBitId() {
  624.         return varBitId;
  625.     }
  626.    
  627.     /**
  628.      * Sets the var bit id of the actor.
  629.      * @param varBitId The var bit id of the actor.
  630.      */
  631.     public void setVarBitId(int varBitId) {
  632.         this.varBitId = varBitId;
  633.     }
  634.    
  635.     /**
  636.      * Gets the setting id of the actor.
  637.      * @return The setting id of the actor.
  638.      */
  639.     public int getSettingId() {
  640.         return settingId;
  641.     }
  642.    
  643.     /**
  644.      * Sets the setting id of the actor.
  645.      * @param settingId The setting id of the actor.
  646.      */
  647.     public void setSettingId(int settingId) {
  648.         this.settingId = settingId;
  649.     }
  650.    
  651.     /**
  652.      * Sets the children id size of this actor.
  653.      * @param size The size of the actor's children id array.
  654.      */
  655.     public void setChildrenIdSize(int size) {
  656.         this.childrenIds = new int[size];
  657.     }
  658.    
  659.     /**
  660.      * Sets a child id of this actor.
  661.      * @param index The actor's child index.
  662.      * @param childId The actor's child id.
  663.      */
  664.     public void setChildId(int index, int childId) {
  665.         this.childrenIds[index] = childId;
  666.     }
  667.  
  668.     /**
  669.      * Gets a child id of this actor.
  670.      * @param index The index of the actor's child id.
  671.      * @return The child id of this actor with the specified index.
  672.      * @throws IndexOutOfBoundsException if the index is out of bounds.
  673.      */
  674.     public int getChildId(int index) {
  675.         if (index < 0 || index >= childrenIds.length) {
  676.             throw new IndexOutOfBoundsException();
  677.         }
  678.         return childrenIds[index];
  679.     }
  680.    
  681.     /**
  682.      * Checks whether or not the actor is clickable.
  683.      * @return Whether or not the actor is clickable.
  684.      */
  685.     public boolean isClickable() {
  686.         return clickable;
  687.     }
  688.    
  689.     /**
  690.      * Sets whether or not the actor is clickable.
  691.      * @param clickable Whether or not the actor is clickable.
  692.      */
  693.     public void setClickable(boolean clickable) {
  694.         this.clickable = clickable;
  695.     }
  696. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement