Move some classes into the new org.apollo.game.model.entity package, and update plugins and classes that reference these.

This commit is contained in:
Major-
2014-07-03 01:02:02 +01:00
parent 5b173fc7ae
commit 9d8e7cda0a
116 changed files with 274 additions and 190 deletions
+1 -1
View File
@@ -18,8 +18,8 @@ java_import 'org.apollo.game.command.CommandListener'
java_import 'org.apollo.game.event.handler.EventHandler'
java_import 'org.apollo.game.login.LoginListener'
java_import 'org.apollo.game.login.LogoutListener'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.entity.Player'
java_import 'org.apollo.game.model.settings.PrivilegeLevel'
java_import 'org.apollo.game.scheduling.ScheduledTask'
+1
View File
@@ -22,5 +22,6 @@ on :command, :graphic, RIGHTS_MOD do |player, command|
return
end
player.send(DisplayCrossbonesEvent.new(true ))
player.play_graphic(Graphic.new(args[0].to_i))
end
+2 -2
View File
@@ -1,11 +1,11 @@
require 'java'
java_import 'org.apollo.game.model.Entity'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.def.ItemDefinition'
java_import 'org.apollo.game.model.def.NpcDefinition'
java_import 'org.apollo.game.model.def.ObjectDefinition'
java_import 'org.apollo.game.model.entity.Entity'
java_import 'org.apollo.game.model.entity.Player'
on :command, :lookup, RIGHTS_ADMIN do |player, command|
args = command.arguments.to_a
+1 -1
View File
@@ -1,8 +1,8 @@
require 'java'
java_import 'org.apollo.game.model.Npc'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.Position'
java_import 'org.apollo.game.model.entity.Npc'
# An array of npcs that cannot be spawned.
blacklist = []
+2 -2
View File
@@ -1,6 +1,6 @@
require 'java'
java_import 'org.apollo.game.model.SkillSet'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.SkillSet'
java_import 'org.apollo.game.model.entity.Skill'
# Maximises the player's skill set.
on :command, :max, RIGHTS_ADMIN do |player, command|
+2 -2
View File
@@ -1,8 +1,8 @@
require 'java'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.Skill'
java_import 'org.apollo.game.model.entity.Player'
EAT_FOOD_SOUND = 317
+1 -1
View File
@@ -1,6 +1,6 @@
require 'java'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.Skill'
DRINK_POTION_SOUND = 334
+1 -1
View File
@@ -1,7 +1,7 @@
require 'java'
java_import 'org.apollo.game.action.DistancedAction'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.Skill'
# TODO: this shouldn't use the punch animation/delay, but should use the one
# from the active weapon/attack style (according to Scu11 anyway).
+6 -9
View File
@@ -1,16 +1,11 @@
require 'java'
java_import 'org.apollo.game.model.Entity'
java_import 'org.apollo.game.model.entity.Entity'
# Maps attribute names (i.e. symbols) to attribute definitions.
ATTRIBUTE_DEFINITIONS = {}
class Entity
# The map of strings to attributes.
def attributes
@attributes ||= {}
end
# Overridies method_missing
def method_missing(symbol, *args)
@@ -20,11 +15,13 @@ class Entity
raise "Error - expected argument count of 1, received #{args.length}" unless args.length == 1
name = name[0...-1].strip # Drop the equals and preceeding whitespace
attributes[name] = args[0]
attributes[name] = args[0].is_a?(Symbol) ? args[0].to_s : args[0]
elsif ATTRIBUTE_DEFINITIONS[name] == nil
super(symbol, *args)
else
return attributes[name] || ATTRIBUTE_DEFINITIONS[name].default
if attributes[name] == nil then return ATTRIBUTE_DEFINITIONS[name].default end
return ATTRIBUTE_DEFINITIONS[name].type == :symbol ? attributes[name].to_sym : attributes[name]
end
end
@@ -36,7 +33,7 @@ end
# An attribute belonging to an entity.
class AttributeDefinition
attr_reader :default, :persistence
attr_reader :default, :type, :persistence
def initialize(default, persistence=:transient)
@default = default
+20 -27
View File
@@ -3,10 +3,10 @@ require 'java'
java_import 'org.apollo.game.action.Action'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Graphic'
java_import 'org.apollo.game.model.Npc'
java_import 'org.apollo.game.model.Position'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.def.NpcDefinition'
java_import 'org.apollo.game.model.entity.Npc'
# Information about npc spawning
#
@@ -61,16 +61,12 @@ end
# Applies a decoded hash (one aquired using parse_hash) to the specified npc.
def apply_decoded_hash(npc, hash)
hash.each do |key, value|
if key == :face
npc.turn_to(value)
elsif key == :boundary
npc.boundary = value
elsif key == :spawn_animation
npc.play_animation(Animation.new(value))
elsif key == :spawn_graphic
npc.play_graphic(Graphic.new(value))
else
raise "Unrecognised key #{key} - value #{value}."
case key
when :face then npc.turn_to(value)
when :boundary then npc.boundary = value
when :spawn_animation then npc.play_animation(Animation.new(value))
when :spawn_graphic then npc.play_graphic(Graphic.new(value))
else raise "Unrecognised key #{key} - value #{value}."
end
end
end
@@ -78,23 +74,20 @@ end
# Parses the remaining key-value pairs in the hash.
def decode_hash(position, hash)
decoded = {}
hash.each do |key, value|
if key == :face
facing_position = direction_to_position(value, position)
decoded[:face] = facing_position
elsif key == :bounds
decoded[:boundary] = value
elsif key == :delta_bounds
dx, dy, x, y, z = value[0], value[1], position.x, position.y, position.height
raise 'Delta values cannot be < 0.' if dx < 0 || dy < 0
hash.each do |key, value|
case key
when :face
facing_position = direction_to_position(value, position)
decoded[:face] = facing_position
when :delta_bounds
dx, dy, x, y, z = value[0], value[1], position.x, position.y, position.height
raise 'Delta values cannot be less than 0.' if dx < 0 || dy < 0
decoded[:boundary] = [ Position.new(x + dx, y, z), Position.new(x, y + dy, z), Position.new(x - dx, y, z), Position.new(x, y - dy, z) ]
elsif key == :spawn_animation
decoded[:spawn_animation] = Animation.new(value)
elsif key == :spawn_graphic
decoded[:spawn_graphic] = Graphic.new(value)
else
raise "Unrecognised key #{key} - value #{value}."
decoded[:boundary] = [ Position.new(x + dx, y, z), Position.new(x, y + dy, z), Position.new(x - dx, y, z), Position.new(x, y - dy, z) ]
when :bounds then decoded[:boundary] = value
when :spawn_animation then decoded[:spawn_animation] = Animation.new(value)
when :spawn_graphic then decoded[:spawn_graphic] = Graphic.new(value)
else raise "Unrecognised key #{key} - value #{value}."
end
end
return decoded
+1
View File
@@ -9,6 +9,7 @@
</authors>
<scripts>
<script>npc-spawn.rb</script>
<script>item-spawn.rb</script>
</scripts>
<dependencies />
</plugin>
+1 -1
View File
@@ -2,10 +2,10 @@ require 'java'
java_import 'org.apollo.game.event.impl.FriendServerStatusEvent'
java_import 'org.apollo.game.event.impl.SendFriendEvent'
java_import 'org.apollo.game.model.Player'
java_import 'org.apollo.game.model.World'
java_import 'org.apollo.game.model.settings.ServerStatus'
java_import 'org.apollo.game.model.settings.PrivacyState'
java_import 'org.apollo.game.model.entity.Player'
# Processes an add friend event, updating the logged-in status of the player (and the person they added) if necessary.
+3 -1
View File
@@ -10,5 +10,7 @@
<scripts>
<script>run.rb</script>
</scripts>
<dependencies />
<dependencies>
<dependency>attributes</dependency>
</dependencies>
</plugin>
+1 -1
View File
@@ -4,7 +4,7 @@
require 'java'
java_import 'org.apollo.game.event.impl.SetWidgetItemModelEvent'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.Skill'
HERBLORE_DIALOGUE = 4429
+1 -1
View File
@@ -1,6 +1,6 @@
require 'java'
java_import 'org.apollo.game.model.EquipmentConstants'
java_import 'org.apollo.game.model.entity.EquipmentConstants'
AIR_ELEMENTS = {}
WATER_ELEMENTS = {}
+2 -2
View File
@@ -2,8 +2,8 @@ require 'java'
java_import 'org.apollo.game.action.Action'
java_import 'org.apollo.game.event.impl.DisplayTabInterfaceEvent'
java_import 'org.apollo.game.model.EquipmentConstants'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.EquipmentConstants'
java_import 'org.apollo.game.model.entity.Skill'
DISPLAY_SPELLBOOK = DisplayTabInterfaceEvent.new(6)
+1 -1
View File
@@ -1,8 +1,8 @@
require 'java'
java_import 'org.apollo.game.action.DistancedAction'
java_import 'org.apollo.game.model.EquipmentConstants'
java_import 'org.apollo.game.model.def.ItemDefinition'
java_import 'org.apollo.game.model.entity.EquipmentConstants'
PROSPECT_PULSES = 3
ORE_SIZE = 1
+2 -2
View File
@@ -2,12 +2,12 @@ require 'java'
java_import 'org.apollo.game.action.Action'
java_import 'org.apollo.game.model.Animation'
java_import 'org.apollo.game.model.Skill'
java_import 'org.apollo.game.model.entity.Skill'
BURY_BONE_ANIMATION = 827
BONES = {}
# Represents a bone with a name, id, and experience.
# Represents a bone with an id and experience value.
class Bone
attr_reader :id, :exp