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

Handles going through a door. More...

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

Public Member Functions

 DoorAction (Player player, GameObject door, Position destination, Direction face)
 DoorAction (Player player, GameObject door, Position destination, Direction face, Predicate< Player > condition, String message)
void execute ()
 A function representing the unit of work that will be carried out.
String getName ()
 Gets the name of this action.
WalkablePolicy getWalkablePolicy ()
 Gets the WalkablePolicy of this action.
boolean prioritized ()
 Determines if this action is prioritized.
Public Member Functions inherited from com.runehive.game.action.Action< T extends Mob >
 Action (T mob, int delay)
 Creates a new Action randomevent.
 Action (T mob, int delay, boolean instant)
 Creates a new Action randomevent.
boolean cancellableInProgress ()
getMob ()
 Gets the player.
Public Member Functions inherited from com.runehive.game.task.Task
Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Protected Member Functions

boolean canSchedule ()
 A function executed on registration.
void onCancel (boolean logout)
 A function executed on cancellation.
Protected Member Functions inherited from com.runehive.game.task.Task
void baseExecute ()
void onSchedule ()
 A function executed on registration.

Private Attributes

final Predicate< Playercondition
int count
final GameObject door
final Direction face
final String message
final Position position

Additional Inherited Members

Package Functions inherited from com.runehive.game.task.Task
void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Detailed Description

Handles going through a door.

(Cheap fix doesn't actually open the door)

Author
Daniel

Definition at line 20 of file DoorAction.java.

Constructor & Destructor Documentation

◆ DoorAction() [1/2]

com.runehive.game.action.impl.DoorAction.DoorAction ( Player player,
GameObject door,
Position destination,
Direction face )

Definition at line 28 of file DoorAction.java.

28 {
29 this(player, door, destination, face, null, null);
30 }

References door, and face.

◆ DoorAction() [2/2]

com.runehive.game.action.impl.DoorAction.DoorAction ( Player player,
GameObject door,
Position destination,
Direction face,
Predicate< Player > condition,
String message )

Definition at line 32 of file DoorAction.java.

32 {
33 super(player, 1, true);
34 this.count = 0;
35 this.door = door;
36 this.position = destination;
37 this.face = face;
38 this.condition = condition;
39 this.message = message;
40 }

References condition, door, face, and message.

Member Function Documentation

◆ canSchedule()

boolean com.runehive.game.action.impl.DoorAction.canSchedule ( )
protected

A function executed on registration.

Reimplemented from com.runehive.game.task.Task.

Definition at line 43 of file DoorAction.java.

43 {
44 if (condition != null && !condition.test(getMob())) {
45 getMob().send(new SendMessage(message, MessageColor.RED));
46 return false;
47 }
48 return true;
49 }

References condition, com.runehive.game.action.Action< T extends Mob >.getMob(), message, and com.runehive.util.MessageColor.RED.

Here is the call graph for this function:

◆ execute()

void com.runehive.game.action.impl.DoorAction.execute ( )

A function representing the unit of work that will be carried out.

Reimplemented from com.runehive.game.task.Task.

Definition at line 52 of file DoorAction.java.

52 {
53 if (!Utility.within(getMob().getPosition(), door.getPosition(), 1)) {
54 if (!getMob().movement.isMoving())
55 getMob().walk(door.getPosition());
56 return;
57 }
58
59 if (getMob().getCombat().inCombat())
60 getMob().getCombat().reset();
61
62 if (count == 0) {
63 getMob().face(face);
64 getMob().locking.lock();
65 } else if (count == 1) {
66 getMob().move(position);
67 getMob().locking.unlock();
68 getMob().face(Direction.getOppositeDirection(face));
69 cancel();
70 }
71 count++;
72 }

References com.runehive.game.task.Task.cancel(), count, door, face, com.runehive.game.action.Action< T extends Mob >.getMob(), com.runehive.game.world.entity.mob.Direction.getOppositeDirection(), position, and com.runehive.util.Utility.within().

Here is the call graph for this function:

◆ getName()

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

Gets the name of this action.

Returns
The name of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 80 of file DoorAction.java.

80 {
81 return "Open door";
82 }

◆ getWalkablePolicy()

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

Gets the WalkablePolicy of this action.

Returns
The walkable policy of this action.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 90 of file DoorAction.java.

90 {
91 return WalkablePolicy.NON_WALKABLE;
92 }

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

◆ onCancel()

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

A function executed on cancellation.

Reimplemented from com.runehive.game.task.Task.

Definition at line 75 of file DoorAction.java.

75 {
76 getMob().locking.unlock();
77 }

References com.runehive.game.action.Action< T extends Mob >.getMob().

Here is the call graph for this function:

◆ prioritized()

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

Determines if this action is prioritized.

When making an action prioritized, the next action will be ignored if not queued.

Returns
true if this action is prioritized, false otherwise.

Reimplemented from com.runehive.game.action.Action< T extends Mob >.

Definition at line 85 of file DoorAction.java.

85 {
86 return false;
87 }

Member Data Documentation

◆ condition

final Predicate<Player> com.runehive.game.action.impl.DoorAction.condition
private

Definition at line 24 of file DoorAction.java.

Referenced by canSchedule(), and DoorAction().

◆ count

int com.runehive.game.action.impl.DoorAction.count
private

Definition at line 21 of file DoorAction.java.

Referenced by execute().

◆ door

final GameObject com.runehive.game.action.impl.DoorAction.door
private

Definition at line 22 of file DoorAction.java.

Referenced by DoorAction(), DoorAction(), and execute().

◆ face

final Direction com.runehive.game.action.impl.DoorAction.face
private

Definition at line 26 of file DoorAction.java.

Referenced by DoorAction(), DoorAction(), and execute().

◆ message

final String com.runehive.game.action.impl.DoorAction.message
private

Definition at line 25 of file DoorAction.java.

Referenced by canSchedule(), and DoorAction().

◆ position

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

Definition at line 23 of file DoorAction.java.

Referenced by execute().


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