RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.activity.GroupActivity Class Referenceabstract

A GroupActivity is an extension of Activity that holds a list of active activities. More...

Inheritance diagram for com.runehive.content.activity.GroupActivity:
Collaboration diagram for com.runehive.content.activity.GroupActivity:

Public Member Functions

final void addActivity (Mob mob, Activity activity)
 Adds an activity to the activities group.
void cleanup ()
 Cleans up the activity when finished.
void finish ()
 Finishes the activity.
void forEachActivity (BiConsumer< Mob, Activity > activity)
 Loops through all the activities.
int getActiveSize ()
 Gets the size of the activities in this group.
Activity getActivity (Mob mob)
final void groupMessage (String message)
 Sends a message to all the players in the group.
final boolean isActive ()
 Checks if this group is active.
final void removeActivity (Mob mob)
 Removes an activity from the activities group.
Public Member Functions inherited from com.runehive.content.activity.Activity
 Activity (int cooldown, int instance)
 Constructs a new SequencedMinigame object.
void add (Mob mob)
 Adds a mob to the activity.
boolean canDrinkPotions (Player player)
boolean canEat (Player player, FoodData foodType)
boolean canEquipItem (Player player, Item item, EquipmentType type)
boolean canLogout (Player player)
boolean canSpellCast (Player player)
boolean canTeleport (Player player)
 Called when the player attempts to teleport.
boolean canUsePrayer (Player player)
boolean canUseSpecial (Player player)
void cooldown (int cooldown)
 Applies a cooldown.
ActivityDeathType deathType ()
int getInstance ()
 Gets this activity's instance level.
Optional< Activity_PanelgetPanel ()
 Gets an optional of the activity panel.
int getTicks ()
 Gets the current ticks.
abstract ActivityType getType ()
void onDeath (Mob mob)
 Called when the player die.
boolean onEvent (Player player, InteractionEvent interactionEvent)
void onLogout (Player player)
 Called when the player logs out.
void onRegionChange (Player player)
 Called when the player changes region.
boolean onStep (Mob mob)
void remove (Mob mob)
 Removes a mob from the activity.
void removeAll (Mob... mobs)
 Removes all mobs from the activity.
void sequence ()
 Sequences the activity.
void setInstance (int instance)
void setPanel (Activity_Panel panel)
 Sets the activity panel.
void setPause (boolean pause)
 Sets the pause state of the activity.
void update ()
 The update method.

Protected Member Functions

 GroupActivity (int cooldown, int capacity)
 Constructs a new GroupActivity object.
void removeAll ()
void start ()
 Starts the next activity stage.
Protected Member Functions inherited from com.runehive.content.activity.Activity
boolean clickButton (Player player, ClickButtonInteractionEvent event)
boolean clickItem (Player player, ItemInteractionEvent event)
boolean clickNpc (Player player, NpcInteractionEvent event)
boolean clickObject (Player player, ObjectInteractionEvent event)
final void finishCooldown ()
 Sets the cooldown flag to FINISH.
Optional<? extends ActivityListener<? extends Activity > > getListener ()
 Gets an Optional of the ActivityListener for this activity.
final boolean isPaused ()
 Checks if the cooldown is paused.
boolean itemContainerAction (Player player, ItemContainerInteractionEvent event)
final void pause ()
 Sets the cooldown flag to PAUSE.
boolean pickupItem (Player player, PickupItemInteractionEvent event)
final void resetCooldown ()
 Resets the remaining ticks to the cached cooldown ticks.
void restart (int delay, Runnable runnable)
boolean useItem (Player player, ItemOnItemInteractionEvent event)
boolean useItem (Player player, ItemOnObjectInteractionEvent event)

Protected Attributes

final Map< Mob, Activityactivities
 A map of activities that handles each mob individually.

Static Private Member Functions

static int getNextInstance ()
 Gets the next instance.

Static Private Attributes

static int nextInstance
 The next instance level.

Additional Inherited Members

Static Public Member Functions inherited from com.runehive.content.activity.Activity
static boolean evaluate (Mob mob, Predicate< Activity > predicate)
static void forActivity (Mob mob, Consumer< Activity > consumer)
static< T extends Activity > Optional< T > search (Player player, Class< T > clazz)
Static Protected Attributes inherited from com.runehive.content.activity.Activity
static final int FINISH = -1
 The 'finish' cooldown id.
static final int PAUSE = -2
 The 'pause' cooldown id.
static final int START = 0
 The 'start' cooldown id.

Detailed Description

A GroupActivity is an extension of Activity that holds a list of active activities.

Author
Michael | Chex

Definition at line 16 of file GroupActivity.java.

Constructor & Destructor Documentation

◆ GroupActivity()

com.runehive.content.activity.GroupActivity.GroupActivity ( int cooldown,
int capacity )
protected

Constructs a new GroupActivity object.

Parameters
cooldownthe initial cooldown in ticks

Definition at line 29 of file GroupActivity.java.

29 {
30 super(cooldown, getNextInstance());
31 this.activities = new HashMap<>(capacity);
32 }

References com.runehive.content.activity.Activity.cooldown, and getNextInstance().

Here is the call graph for this function:

Member Function Documentation

◆ addActivity()

final void com.runehive.content.activity.GroupActivity.addActivity ( Mob mob,
Activity activity )

Adds an activity to the activities group.

Parameters
mobthe mob to add
activitythe mob's activity

Definition at line 90 of file GroupActivity.java.

90 {
91 if (!activities.containsKey(mob)) {
92 activities.put(mob, activity);
93 add(mob);
94 }
95 }

References activities, com.runehive.content.activity.Activity.Activity(), and com.runehive.content.activity.Activity.add().

