contrib/tinks: add `FeatureChangeEvent::old_feature`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 23 Jan 2016 16:44:04 +0000 (11:44 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 Jan 2016 19:10:43 +0000 (14:10 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/tinks/src/game/powerups.nit
contrib/tinks/src/game/world.nit

index 2c7cd5b..8fc5af7 100644 (file)
@@ -48,13 +48,13 @@ redef class Tank
                # Put a random powerup at the center of the old tank
                var pos = new Pos(pos.x.floor+0.5, pos.y.floor+0.5)
                var powerup = new Powerup(turn.game.story.powerups.rand, pos)
-               turn.add new FeatureChangeEvent(powerup, pos)
+               turn.add new FeatureChangeEvent(powerup, null, pos)
 
                # Add some debris around it
                var forward = new Pos((pos.x+heading.cos*1.1).floor+0.5, (pos.y+heading.sin*1.1).floor+0.5)
                var backward = new Pos((pos.x-heading.cos*1.1).floor+0.5, (pos.y-heading.sin*1.1).floor+0.5)
-               turn.add new FeatureChangeEvent(new Feature(turn.game.story.debris, forward), forward)
-               turn.add new FeatureChangeEvent(new Feature(turn.game.story.debris, backward), backward)
+               turn.add new FeatureChangeEvent(new Feature(turn.game.story.debris, forward), null, forward)
+               turn.add new FeatureChangeEvent(new Feature(turn.game.story.debris, backward), null, backward)
        end
 
        # Intercept collision detection of "absorb" powerups
@@ -78,7 +78,7 @@ redef class Tank
                # Only powerups! absorb them
                for powerup in collisions do
                        if powerup isa Powerup then
-                               turn.add new FeatureChangeEvent(null, powerup.pos)
+                               turn.add new FeatureChangeEvent(null, powerup, powerup.pos)
 
                                if powerup.rule.restore_health then
                                        turn.add new TankHealthChange(self, rule.max_health)
index a9e1844..9ba1d8b 100644 (file)
@@ -211,6 +211,9 @@ class FeatureChangeEvent
        # New `Feature`, if any
        var feature: nullable Feature
 
+       # Previous feature, if any
+       var old_feature: nullable Feature
+
        # `Pos` of this change
        var pos: Pos