RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.content.combat.cannon.CannonManager Class Reference

Classes

enum  Rotation
enum  Setup

Static Public Member Functions

static void drop (Player player, Cannon cannon)
static void empty (Player player)
static Projectile getCannonFire ()
static Npc[] getNpc (Cannon cannon)
static void load (Player player)
static void logout (Player player)
static void pickup (Player player)
static void rotate (Cannon cannon)
static void test (Player player)

Static Package Attributes

static Map< String, CannonACTIVE_CANNONS = new HashMap<>()

Detailed Description

Definition at line 18 of file CannonManager.java.

Member Function Documentation

◆ drop()

void com.runehive.content.combat.cannon.CannonManager.drop ( Player player,
Cannon cannon )
static

Definition at line 46 of file CannonManager.java.

46 {
47 if (ACTIVE_CANNONS.containsKey(player.getName())) {
48 player.send(new SendMessage("You already have a cannon active!"));
49 return;
50 }
51 if(Area.inCatacombs(player)) {
52 player.send(new SendMessage("You cannot set up a cannon here!"));
53 return;
54 }
55
56 if (cannon.getStage().ordinal() != 0) {
57 player.send(new SendMessage("You have already started setting up a cannon!"));
58 return;
59 }
60
61 for (Cannon other : ACTIVE_CANNONS.values()) {
62 if (other.getPosition().isWithinDistance(player.getPosition(), 5)) {
63 player.send(new SendMessage("You are trying to build too close to another cannon!"));
64 return;
65 }
66 }
67
68 World.schedule(new CannonBuild(player, cannon));
69 }

References ACTIVE_CANNONS, com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.Entity.getPosition(), com.runehive.game.world.position.Area.inCatacombs(), com.runehive.game.world.World.schedule(), and com.runehive.game.world.entity.mob.player.Player.send().

Referenced by test().

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

◆ empty()

void com.runehive.content.combat.cannon.CannonManager.empty ( Player player)
static

Definition at line 97 of file CannonManager.java.

97 {
98 Cannon cannon = ACTIVE_CANNONS.get(player.getName());
99
100 if (cannon == null) {
101 player.send(new SendMessage("This is not your cannon!"));
102 return;
103 }
104
105 if (!cannon.getOwner().equalsIgnoreCase(player.getName())) {
106 player.send(new SendMessage("This is not your cannon!"));
107 return;
108 }
109
110 if(cannon.getAmmunition() != 0)
111 player.inventory.add(new Item(2, cannon.getAmmunition()));
112
113 cannon.setFiring(false);
114 cannon.setAmmunition(0);
115 }

References ACTIVE_CANNONS, com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.inventory, and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ getCannonFire()

Projectile com.runehive.content.combat.cannon.CannonManager.getCannonFire ( )
static

Definition at line 180 of file CannonManager.java.

180 {
181 Projectile p = new Projectile(53);
182 p.setStartHeight(50);
183 p.setEndHeight(50);
184 return p;
185 }

References com.runehive.game.Projectile.setEndHeight(), and com.runehive.game.Projectile.setStartHeight().

Referenced by com.runehive.content.combat.cannon.CannonFireAction.execute().

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

◆ getNpc()

Npc[] com.runehive.content.combat.cannon.CannonManager.getNpc ( Cannon cannon)
static

Definition at line 187 of file CannonManager.java.

187 {
188 ArrayList<Npc> attack = new ArrayList<>();
189
190 for (Npc npc : World.getNpcs()) {
191 if (npc == null) {
192 continue;
193 }
194
195 if (!Utility.withinDistance(npc, cannon, Region.VIEW_DISTANCE)) {
196 continue;
197 }
198
199 if (!npc.definition.isAttackable()) {
200 continue;
201 }
202
203 attack.add(npc);
204 }
205
206 Npc[] npc = new Npc[attack.size()];
207
208 for (int i = 0; i < npc.length; i++) {
209 npc[i] = attack.get(i);
210 }
211
212 return npc;
213 }

References com.runehive.game.world.World.getNpcs(), com.runehive.game.world.entity.Entity.length, com.runehive.game.world.region.Region.VIEW_DISTANCE, and com.runehive.util.Utility.withinDistance().

Referenced by com.runehive.content.combat.cannon.CannonFireAction.execute().

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

◆ load()

void com.runehive.content.combat.cannon.CannonManager.load ( Player player)
static

Definition at line 134 of file CannonManager.java.

134 {
135 Cannon cannon = ACTIVE_CANNONS.get(player.getName());
136
137 if (cannon == null) {
138 player.send(new SendMessage("This is not your cannon!"));
139 return;
140 }
141
142 if (!cannon.getOwner().equalsIgnoreCase(player.getName())) {
143 player.send(new SendMessage("This is not your cannon!"));
144 return;
145 }
146
147 if (!player.inventory.contains(2)) {
148 player.send(new SendMessage("You do not have any Cannon balls."));
149 return;
150 }
151
152 int needed = 30 - cannon.getAmmunition();
153
154 if (needed == 0) {
155 player.send(new SendMessage("Your cannon is full."));
156 return;
157 }
158
159 int cannon_balls = player.inventory.computeAmountForId(2);
160
161 if (cannon_balls <= needed) {
162 player.inventory.remove(2, cannon_balls);
163 player.send(new SendMessage("You load the last of your cannon balls"));
164 cannon.setAmmunition(cannon.getAmmunition() + cannon_balls);
165 } else {
166 player.inventory.remove(2, needed);
167 player.send(new SendMessage("You load " + needed + " balls into the cannon."));
168 cannon.setAmmunition(cannon.getAmmunition() + needed);
169 }
170
171 if (cannon.isFiring()) {
172 player.send(new SendMessage("The cannon is already firing!"));
173 return;
174 }
175
176 cannon.setFiring(true);
177 World.schedule(new CannonFireAction(player, cannon));
178 }

References ACTIVE_CANNONS, com.runehive.game.world.items.containers.ItemContainer.computeAmountForId(), com.runehive.game.world.items.containers.ItemContainer.contains(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.inventory, com.runehive.game.world.items.containers.ItemContainer.remove(), com.runehive.game.world.World.schedule(), and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ logout()

void com.runehive.content.combat.cannon.CannonManager.logout ( Player player)
static

Definition at line 117 of file CannonManager.java.

117 {
118 Cannon cannon = ACTIVE_CANNONS.get(player.getName());
119
120 if(cannon == null) return;
121
122
123 if(cannon.getAmmunition() != 0)
124 player.inventory.add(new Item(2, cannon.getAmmunition()));
125
126 int[] ids = { 6, 8, 10, 12 };
127 for(int index = 0; index < ids.length; index++)
128 player.inventory.add(new Item(ids[index]));
129
130 cannon.unregister();
131 ACTIVE_CANNONS.remove(player.getName());
132 }
val index

References ACTIVE_CANNONS, com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.player.Player.getName(), and com.runehive.game.world.entity.mob.player.Player.inventory.

Referenced by com.runehive.game.task.impl.PlayerRemovalTask.tick().

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

◆ pickup()

void com.runehive.content.combat.cannon.CannonManager.pickup ( Player player)
static

Definition at line 71 of file CannonManager.java.

71 {
72 Cannon cannon = ACTIVE_CANNONS.get(player.getName());
73
74 if (cannon == null) {
75 player.send(new SendMessage("This is not your cannon!"));
76 return;
77 }
78
79 if (!cannon.getOwner().equalsIgnoreCase(player.getName())) {
80 player.send(new SendMessage("This is not your cannon!"));
81 return;
82 }
83
84 player.animate(new Animation(827));
85
86 if(cannon.getAmmunition() != 0)
87 player.inventory.add(new Item(2, cannon.getAmmunition()));
88
89 int[] ids = { 6, 8, 10, 12 };
90 for(int index = 0; index < ids.length; index++)
91 player.inventory.add(new Item(ids[index]));
92
93 cannon.unregister();
94 ACTIVE_CANNONS.remove(player.getName());
95 }

References ACTIVE_CANNONS, com.runehive.game.world.items.containers.ItemContainer.add(), com.runehive.game.world.entity.mob.Mob.animate(), com.runehive.game.world.entity.mob.player.Player.getName(), com.runehive.game.world.entity.mob.player.Player.inventory, and com.runehive.game.world.entity.mob.player.Player.send().

Here is the call graph for this function:

◆ rotate()

void com.runehive.content.combat.cannon.CannonManager.rotate ( Cannon cannon)
static

Definition at line 215 of file CannonManager.java.

215 {
216 switch (cannon.getRotation()) {
217 case NORTH:
218 World.sendObjectAnimation(516, cannon.getObject());
219 break;
220 case NORTH_EAST:
221 World.sendObjectAnimation(517, cannon.getObject());
222 break;
223 case EAST:
224 World.sendObjectAnimation(518, cannon.getObject());
225 break;
226 case SOUTH_EAST:
227 World.sendObjectAnimation(519, cannon.getObject());
228 break;
229 case SOUTH:
230 World.sendObjectAnimation(520, cannon.getObject());
231 break;
232 case SOUTH_WEST:
233 World.sendObjectAnimation(521, cannon.getObject());
234 break;
235 case WEST:
236 World.sendObjectAnimation(514, cannon.getObject());
237 break;
238 case NORTH_WEST:
239 World.sendObjectAnimation(515, cannon.getObject());
240 break;
241 }
242 }

References com.runehive.game.world.World.sendObjectAnimation().

Referenced by com.runehive.content.combat.cannon.CannonFireAction.execute().

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

◆ test()

void com.runehive.content.combat.cannon.CannonManager.test ( Player player)
static

Definition at line 42 of file CannonManager.java.

42 {
43 drop(player, new Cannon(player.getName(), player.getPosition()));
44 }

References drop(), com.runehive.game.world.entity.mob.player.Player.getName(), and com.runehive.game.world.entity.Entity.getPosition().

Here is the call graph for this function:

Member Data Documentation

◆ ACTIVE_CANNONS

Map<String, Cannon> com.runehive.content.combat.cannon.CannonManager.ACTIVE_CANNONS = new HashMap<>()
staticpackage

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