Here is the call graph for this function:

◆ cleanup()

void com.runehive.content.activity.GroupActivity.cleanup ( )

Cleans up the activity when finished.

Reimplemented from com.runehive.content.activity.Activity.

Definition at line 48 of file GroupActivity.java.

48 {
49 activities.forEach((mob, activity) -> activity.cleanup());
50 }

References activities.

Referenced by com.runehive.content.activity.lobby.LobbyManager.sequenceActive().

Here is the caller graph for this function:

◆ finish()

void com.runehive.content.activity.GroupActivity.finish ( )

Finishes the activity.

Reimplemented from com.runehive.content.activity.Activity.

Reimplemented in com.runehive.content.activity.impl.pestcontrol.PestControlGame.

Definition at line 40 of file GroupActivity.java.

40 {
41 for (Map.Entry<Mob, Activity> entry : activities.entrySet()) {
42 entry.getValue().finish();
43 entry.getValue().cleanup();
44 }
45 }

References activities, and com.runehive.content.activity.Activity.Activity().

Referenced by com.runehive.content.activity.lobby.LobbyManager.sequenceActive().

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

◆ forEachActivity()

void com.runehive.content.activity.GroupActivity.forEachActivity ( BiConsumer< Mob, Activity > activity)

Loops through all the activities.

Parameters
activitythe consumer

Definition at line 80 of file GroupActivity.java.

80 {
81 activities.forEach(activity);
82 }

References activities.

Referenced by com.runehive.content.activity.lobby.LobbyManager.canStart(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.onStart(), and com.runehive.content.activity.impl.pestcontrol.PestControlGame.sequence().

Here is the caller graph for this function:

◆ getActiveSize()

int com.runehive.content.activity.GroupActivity.getActiveSize ( )

Gets the size of the activities in this group.

Returns
the amount of activities in this group

Definition at line 71 of file GroupActivity.java.

71 {
72 return activities.size();
73 }

References activities.

Referenced by com.runehive.content.activity.lobby.LobbyManager.canStart(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.finished(), com.runehive.content.activity.lobby.LobbyNode.finished(), and com.runehive.content.activity.impl.pestcontrol.PestControlGame.PestControlPanel.update().

Here is the caller graph for this function:

◆ getActivity()

Activity com.runehive.content.activity.GroupActivity.getActivity ( Mob mob)

Definition at line 123 of file GroupActivity.java.

123 {
124 return activities.get(mob);
125 }

References activities, and com.runehive.content.activity.Activity.Activity().

Here is the call graph for this function:

◆ getNextInstance()

int com.runehive.content.activity.GroupActivity.getNextInstance ( )
staticprivate

Gets the next instance.

Returns
the instacne level

Definition at line 132 of file GroupActivity.java.

132 {
133 return nextInstance++;
134 }

References nextInstance.

Referenced by GroupActivity().

Here is the caller graph for this function:

◆ groupMessage()

final void com.runehive.content.activity.GroupActivity.groupMessage ( String message)

Sends a message to all the players in the group.

Parameters
messagethe message to send

Definition at line 116 of file GroupActivity.java.

116 {
117 activities.keySet().forEach(mob -> {
118 if (mob.isPlayer())
119 mob.getPlayer().send(new SendMessage(message));
120 });
121 }

References activities.

Referenced by com.runehive.content.activity.lobby.LobbyManager.canStart(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.onDeath(), and com.runehive.content.activity.impl.pestcontrol.PestControlGame.onStart().

Here is the caller graph for this function:

◆ isActive()

final boolean com.runehive.content.activity.GroupActivity.isActive ( )

Checks if this group is active.

Returns
true if there are active activities

Definition at line 62 of file GroupActivity.java.

62 {
63 return !activities.isEmpty();
64 }

References activities.

◆ removeActivity()

final void com.runehive.content.activity.GroupActivity.removeActivity ( Mob mob)

Removes an activity from the activities group.

Parameters
mobthe mob that owns the activity

Definition at line 102 of file GroupActivity.java.

102 {
103 if (activities.containsKey(mob)) {
104 activities.get(mob).finish();
105 activities.get(mob).cleanup();
106 activities.remove(mob);
107 remove(mob);
108 }
109 }

References activities.

Referenced by com.runehive.content.activity.impl.pestcontrol.PestControlGame.onLogout(), and com.runehive.content.activity.impl.pestcontrol.PestControlGame.onRegionChange().

Here is the caller graph for this function:

◆ removeAll()

void com.runehive.content.activity.GroupActivity.removeAll ( )
protected

Definition at line 52 of file GroupActivity.java.

52 {
53 activities.forEach((mob, activity) -> remove(mob));
54 activities.clear();
55 }

References activities.

Referenced by com.runehive.content.activity.lobby.LobbyManager.sequenceActive().

Here is the caller graph for this function:

◆ start()

void com.runehive.content.activity.GroupActivity.start ( )
protected

Starts the next activity stage.

Reimplemented from com.runehive.content.activity.Activity.

Reimplemented in com.runehive.content.activity.lobby.LobbyNode.

Definition at line 35 of file GroupActivity.java.

35 {
36 activities.values().forEach(Activity::start);
37 }

References activities, and com.runehive.content.activity.Activity.start().

Here is the call graph for this function:

Member Data Documentation

◆ activities

final Map<Mob, Activity> com.runehive.content.activity.GroupActivity.activities
protected

◆ nextInstance

int com.runehive.content.activity.GroupActivity.nextInstance
staticprivate

The next instance level.

Definition at line 22 of file GroupActivity.java.

Referenced by getNextInstance().


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