RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.action.impl.TeleportAction Class Reference

Teleports an entity to another part of the world. More...

Inheritance diagram for com.runehive.game.action.impl.TeleportAction:
Collaboration diagram for com.runehive.game.action.impl.TeleportAction:

Public Member Functions

String getName ()
WalkablePolicy getWalkablePolicy ()
boolean prioritized ()
 TeleportAction (Mob entity, Position position, TeleportationData type, Runnable onDestination)
 Constructs a new TeleportAction object.
Public Member Functions inherited from com.runehive.game.action.ConsecutiveAction< T extends Mob >
 ConsecutiveAction (T mob)
 Generates a new ConsecutiveAction object.
void execute ()
Public Member Functions inherited from com.runehive.game.action.Action< T >
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
abstract String getName ()
 Gets the name of this action.
abstract WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
boolean prioritized ()
 Determines if this action is prioritized.

Protected Member Functions

void onCancel (boolean logout)
void onSchedule ()
Protected Member Functions inherited from com.runehive.game.action.ConsecutiveAction< T extends Mob >
void add (Consumer< Action< T > > action)
 Adds an action to the actions list.
void addFirst (Consumer< Action< T > > action)
 Adds an action to the actions list.

Private Member Functions

void end (Action< Mob > action)
void init ()
void move (Action< Mob > action)
void reset (Action< Mob > action)
void start (Action< Mob > action)
void startTablet (Action< Mob > action)
boolean valid (Action< Mob > action)

Private Attributes

final Runnable onDestination
 The destination randomevent.
final Position position
 The teleport position.
final TeleportationData type
 The teleportType.

Detailed Description

Teleports an entity to another part of the world.

Author
Daniel
Michael | Chex

Definition at line 22 of file TeleportAction.java.

Constructor & Destructor Documentation

◆ TeleportAction()

com.runehive.game.action.impl.TeleportAction.TeleportAction ( Mob entity,
Position position,
TeleportationData type,
Runnable onDestination )

Constructs a new TeleportAction object.

Definition at line 34 of file TeleportAction.java.

34 {
35 super(entity);
36 this.position = position;
37 this.type = type;
38 this.onDestination = onDestination;
39 }

References onDestination, position, and type.

Member Function Documentation

◆ end()

void com.runehive.game.action.impl.TeleportAction.end ( Action< Mob > action)
private

Definition at line 114 of file TeleportAction.java.

114 {
115 type.getEndGraphic().ifPresent(action.getMob()::graphic);
116 type.getEndAnimation().ifPresent(action.getMob()::animate);
117
118 if (type.getEndAnimation().isPresent() || type.getEndGraphic().isPresent()) {
119 action.setDelay(type.getDelay());
120 }
121
122 onDestination.run();
123 action.getMob().onStep();
124
125 //This is for overrides - updates appearance after teleport to account for duel arena
126 action.getMob().updateFlags.add(UpdateFlag.APPEARANCE);
127 }

References com.runehive.game.world.entity.mob.UpdateFlag.APPEARANCE, onDestination, and type.

◆ getName()

String com.runehive.game.action.impl.TeleportAction.getName ( )

Definition at line 151 of file TeleportAction.java.

151 {
152 return "teleport_action";
153 }

◆ getWalkablePolicy()

WalkablePolicy com.runehive.game.action.impl.TeleportAction.getWalkablePolicy ( )

Definition at line 161 of file TeleportAction.java.

161 {
162 return WalkablePolicy.NON_WALKABLE;
163 }

References com.runehive.game.action.policy.WalkablePolicy.NON_WALKABLE.

◆ init()

void com.runehive.game.action.impl.TeleportAction.init ( )
private

Definition at line 56 of file TeleportAction.java.

56 {
57 add(this::start);
58 add(this::move);
59 if (type != TeleportationData.TABLET)
60 add(this::end);
61 add(this::reset);
62 }

References com.runehive.game.action.ConsecutiveAction< T extends Mob >.add(), com.runehive.content.skill.impl.magic.teleport.TeleportationData.TABLET, and type.

Referenced by onSchedule().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move()

void com.runehive.game.action.impl.TeleportAction.move ( Action< Mob > action)
private

Definition at line 98 of file TeleportAction.java.

98 {
99 if (valid(action)) {
100 action.setDelay(1);
101 action.getMob().move(position);
102 action.getMob().inTeleport = true;
103 action.getMob().teleporting = true;
104
105 if (action.getMob().isPlayer()) {
106 action.getMob().getPlayer().send(new SendString("[CLOSE_MENU]", 0));
107 }
108 } else {
109 reset(action);
110 onDestination.run();
111 }
112 }

References onDestination, position, reset(), and valid().

Here is the call graph for this function:

◆ onCancel()

