Package horizons :: Package component :: Module stancecomponent :: Class StanceComponent
[hide private]
[frames] | no frames]

Class StanceComponent

source code

Component --+
            |
           StanceComponent

Class to be inherited for all unit stances It has methods defined for specific instance states The default methods are defined that the instance only listens to user commands If a state different from user_attack or user_move is passed, it stops any action and switches to idle.

NOTE: This does not use stance inheritance as intended, but multiple stance components are present at the same time, while only one is used at a time.

Instance Methods [hide private]
 
__init__(self)
Used for initialization code that does not require any other components.
source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
remove(self)
Removes component and reference to instance
source code
 
set_state(self, state) source code
 
get_state(self) source code
 
act(self)
Act according to current state This is called every few second in the instance code
source code
 
act_idle(self)
Method executed when the instance is idle
source code
 
act_user_attack(self)
Method executed when the instance is trying to attack a target selected by the user
source code
 
act_user_move(self)
Method executed when the instance is moving to a location selected by the user
source code
 
act_move_back(self)
Method executed when the instance is moving back to it's default location
source code
 
act_auto_attack(self)
Method executed when the instance has auto acquired target
source code
 
act_flee(self)
Method executed when the instance is trying to evade an attack
source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
session(self) source code
Class Methods [hide private]
    Inherited from Component
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  NAME = 'stance'
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Overrides: Component.__init__
(inherited documentation)

initialize(self)

source code 

This is called by the ComponentHolder after it set the instance. Use this to initialize any needed infrastructure. When this is called, it is guaranteed that all other components this one has a dependency on have been added, but initalize may not have been called on them, only __init__. It is only called after construction, not on load().

Overrides: Component.initialize
(inherited documentation)

remove(self)

source code 

Removes component and reference to instance

Overrides: Component.remove
(inherited documentation)