Package horizons :: Package component :: Module storagecomponent :: Class StorageComponent
[hide private]
[frames] | no frames]

Class StorageComponent

source code

Component --+
            |
           StorageComponent

The StorageComponent class is used for everything that has an inventory.

Examples for these classes are ships, settlements, buildings, etc. Basically it just adds an inventory, nothing more, nothing less.

Instance Methods [hide private]
 
__init__(self, inventory)
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
 
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
 
something_changed(self)
Used as proxy to send messages when a changelistener notifies us.
source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
session(self) source code
Class Methods [hide private]
 
get_instance(cls, arguments)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  NAME = 'storagecomponent'
hash(x)
  storage_mapping = {'PositiveStorage': PositiveStorage, 'Positi...
    Inherited from Component
  DEPENDENCIES = []
Method Details [hide private]

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

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)

something_changed(self)

source code 

Used as proxy to send messages when a changelistener notifies us.

Masks the message sender to be `self.instance` rather than self because that is what we are interested in, usually.

get_instance(cls, arguments)
Class Method

source code 

This function is used to instantiate classes from yaml data. Override this if the component has more than just a basic constructor with primitive types (takes custom classes as arguments, e.g. Storages)

Overrides: Component.get_instance
(inherited documentation)

Class Variable Details [hide private]

storage_mapping

Value:
{'PositiveStorage': PositiveStorage, 'PositiveSizedSlotStorage': Posit\
iveSizedSlotStorage, 'PositiveTotalNumSlotsStorage': PositiveTotalNumS\
lotsStorage, 'SlotsStorage': PositiveSizedSpecializedStorage, 'Settlem\
entStorage': SettlementStorage}