Package horizons :: Package component :: Module collectingcomponent :: Class CollectingComponent
[hide private]
[frames] | no frames]

Class CollectingComponent

source code

Component --+
            |
           CollectingComponent

The CollectingBuilding class represents a object that uses collectors to collect resources from other ResourceHolder objects. It is used to organize Collector instances. NOTE: Anything inheriting from this class must also inherit from the Building class.

Base class for most producing/collecting buildings.

Instance Methods [hide private]
 
__init__(self, collectors)
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
 
__init(self)
Part of initiation that __init__() and load() share
source code
 
create_collector(self, collectors)
Creates collectors for building according to db.
source code
 
add_collector(self, collector_class)
Creates a collector and adds it to this building.
source code
 
remove(self)
Removes component and reference to instance
source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
add_local_collector(self, collector) source code
 
remove_local_collector(self, collector) source code
 
get_local_collectors(self) source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) 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 = 'CollectingComponent'
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Method Details [hide private]

__init__(self, collectors)
(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)

add_collector(self, collector_class)

source code 

Creates a collector and adds it to this building.

Parameters:
  • collector_class - unit class of collector to create

remove(self)

source code 

Removes component and reference to instance

Overrides: Component.remove
(inherited documentation)

save(self, db)

source code 

Will do nothing, but will be always called in componentholder code, even if not implemented.

Overrides: Component.save
(inherited documentation)

load(self, db, worldid)

source code 

This does on load what __init() and initalize() together do on constructions at runtime. Has to set up everything that is not setup in __init__(). Note that on loading __init__() is called with the data needed by the component through get_instance(), but initialize() is not, so any work needed for loading as well should be moved to a separate method and called here.

Overrides: Component.load
(inherited documentation)