mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Add door plugin. Note that this will need to be revisited when local object synchronization is complete.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
java_import 'org.apollo.game.action.DistancedAction'
|
||||
|
||||
# A distanced action which opens a door.
|
||||
class OpenDoorAction < DistancedAction
|
||||
include DoorConstants
|
||||
|
||||
attr_reader :door_object
|
||||
|
||||
def initialize(mob, door_object)
|
||||
super(0, true, mob, door_object.position, DOOR_SIZE)
|
||||
@door_object = door_object
|
||||
end
|
||||
|
||||
def executeAction
|
||||
mob.turn_to @door_object.position
|
||||
DoorUtil::toggle(@door_object, mob)
|
||||
stop
|
||||
end
|
||||
|
||||
def equals(other)
|
||||
return (get_class == other.get_class && @position == other.position)
|
||||
end
|
||||
end
|
||||
|
||||
# Message handler for opening and closing doors.
|
||||
on :message, :first_object_action do |ctx, player, message|
|
||||
if DoorUtil::is_door?(message.id)
|
||||
door_object = DoorUtil::get_door_object(message.position, message.id)
|
||||
player.start_action(OpenDoorAction.new(player, door_object)) unless door_object.nil?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user