void com.runehive.game.action.impl.TeleportAction.onCancel ( boolean logout)
protected

Definition at line 135 of file TeleportAction.java.

135 {
136 getMob().animate(Animation.RESET, true);
137 getMob().graphic(Graphic.RESET, true);
138 getMob().inTeleport = false;
139 getMob().teleporting = false;
140
141 if (type == TeleportationData.TABLET) {
142 getMob().getPlayer().pvpInstance = false;
143 getMob().instance = Mob.DEFAULT_INSTANCE;
144 if (getMob().getPlayer().pet != null) {
145 getMob().getPlayer().pet.instance = getMob().instance;
146 }
147 }
148 }

References com.runehive.game.world.entity.Entity.DEFAULT_INSTANCE, com.runehive.game.action.Action< T >.getMob(), com.runehive.game.Animation.RESET, com.runehive.game.Graphic.RESET, com.runehive.content.skill.impl.magic.teleport.TeleportationData.TABLET, and type.

Here is the call graph for this function:

◆ onSchedule()

void com.runehive.game.action.impl.TeleportAction.onSchedule ( )
protected

Definition at line 42 of file TeleportAction.java.

42 {
43 if (getMob().isPlayer() && getMob().getPlayer().isTeleblocked()) {
44 cancel();
45 getMob().getPlayer().message("You are currently under the affects of a teleblock spell and can not teleport!");
46 return;
47 }
48
49 if (!valid(this)) {
50 cancel();
51 } else {
52 init();
53 }
54 }

References com.runehive.game.action.Action< T >.getMob(), init(), and valid().

Here is the call graph for this function:

◆ prioritized()

boolean com.runehive.game.action.impl.TeleportAction.prioritized ( )

Definition at line 156 of file TeleportAction.java.

156 {
157 return false;
158 }

◆ reset()

void com.runehive.game.action.impl.TeleportAction.reset ( Action< Mob > action)
private

Definition at line 129 of file TeleportAction.java.

129 {
130 action.getMob().inTeleport = false;
131 cancel();
132 }

Referenced by move().

Here is the caller graph for this function:

◆ start()

void com.runehive.game.action.impl.TeleportAction.start ( Action< Mob > action)
private

Definition at line 75 of file TeleportAction.java.

75 {
76 if (type != TeleportationData.HOME)
77 action.getMob().inTeleport = true;
78
79 action.setDelay(type.getDelay());
80 action.getMob().movement.reset();
81 type.getStartAnimation().ifPresent(action.getMob()::animate);
82 type.getStartGraphic().ifPresent(action.getMob()::graphic);
83
84 if (type.lockMovement()) {
85 action.getMob().locking.lock();
86 }
87
88 if (type == TeleportationData.TABLET) {
89 addFirst(this::startTablet);
90 }
91 }

References com.runehive.game.action.ConsecutiveAction< T extends Mob >.addFirst(), com.runehive.content.skill.impl.magic.teleport.TeleportationData.HOME, com.runehive.content.skill.impl.magic.teleport.TeleportationData.TABLET, and type.

Here is the call graph for this function:

◆ startTablet()

void com.runehive.game.action.impl.TeleportAction.startTablet ( Action< Mob > action)
private

Definition at line 93 of file TeleportAction.java.

93 {
94 action.setDelay(type.getDelay());
95 type.getEndAnimation().ifPresent(action.getMob()::animate);
96 }

References type.

◆ valid()

boolean com.runehive.game.action.impl.TeleportAction.valid ( Action< Mob > action)
private

Definition at line 64 of file TeleportAction.java.

64 {
65 if (type == TeleportationData.HOME && action.getMob().getCombat().inCombat()) {
66 if (action.getMob().isPlayer()) {
67 action.getMob().getPlayer().send(new SendMessage("You can't teleport home while in combat!"));
68 }
69 cancel();
70 return false;
71 }
72 return true;
73 }

References com.runehive.content.skill.impl.magic.teleport.TeleportationData.HOME, and type.

Referenced by move(), and onSchedule().

Here is the caller graph for this function:

Member Data Documentation

◆ onDestination

final Runnable com.runehive.game.action.impl.TeleportAction.onDestination
private

The destination randomevent.

Definition at line 31 of file TeleportAction.java.

Referenced by end(), move(), and TeleportAction().

◆ position

final Position com.runehive.game.action.impl.TeleportAction.position
private

The teleport position.

Definition at line 25 of file TeleportAction.java.

Referenced by move(), and TeleportAction().

◆ type

final TeleportationData com.runehive.game.action.impl.TeleportAction.type
private

The teleportType.

Definition at line 28 of file TeleportAction.java.

Referenced by end(), init(), onCancel(), start(), startTablet(), TeleportAction(), and valid().


The documentation for this class was generated from the following file: