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

Handles the dwarf cannon. More...

Inheritance diagram for com.runehive.content.combat.cannon.Cannon:
Collaboration diagram for com.runehive.content.combat.cannon.Cannon:

Public Member Functions

void addToRegion (Region region)
 Adds this entity to the specified region.
 Cannon (String owner, Position position)
boolean equals (Object obj)
int getAmmunition ()
String getName ()
 Gets the name of this entity.
CustomGameObject getObject ()
String getOwner ()
Position getPosition ()
Rotation getRotation ()
Setup getStage ()
EntityType getType ()
 Gets the EntityType.
int hashCode ()
boolean isFiring ()
void register ()
 Registers an entity to the World.
void removeFromRegion (Region region)
 Removes this entity from the specified region.
void setAmmunition (int ammunition)
void setFiring (boolean firing)
void setObject (CustomGameObject object)
void setRotation (Rotation rotation)
void setStage (Setup stage)
void unregister ()
 Unregisters an entity from the World.
Public Member Functions inherited from com.runehive.game.world.entity.Entity
 Entity (Position position)
 Entity (Position position, boolean visible)
Position getCenterPosition ()
int getHeight ()
int getIndex ()
Region getRegion ()
int getX ()
int getY ()
boolean is (EntityType type)
final boolean isCustomObject ()
 Check if an entity is an object.
final boolean isRegistered ()
final boolean isStaticObject ()
 Check if an entity is an object.
boolean isValid ()
 Validates this npc based on its current region and registered state.
boolean isVisible ()
int length ()
void onStep ()
void setIndex (int index)
void setLength (int length)
void setPosition (Position position)
void setVisible (boolean visible)
void setWidth (int width)
void setX (int x)
void setY (int y)
void setZ (int z)
String toString ()
int width ()

Private Attributes

int ammunition
boolean firing
CustomGameObject object
final String owner
final Position position
Rotation rotation
Setup stage

Additional Inherited Members

Static Public Member Functions inherited from com.runehive.game.world.Interactable
static Interactable create (Position position)
 Creates a new instance of an Interactable.
static Interactable create (Position position, int width, int length)
 Creates a new instance of an Interactable.
Public Attributes inherited from com.runehive.game.world.entity.Entity
int instance = DEFAULT_INSTANCE
Static Public Attributes inherited from com.runehive.game.world.entity.Entity
static final int DEFAULT_INSTANCE = 0
Protected Member Functions inherited from com.runehive.game.world.entity.Entity
Entity destroy ()
 Destroys this entity.
void setRegistered (boolean registered)

Detailed Description

Handles the dwarf cannon.

Author
Daniel

Definition at line 19 of file Cannon.java.

Constructor & Destructor Documentation

◆ Cannon()

com.runehive.content.combat.cannon.Cannon.Cannon ( String owner,
Position position )

Definition at line 35 of file Cannon.java.

35 {
36 super(position);
37 this.owner = owner;
38 this.position = position;
39 this.ammunition = 0;
40 this.firing = false;
41 this.stage = Setup.NO_CANNON;
42 this.rotation = Rotation.NORTH;
43 this.object = new CustomGameObject(8, position);
44 }

References com.runehive.content.combat.cannon.CannonManager.Setup.NO_CANNON, com.runehive.content.combat.cannon.CannonManager.Rotation.NORTH, owner, and position.

Member Function Documentation

◆ addToRegion()

void com.runehive.content.combat.cannon.Cannon.addToRegion ( Region region)

Adds this entity to the specified region.

Parameters
regionThe region.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 116 of file Cannon.java.

116 {
117 region.getPlayers(getHeight()).stream().filter(Player::isValid).forEach(player -> player.send(new SendAddObject(object)));
118 }

References com.runehive.game.world.entity.Entity.getHeight(), com.runehive.game.world.region.Region.getPlayers(), and com.runehive.game.world.entity.mob.player.Player.isValid().

Referenced by register().

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

◆ equals()

boolean com.runehive.content.combat.cannon.Cannon.equals ( Object obj)

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 136 of file Cannon.java.

136 {
137 return false;
138 }

◆ getAmmunition()

int com.runehive.content.combat.cannon.Cannon.getAmmunition ( )

Definition at line 54 of file Cannon.java.

54 {
55 return ammunition;
56 }

References ammunition.

◆ getName()

String com.runehive.content.combat.cannon.Cannon.getName ( )

Gets the name of this entity.

Returns
The entity's name.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 126 of file Cannon.java.

126 {
127 return "Dwarf cannon";
128 }

◆ getObject()

CustomGameObject com.runehive.content.combat.cannon.Cannon.getObject ( )

Definition at line 78 of file Cannon.java.

78 {
79 return object;
80 }

References object.

◆ getOwner()

String com.runehive.content.combat.cannon.Cannon.getOwner ( )

Definition at line 46 of file Cannon.java.

46 {
47 return owner;
48 }

References owner.

◆ getPosition()

Position com.runehive.content.combat.cannon.Cannon.getPosition ( )
Returns
the current location

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 50 of file Cannon.java.

50 {
51 return position;
52 }

References position.

Referenced by register().

Here is the caller graph for this function:

◆ getRotation()

Rotation com.runehive.content.combat.cannon.Cannon.getRotation ( )

Definition at line 86 of file Cannon.java.

86 {
87 return rotation;
88 }

References rotation.

◆ getStage()

Setup com.runehive.content.combat.cannon.Cannon.getStage ( )

Definition at line 70 of file Cannon.java.

70 {
71 return stage;
72 }

References stage.

◆ getType()

EntityType com.runehive.content.combat.cannon.Cannon.getType ( )

Gets the EntityType.

Returns
The EntityType.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 131 of file Cannon.java.

131 {
132 return EntityType.DWARF_CANNON;
133 }

References com.runehive.game.world.entity.EntityType.DWARF_CANNON.

◆ hashCode()

int com.runehive.content.combat.cannon.Cannon.hashCode ( )

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 141 of file Cannon.java.

141 {
142 return 0;
143 }

◆ isFiring()

boolean com.runehive.content.combat.cannon.Cannon.isFiring ( )

Definition at line 62 of file Cannon.java.

62 {
63 return firing;
64 }

References firing.

◆ register()

void com.runehive.content.combat.cannon.Cannon.register ( )

Registers an entity to the World.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 95 of file Cannon.java.

95 {
96 if (!isRegistered()) {
97 Region region = getRegion();
98 setRegistered(true);
99
100 if (region == null) {
101 setPosition(getPosition());
102 } else if (!region.containsObject(getHeight(), object)) {
103 addToRegion(region);
104 }
105 }
106 }

References addToRegion(), com.runehive.game.world.region.Region.containsObject(), com.runehive.game.world.entity.Entity.getHeight(), getPosition(), com.runehive.game.world.entity.Entity.getRegion(), com.runehive.game.world.entity.Entity.isRegistered(), com.runehive.game.world.entity.Entity.setPosition(), and com.runehive.game.world.entity.Entity.setRegistered().

Here is the call graph for this function:

◆ removeFromRegion()

void com.runehive.content.combat.cannon.Cannon.removeFromRegion ( Region region)

Removes this entity from the specified region.

Parameters
regionThe region.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 121 of file Cannon.java.

121 {
122 region.getPlayers(getHeight()).stream().filter(Player::isValid).forEach(player -> player.send(new SendRemoveObject(object)));
123 }

References com.runehive.game.world.entity.Entity.getHeight(), com.runehive.game.world.region.Region.getPlayers(), and com.runehive.game.world.entity.mob.player.Player.isValid().

Here is the call graph for this function:

◆ setAmmunition()

void com.runehive.content.combat.cannon.Cannon.setAmmunition ( int ammunition)

Definition at line 58 of file Cannon.java.

58 {
59 this.ammunition = ammunition;
60 }

References ammunition.

◆ setFiring()

void com.runehive.content.combat.cannon.Cannon.setFiring ( boolean firing)

Definition at line 66 of file Cannon.java.

66 {
67 this.firing = firing;
68 }

References firing.

◆ setObject()

void com.runehive.content.combat.cannon.Cannon.setObject ( CustomGameObject object)

Definition at line 82 of file Cannon.java.

82 {
83 this.object = object;
84 }

References object.

◆ setRotation()

void com.runehive.content.combat.cannon.Cannon.setRotation ( Rotation rotation)

Definition at line 90 of file Cannon.java.

90 {
91 this.rotation = rotation;
92 }

References rotation.

◆ setStage()

void com.runehive.content.combat.cannon.Cannon.setStage ( Setup stage)

Definition at line 74 of file Cannon.java.

74 {
75 this.stage = stage;
76 }

References stage.

◆ unregister()

void com.runehive.content.combat.cannon.Cannon.unregister ( )

Unregisters an entity from the World.

Reimplemented from com.runehive.game.world.entity.Entity.

Definition at line 109 of file Cannon.java.

109 {
110 if (isRegistered()) {
111 destroy();
112 }
113 }

References com.runehive.game.world.entity.Entity.destroy(), and com.runehive.game.world.entity.Entity.isRegistered().

Here is the call graph for this function:

Member Data Documentation

◆ ammunition

int com.runehive.content.combat.cannon.Cannon.ammunition
private

Definition at line 27 of file Cannon.java.

Referenced by getAmmunition(), and setAmmunition().

◆ firing

boolean com.runehive.content.combat.cannon.Cannon.firing
private

Definition at line 29 of file Cannon.java.

Referenced by isFiring(), and setFiring().

◆ object

CustomGameObject com.runehive.content.combat.cannon.Cannon.object
private

Definition at line 25 of file Cannon.java.

Referenced by getObject(), and setObject().

◆ owner

final String com.runehive.content.combat.cannon.Cannon.owner
private

Definition at line 21 of file Cannon.java.

Referenced by Cannon(), and getOwner().

◆ position

final Position com.runehive.content.combat.cannon.Cannon.position
private

Definition at line 23 of file Cannon.java.

Referenced by Cannon(), and getPosition().

◆ rotation

Rotation com.runehive.content.combat.cannon.Cannon.rotation
private

Definition at line 33 of file Cannon.java.

Referenced by getRotation(), and setRotation().

◆ stage

Setup com.runehive.content.combat.cannon.Cannon.stage
private

Definition at line 31 of file Cannon.java.

Referenced by getStage(), and setStage().


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