lzrtag / LZRTag

AVR-Based easily modifyable DIY Lasertag!
GNU General Public License v3.0
94 stars 11 forks source link

EventSystem hook implementation #38

Closed Xasin closed 6 years ago

Xasin commented 6 years ago

This should close #19, and will be the base for a lot of future upgrades, like various game modes, very dynamic game configuration and behaviour changes, as well as game "start-stop" controls.

The main change is to remove all previous callback method systems. Instead, new behaviours are added by using the add_hook option, which ties in instances of the Lasertag::EventHook base class into the game.

Each one has access to various hooks, such as


This change is Reviewable

Xasin commented 6 years ago

Reviewed 1 of 4 files at r1, 5 of 5 files at r4. Review status: all files reviewed at latest revision, all discussions resolved.


Ruby/GameInterface/EventHook.rb, line 34 at r4 (raw file):

      end
      def onKill(killedPlayer, sourcePlayer)
      end

Add helper functions to simulate all players connecting and disconnecting - mainly for convenience within the onHookin and onHookout functions.


Ruby/GameInterface/LTagGame.rb, line 92 at r4 (raw file):

              @lastGameTick = Time.now();
              @hooks.each do |h|
                  h.onGameTick(dT);

Maybe encapsulate the hook execution in begin rescue, to make the system not fail quite as unpredictable?


Comments from Reviewable

Xasin commented 6 years ago

Reviewed 1 of 1 files at r5, 1 of 1 files at r6. Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable