Rename Character to Mob; make Entity an abstract class.

This commit is contained in:
Major-
2013-11-22 19:37:30 +00:00
parent f40f885008
commit ea115562c0
14 changed files with 42 additions and 81 deletions
-10
View File
@@ -1,10 +0,0 @@
require 'java'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.event.impl.PositionEvent'
java_import 'org.apollo.game.event.impl.SetTileItemEvent'
on :command, :drop, RIGHTS_ADMIN do |player, command|
player.send(PositionEvent.new(player.position, player.position))
player.send(SetTileItemEvent.new(70, 1))
end
-6
View File
@@ -1,6 +0,0 @@
require 'java'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.event.impl.PositionEvent'
java_import 'org.apollo.game.event.impl.SetTileItemEvent'
+2 -2
View File
@@ -1,6 +1,6 @@
package org.apollo.game.action; package org.apollo.game.action;
import org.apollo.game.model.Character; import org.apollo.game.model.Mob;
import org.apollo.game.scheduling.ScheduledTask; import org.apollo.game.scheduling.ScheduledTask;
/** /**
@@ -12,7 +12,7 @@ import org.apollo.game.scheduling.ScheduledTask;
* *
* @author Graham * @author Graham
*/ */
public abstract class Action<T extends Character> extends ScheduledTask { public abstract class Action<T extends Mob> extends ScheduledTask {
/** /**
* The character performing the action. * The character performing the action.
@@ -1,6 +1,6 @@
package org.apollo.game.action; package org.apollo.game.action;
import org.apollo.game.model.Character; import org.apollo.game.model.Mob;
import org.apollo.game.model.Position; import org.apollo.game.model.Position;
/** /**
@@ -9,7 +9,7 @@ import org.apollo.game.model.Position;
* @author Blake * @author Blake
* @author Graham * @author Graham
*/ */
public abstract class DistancedAction<T extends Character> extends Action<T> { public abstract class DistancedAction<T extends Mob> extends Action<T> {
/** /**
* The delay once the threshold is reached. * The delay once the threshold is reached.
+10 -4
View File
@@ -1,25 +1,31 @@
package org.apollo.game.model; package org.apollo.game.model;
/** /**
* Represents an in-game entity, such as a character, object, projectile etc. * Represents an in-game entity, such as a character, object, projectile etc.
* *
* @author Major * @author Major
*/ */
public interface Entity { public abstract class Entity {
/**
* The position of the entity.
*/
protected Position position;
/** /**
* Gets the {@link EntityType} of this entity. * Gets the {@link EntityType} of this entity.
* *
* @return The type. * @return The type.
*/ */
public EntityType getEntityType(); public abstract EntityType getEntityType();
/** /**
* Gets the position of this entity. * Gets the position of this entity.
* *
* @return The position. * @return The position.
*/ */
public Position getPosition(); public Position getPosition() {
return position;
}
} }
@@ -13,11 +13,11 @@ import org.apollo.game.sync.block.SynchronizationBlockSet;
import org.apollo.util.CharacterRepository; import org.apollo.util.CharacterRepository;
/** /**
* A {@link Character} is a living creature in the world, such as a player or NPC. * A {@link Mob} is a living entity in the world, such as a player or NPC.
* *
* @author Graham * @author Graham
*/ */
public abstract class Character implements Entity { public abstract class Mob extends Entity {
/** /**
* The character's current action. * The character's current action.
@@ -70,11 +70,6 @@ public abstract class Character implements Entity {
*/ */
private final List<Player> localPlayers = new ArrayList<Player>(); private final List<Player> localPlayers = new ArrayList<Player>();
/**
* The current position of this character.
*/
private Position position;
/** /**
* The second direction. * The second direction.
*/ */
@@ -100,7 +95,7 @@ public abstract class Character implements Entity {
* *
* @param position The initial position of this character. * @param position The initial position of this character.
*/ */
public Character(Position position) { public Mob(Position position) {
this.position = position; this.position = position;
init(); init();
} }
@@ -286,8 +281,8 @@ public abstract class Character implements Entity {
/** /**
* Sends an {@link Event} to either: * Sends an {@link Event} to either:
* <ul> * <ul>
* <li>The client if this {@link Character} is a {@link Player}.</li> * <li>The client if this {@link Mob} is a {@link Player}.</li>
* <li>The AI routines if this {@link Character} is an NPC</li> * <li>The AI routines if this {@link Mob} is an NPC</li>
* </ul> * </ul>
* *
* @param event The event. * @param event The event.
+2 -2
View File
@@ -4,11 +4,11 @@ import org.apollo.game.event.Event;
import org.apollo.game.model.def.NpcDefinition; import org.apollo.game.model.def.NpcDefinition;
/** /**
* An {@link Npc} is a {@link Character} that is not being controlled by a player. * An {@link Npc} is a {@link Mob} that is not being controlled by a player.
* *
* @author Major * @author Major
*/ */
public class Npc extends Character { public class Npc extends Mob {
/** /**
* This npc's definition. * This npc's definition.
+2 -2
View File
@@ -28,11 +28,11 @@ import org.apollo.security.PlayerCredentials;
import org.apollo.util.Point; import org.apollo.util.Point;
/** /**
* A {@link Player} is a {@link Character} that a user is controlling. * A {@link Player} is a {@link Mob} that a user is controlling.
* *
* @author Graham * @author Graham
*/ */
public final class Player extends Character { public final class Player extends Mob {
/** /**
* An enumeration with the different privilege levels a player can have. * An enumeration with the different privilege levels a player can have.
+3 -3
View File
@@ -5,7 +5,7 @@ import java.util.Deque;
import java.util.Queue; import java.util.Queue;
/** /**
* A queue of {@link Direction}s which a {@link Character} will follow. * A queue of {@link Direction}s which a {@link Mob} will follow.
* *
* @author Graham * @author Graham
*/ */
@@ -53,7 +53,7 @@ public final class WalkingQueue {
/** /**
* The character whose walking queue this is. * The character whose walking queue this is.
*/ */
private final Character character; private final Mob character;
/** /**
* The old queue of directions. * The old queue of directions.
@@ -75,7 +75,7 @@ public final class WalkingQueue {
* *
* @param character The character. * @param character The character.
*/ */
public WalkingQueue(Character character) { public WalkingQueue(Mob character) {
this.character = character; this.character = character;
} }
+1 -11
View File
@@ -10,18 +10,13 @@ import org.apollo.game.model.def.ObjectDefinition;
* *
* @author Major * @author Major
*/ */
public final class GameObject implements Entity { public final class GameObject extends Entity {
/** /**
* The object definition. * The object definition.
*/ */
private final ObjectDefinition definition; private final ObjectDefinition definition;
/**
* The position of the game object.
*/
private final Position position;
/** /**
* Creates the game object. * Creates the game object.
* *
@@ -46,9 +41,4 @@ public final class GameObject implements Entity {
return EntityType.GAME_OBJECT; return EntityType.GAME_OBJECT;
} }
@Override
public Position getPosition() {
return position;
}
} }
@@ -11,7 +11,7 @@ import org.apollo.game.model.def.ObjectDefinition;
* @author Chris Fletcher * @author Chris Fletcher
* @author Major * @author Major
*/ */
public final class StaticObject implements Entity { public final class StaticObject extends Entity {
/** /**
* The object's definition. * The object's definition.
@@ -23,11 +23,6 @@ public final class StaticObject implements Entity {
*/ */
private final int id; private final int id;
/**
* The object's position.
*/
private final Position position;
/** /**
* The object's rotation. * The object's rotation.
*/ */
@@ -77,15 +72,6 @@ public final class StaticObject implements Entity {
return id; return id;
} }
/**
* Gets the position of this object.
*
* @return The object's position.
*/
public Position getPosition() {
return position;
}
/** /**
* Gets the object's rotation. * Gets the object's rotation.
* *
@@ -1,6 +1,6 @@
package org.apollo.game.scheduling.impl; package org.apollo.game.scheduling.impl;
import org.apollo.game.model.Character; import org.apollo.game.model.Mob;
import org.apollo.game.scheduling.ScheduledTask; import org.apollo.game.scheduling.ScheduledTask;
/** /**
@@ -14,14 +14,14 @@ public final class SkillNormalizationTask extends ScheduledTask {
/** /**
* The character. * The character.
*/ */
private final Character character; private final Mob character;
/** /**
* Creates the skill normalization task. * Creates the skill normalization task.
* *
* @param character The character. * @param character The character.
*/ */
public SkillNormalizationTask(Character character) { public SkillNormalizationTask(Mob character) {
super(100, false); super(100, false);
this.character = character; this.character = character;
} }
@@ -9,7 +9,7 @@ package org.apollo.game.sync.block;
public class HitUpdateBlock extends SynchronizationBlock { public class HitUpdateBlock extends SynchronizationBlock {
/** /**
* The {@link org.apollo.game.model.Character}'s current health. * The {@link org.apollo.game.model.Mob}'s current health.
*/ */
private final int currentHealth; private final int currentHealth;
@@ -19,7 +19,7 @@ public class HitUpdateBlock extends SynchronizationBlock {
private final int damage; private final int damage;
/** /**
* The {@link org.apollo.game.model.Character}'s maximum health. * The {@link org.apollo.game.model.Mob}'s maximum health.
*/ */
private final int maximumHealth; private final int maximumHealth;
@@ -33,8 +33,8 @@ public class HitUpdateBlock extends SynchronizationBlock {
* *
* @param hitDamage The damage dealt by the hit. * @param hitDamage The damage dealt by the hit.
* @param hitType The type of hit. * @param hitType The type of hit.
* @param currentHealth The current health of the {@link org.apollo.game.model.Character}. * @param currentHealth The current health of the {@link org.apollo.game.model.Mob}.
* @param maximumHealth The maximum health of the {@link org.apollo.game.model.Character}. * @param maximumHealth The maximum health of the {@link org.apollo.game.model.Mob}.
*/ */
public HitUpdateBlock(int hitDamage, int hitType, int currentHealth, int maximumHealth) { public HitUpdateBlock(int hitDamage, int hitType, int currentHealth, int maximumHealth) {
damage = hitDamage; damage = hitDamage;
@@ -44,7 +44,7 @@ public class HitUpdateBlock extends SynchronizationBlock {
} }
/** /**
* Gets the current health of the {@link org.apollo.game.model.Character}. * Gets the current health of the {@link org.apollo.game.model.Mob}.
* *
* @return The current health; * @return The current health;
*/ */
@@ -62,7 +62,7 @@ public class HitUpdateBlock extends SynchronizationBlock {
} }
/** /**
* Gets the maximum health of the {@link org.apollo.game.model.Character}. * Gets the maximum health of the {@link org.apollo.game.model.Mob}.
* *
* @return The maximum health. * @return The maximum health.
*/ */
+5 -5
View File
@@ -3,15 +3,15 @@ package org.apollo.util;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.apollo.game.model.Character; import org.apollo.game.model.Mob;
/** /**
* A {@link CharacterRepository} is a repository of {@link Character}s that are currently active in the game world. * A {@link CharacterRepository} is a repository of {@link Mob}s that are currently active in the game world.
* *
* @author Graham * @author Graham
* @param <T> The type of character. * @param <T> The type of character.
*/ */
public final class CharacterRepository<T extends Character> implements Iterable<T> { public final class CharacterRepository<T extends Mob> implements Iterable<T> {
/** /**
* The {@link Iterator} implementation for the {@link CharacterRepository} class. * The {@link Iterator} implementation for the {@link CharacterRepository} class.
@@ -75,7 +75,7 @@ public final class CharacterRepository<T extends Character> implements Iterable<
/** /**
* The array of characters in this repository. * The array of characters in this repository.
*/ */
private final Character[] characters; private final Mob[] characters;
/** /**
* The position of the next free index. * The position of the next free index.
@@ -93,7 +93,7 @@ public final class CharacterRepository<T extends Character> implements Iterable<
* @param capacity The maximum number of characters that can be present in the repository. * @param capacity The maximum number of characters that can be present in the repository.
*/ */
public CharacterRepository(int capacity) { public CharacterRepository(int capacity) {
this.characters = new Character[capacity]; this.characters = new Mob[capacity];
} }
/** /**