~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to lib/gamex/BaseGameObject.mhx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package gamex;
 
7
 
 
8
/**
 
9
 * The base class for Objects to be used in a GameDriver.
 
10
 *
 
11
 * The Generic non-specified GameDriverType and the casts are required to
 
12
 * resolve a type loop of the two classes trying to refer to each other.  The
 
13
 * overhead in this class was less, therefore it is done here.
 
14
 */
 
15
class BaseGameObject<GameDriverType> implements GameObject
 
16
{
 
17
        /*protected*/ var game : GameDriverType;
 
18
        /*protected*/ var destroyed : Bool;
 
19
 
 
20
        public function new( game : GameDriverType )
 
21
        {
 
22
                this.game = game;
 
23
                destroyed = false;
 
24
                
 
25
                cast( game, BaseGameDriver<Dynamic> ).addGameObject( this );
 
26
        }
 
27
        
 
28
        /*virtual*/ function destroy()
 
29
        {
 
30
                ASSERT_FALSE( destroyed );
 
31
                destroyed = true;
 
32
                
 
33
                cast( game, BaseGameDriver<Dynamic> ).removeGameObject( this );
 
34
        }
 
35
        
 
36
        /**
 
37
         * Should be overridden by derived classes if they need to perform
 
38
         * timed operations.
 
39
         */
 
40
        /*virtual*/ public function stepTime( elapsed : Float ) : Void
 
41
        {
 
42
                //does nothing by default
 
43
        }
 
44
}