RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.task.impl.ObjectReplacementEvent Class Reference

An randomevent which replaces an object with another object. More...

Inheritance diagram for com.runehive.game.task.impl.ObjectReplacementEvent:
Collaboration diagram for com.runehive.game.task.impl.ObjectReplacementEvent:

Public Member Functions

void execute ()
 A function representing the unit of work that will be carried out.
 ObjectReplacementEvent (GameObject original, int delay)
 ObjectReplacementEvent (GameObject original, int replacement, int delay)
 ObjectReplacementEvent (GameObject original, int replacement, int delay, Runnable onEndRun)
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

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

Private Attributes

final Runnable onEndRun
 The on event end runnable.
final GameObject original
 The original game object.
final int originalId
 The replacement game object.
final int replacement
 The replacement game object.

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

An randomevent which replaces an object with another object.

Author
Daniel | Obey
Michael | Chex

Definition at line 12 of file ObjectReplacementEvent.java.

Constructor & Destructor Documentation

◆ ObjectReplacementEvent() [1/3]

com.runehive.game.task.impl.ObjectReplacementEvent.ObjectReplacementEvent ( GameObject original,
int delay )

Definition at line 26 of file ObjectReplacementEvent.java.

26 {
27 super(false, delay);
28 this.original = original;
29 this.originalId = original.getId();
30 this.replacement = -1;
31 this.onEndRun = () -> {
32 };
33 }

References com.runehive.game.task.Task.delay, and original.

◆ ObjectReplacementEvent() [2/3]

com.runehive.game.task.impl.ObjectReplacementEvent.ObjectReplacementEvent ( GameObject original,
int replacement,
int delay )

Definition at line 35 of file ObjectReplacementEvent.java.

35 {
36 super(false, delay);
37 this.original = original;
38 this.originalId = original.getId();
39 this.replacement = replacement;
40 this.onEndRun = () -> {
41 };
42 }

References com.runehive.game.task.Task.delay, original, and replacement.

◆ ObjectReplacementEvent() [3/3]

com.runehive.game.task.impl.ObjectReplacementEvent.ObjectReplacementEvent ( GameObject original,
int replacement,
int delay,
Runnable onEndRun )

Definition at line 44 of file ObjectReplacementEvent.java.

44 {
45 super(false, delay);
46 this.original = original;
47 this.originalId = original.getId();
48 this.replacement = replacement;
49 this.onEndRun = onEndRun;
50 }

References com.runehive.game.task.Task.delay, onEndRun, original, and replacement.

Member Function Documentation

◆ execute()

void com.runehive.game.task.impl.ObjectReplacementEvent.execute ( )

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

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

Definition at line 62 of file ObjectReplacementEvent.java.

62 {
63 cancel();
64 }

References com.runehive.game.task.Task.cancel().

Here is the call graph for this function:

◆ onCancel()

void com.runehive.game.task.impl.ObjectReplacementEvent.onCancel ( boolean logout)
protected

A function executed on cancellation.

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

Definition at line 67 of file ObjectReplacementEvent.java.

67 {
68 if (replacement == -1) {
69 original.register();
70 } else {
71 original.transform(originalId);
72 }
73
74 onEndRun.run();
75 }

References onEndRun, original, originalId, and replacement.

◆ onSchedule()

void com.runehive.game.task.impl.ObjectReplacementEvent.onSchedule ( )
protected

A function executed on registration.

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

Definition at line 53 of file ObjectReplacementEvent.java.

53 {
54 if (replacement == -1) {
55 original.unregister();
56 return;
57 }
58 original.transform(replacement);
59 }

References original, and replacement.

Member Data Documentation

◆ onEndRun

final Runnable com.runehive.game.task.impl.ObjectReplacementEvent.onEndRun
private

The on event end runnable.

Definition at line 24 of file ObjectReplacementEvent.java.

Referenced by ObjectReplacementEvent(), and onCancel().

◆ original

final GameObject com.runehive.game.task.impl.ObjectReplacementEvent.original
private

The original game object.

Definition at line 15 of file ObjectReplacementEvent.java.

Referenced by ObjectReplacementEvent(), ObjectReplacementEvent(), ObjectReplacementEvent(), onCancel(), and onSchedule().

◆ originalId

final int com.runehive.game.task.impl.ObjectReplacementEvent.originalId
private

The replacement game object.

Definition at line 18 of file ObjectReplacementEvent.java.

Referenced by onCancel().

◆ replacement

final int com.runehive.game.task.impl.ObjectReplacementEvent.replacement
private

The replacement game object.

Definition at line 21 of file ObjectReplacementEvent.java.

Referenced by ObjectReplacementEvent(), ObjectReplacementEvent(), onCancel(), and onSchedule().


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