Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private List<InterfaceComponent> getDynamicSubComponents() {
- List<InterfaceComponent> subcomponents = new ArrayList<>();
- RSInterfaceComponent provider = getProvider();
- if (provider == null) {
- return subcomponents;
- }
- RSInterfaceComponent[] raw = provider.getSubComponents();
- if (raw == null) {
- return subcomponents;
- }
- for (RSInterfaceComponent component : raw) {
- if (component != null && component.getParentUid() == getUid()) {
- subcomponents.add(new InterfaceComponent(component));
- }
- }
- return subcomponents;
- }
- private List<InterfaceComponent> getStaticSubComponents() {
- List<InterfaceComponent> subcomponents = new ArrayList<>();
- if (getParentUid() == getUid()) {
- return subcomponents;
- }
- int group = getGroupIndex();
- RSInterfaceComponent[][] raw = Game.getClient().getInterfaces();
- if (raw == null || group < 0 || group >= raw.length) {
- return subcomponents;
- }
- RSInterfaceComponent[] grouped = raw[group];
- if (grouped == null) {
- return subcomponents;
- }
- for (RSInterfaceComponent component : grouped) {
- if (component != null && component.getParentUid() == getUid()) {
- subcomponents.add(new InterfaceComponent(component));
- }
- }
- return subcomponents;
- }
- private List<InterfaceComponent> getNestedSubComponents() {
- List<InterfaceComponent> subcomponents = new ArrayList<>();
- if (getParentUid() == getUid()) {
- return subcomponents;
- }
- RSNodeTable<RSSubInterface> nested = Game.getClient().getSubInterfaces();
- if (nested == null) {
- return subcomponents;
- }
- RSSubInterface sub = nested.lookup(getUid());
- if (sub == null) {
- return subcomponents;
- }
- int group = sub.getId();
- RSInterfaceComponent[][] raw = Game.getClient().getInterfaces();
- if (raw == null || group < 0 || group >= raw.length) {
- return subcomponents;
- }
- RSInterfaceComponent[] grouped = raw[group];
- if (grouped == null) {
- return subcomponents;
- }
- for (RSInterfaceComponent component : grouped) {
- if (component != null && component.getParentUid() == -1) {
- subcomponents.add(new InterfaceComponent(component));
- }
- }
- return subcomponents;
- }
- private List<InterfaceComponent> getDefaultSubComponents() {
- List<InterfaceComponent> subcomponents = new ArrayList<>();
- RSInterfaceComponent provider = getProvider();
- if (provider == null) {
- return subcomponents;
- }
- RSInterfaceComponent[] raw = provider.getSubComponents();
- if (raw == null) {
- return subcomponents;
- }
- for (RSInterfaceComponent component : raw) {
- if (component != null) {
- subcomponents.add(new InterfaceComponent(component));
- }
- }
- return subcomponents;
- }
- public List<InterfaceComponent> getSubComponents(TraversalOption option) {
- switch (option) {
- case NESTED:
- return getNestedSubComponents();
- case STATIC:
- return getStaticSubComponents();
- case DYNAMIC:
- return getDynamicSubComponents();
- case DEFAULT:
- return getDefaultSubComponents();
- default: {
- throw new IllegalArgumentException("Unsupported TraversalOption: " + option);
- }
- }
- }
- public List<InterfaceComponent> getSubComponents() {
- return getSubComponents(TraversalOption.DEFAULT);
- }
- public enum TraversalOption {
- NESTED,
- DYNAMIC,
- STATIC,
- DEFAULT;
- private static final TraversalOption[] NATURAL = {NESTED, DYNAMIC, STATIC};
- public static TraversalOption[] natural() {
- return NATURAL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement