Last active
July 6, 2017 12:05
-
-
Save drusepth/ec99e3ea1478d25b170953912a0366e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lifeform.rb | |
module Tiamat | |
class Lifeform < BaseTiamatObject | |
include AgingProperty # calls `during_tick :age` to trigger aging as a hook on .tick | |
end | |
end | |
# Slime.rb | |
class Slime < Tiamat::Lifeform | |
end | |
# Output | |
~/Code/personal/tiamat (master *)$ ruby run.rb | |
[startup] Initializing Tiamat engine | |
[internal] Registering during_tick hook on Tiamat::BaseTiamatObject: move | |
[internal] Registering before_move hook on Tiamat::BaseTiamatObject: initialize_location | |
[internal] Registering during_move hook on Tiamat::BaseTiamatObject: move_randomly | |
[internal] Registering after_move hook on Tiamat::BaseTiamatObject: adjust_energy | |
[internal] Registering after_tick hook on Tiamat::World: display_world | |
[internal] Registering during_tick hook on Tiamat::Lifeform: age | |
[internal] Registering during_age hook on Tiamat::Lifeform: increment_age | |
[internal] Registering before_tick hook on Tiamat::Lifeform: initialize_energy | |
[internal] Registering after_tick hook on Tiamat::Lifeform: adjust_energy | |
[internal] Registering after_tick hook on Tiamat::Lifeform: bound_energy | |
[internal] Registering before_rest hook on Tiamat::Lifeform: initialize_energy | |
[internal] Registering during_rest hook on Tiamat::Lifeform: regain_energy_from_resting | |
[internal] Registering after_rest hook on Tiamat::Lifeform: bound_energy | |
[startup] Injecting user models | |
[internal] Loading /home/drusepth/Code/personal/tiamat/tiamat-engine/../models/slime.rb | |
[startup] Injecting user services | |
[startup] Engine initialized. | |
From: /home/drusepth/Code/personal/tiamat/run.rb @ line 6 : | |
1: require 'pry' | |
2: | |
3: require_relative 'tiamat-engine/tiamat' | |
4: Tiamat::Engine.initialize! | |
5: | |
=> 6: binding.pry | |
[1] pry(main)> some_lifeform = Tiamat::Lifeform.new | |
=> #<Tiamat::Lifeform:0x0055598b2af5f0> | |
[2] pry(main)> some_lifeform.tick | |
[internal] Triggering 3 hooks for tick | |
[internal] - Activating 1 methods in Tiamat::Lifeform::tick_before | |
[internal] - Activating 1 methods in Tiamat::Lifeform::tick_during | |
[internal] Triggering 3 hooks for age | |
[internal] - Activating 0 methods in Tiamat::Lifeform::age_before | |
[internal] - Activating 1 methods in Tiamat::Lifeform::age_during | |
[internal] - Activating 0 methods in Tiamat::Lifeform::age_after | |
[internal] - Activating 2 methods in Tiamat::Lifeform::tick_after | |
=> #<Tiamat::Lifeform:0x0055598b2af5f0 @_age=1, @_energy=99> | |
[3] pry(main)> some_slime = Slime.new | |
=> #<Slime:0x0055598b24fd58> | |
[4] pry(main)> some_slime.tick | |
[internal] No hook handlers registered on Slime | |
[5] pry(main)> | |
Hook queue code: https://github.com/drusepth/tiamat/blob/master/tiamat-engine/core/hooks/hook_queue.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment