1package com.runehive.content.activity;
3import com.runehive.Config;
4import com.runehive.content.activity.panel.Activity_Panel;
5import com.runehive.content.consume.FoodData;
6import com.runehive.content.event.EventDispatcher;
7import com.runehive.content.event.InteractionEvent;
8import com.runehive.content.event.InteractionEventListener;
9import com.runehive.content.event.impl.*;
10import com.runehive.game.Animation;
11import com.runehive.game.Graphic;
12import com.runehive.game.world.World;
13import com.runehive.game.world.entity.Entity;
14import com.runehive.game.world.entity.mob.Mob;
15import com.runehive.game.world.entity.mob.npc.NpcDeath;
16import com.runehive.game.world.entity.mob.player.Player;
17import com.runehive.game.world.items.Item;
18import com.runehive.game.world.items.containers.equipment.EquipmentType;
20import java.util.Optional;
21import java.util.function.Consumer;
22import java.util.function.Predicate;
34 protected static final int START = 0;
37 protected static final int FINISH = -1;
40 protected static final int PAUSE = -2;
60 public static <T extends Activity> Optional<T>
search(
Player player, Class<T> clazz) {
64 return Optional.empty();
68 return Optional.of(clazz.cast(
activity));
71 return Optional.empty();
74 public static boolean evaluate(
Mob mob, Predicate<Activity> predicate) {
75 return mob !=
null && mob.activity !=
null && predicate.test(mob.
activity);
169 protected void restart(
int delay, Runnable runnable) {
184 return Optional.ofNullable(
panel);
210 public void remove(
Mob mob) {
211 getListener().ifPresent(mob.getCombat()::removeListener);
214 mob.getNpc().unregister();
217 mob.getPlayer().setActivity(
null);
226 if (mobs.length != 0)
227 for (
Mob mob : mobs) {
228 if (mob.isRegistered())
282 protected Optional<? extends ActivityListener<? extends Activity>>
getListener() {
283 return Optional.empty();
The class that contains setting-related constants for the server.
static final Position DEFAULT_POSITION
The default, i.e.
final int cooldown
The sequencing cooldown.
Activity(int cooldown, int instance)
Constructs a new SequencedMinigame object.
void setPause(boolean pause)
Sets the pause state of the activity.
boolean canTeleport(Player player)
Called when the player attempts to teleport.
boolean canDrinkPotions(Player player)
final boolean isPaused()
Checks if the cooldown is paused.
abstract void finish()
Finishes the activity.
boolean clickItem(Player player, ItemInteractionEvent event)
static final int PAUSE
The 'pause' cooldown id.
void onLogout(Player player)
Called when the player logs out.
boolean canSpellCast(Player player)
final void resetCooldown()
Resets the remaining ticks to the cached cooldown ticks.
static final int FINISH
The 'finish' cooldown id.
static< T extends Activity > Optional< T > search(Player player, Class< T > clazz)
boolean canEat(Player player, FoodData foodType)
int instance
The activity instance level.
void onDeath(Mob mob)
Called when the player die.
boolean itemContainerAction(Player player, ItemContainerInteractionEvent event)
boolean clickObject(Player player, ObjectInteractionEvent event)
abstract void start()
Starts the next activity stage.
void setPanel(Activity_Panel panel)
Sets the activity panel.
boolean pickupItem(Player player, PickupItemInteractionEvent event)
boolean canLogout(Player player)
Optional<? extends ActivityListener<? extends Activity > > getListener()
Gets an Optional of the ActivityListener for this activity.
static final int START
The 'start' cooldown id.
void onRegionChange(Player player)
Called when the player changes region.
boolean useItem(Player player, ItemOnItemInteractionEvent event)
int ticks
The remaining game ticks.
abstract void cleanup()
Cleans up the activity when finished.
abstract ActivityType getType()
int getInstance()
Gets this activity's instance level.
int getTicks()
Gets the current ticks.
void restart(int delay, Runnable runnable)
ActivityDeathType deathType()
final void pause()
Sets the cooldown flag to PAUSE.
void removeAll(Mob... mobs)
Removes all mobs from the activity.
boolean clickNpc(Player player, NpcInteractionEvent event)
boolean canEquipItem(Player player, Item item, EquipmentType type)
void add(Mob mob)
Adds a mob to the activity.
boolean onEvent(Player player, InteractionEvent interactionEvent)
boolean useItem(Player player, ItemOnObjectInteractionEvent event)
void cooldown(int cooldown)
Applies a cooldown.
static boolean evaluate(Mob mob, Predicate< Activity > predicate)
final void finishCooldown()
Sets the cooldown flag to FINISH.
void sequence()
Sequences the activity.
boolean clickButton(Player player, ClickButtonInteractionEvent event)
void update()
The update method.
Activity_Panel panel
The panel for this activity.
boolean canUseSpecial(Player player)
void setInstance(int instance)
boolean canUsePrayer(Player player)
Optional< Activity_Panel > getPanel()
Gets an optional of the activity panel.
static void forActivity(Mob mob, Consumer< Activity > consumer)
void dispatch(InteractionType type, EventHandler eventHandler)
Class that models a single animation used by an entity.
static final Animation RESET
Represents a single graphic that can be used by entities.
static final Graphic RESET
Represents the game world.
static void schedule(Task task)
Submits a new event.
Represents a character in the game world, i.e.
abstract void register()
Registers an entity to the World.
final boolean isRegistered()
static final int DEFAULT_INSTANCE
abstract Combat<? extends Mob > getCombat()
The combat of the mob.
void move(Position position)
Moves the mob to a set position.
final boolean isNpc()
Check if an entity is an npc.
void setActivity(Activity activity)
This class represents a character controlled by a player.
The container class that represents an item that can be interacted with.
Created by Daniel on 2018-01-28.
Holds all activity types that are timed.
ITEM_CONTAINER_INTERACTION_EVENT
The enumerated types of a players equipped item slots.