-
Notifications
You must be signed in to change notification settings - Fork 5
Gotchas
#Introduction There are certain aspects to the workflow that may not make sense, and without first being aware of them one may find undesired behaviour.
Attribute are set to "complain" by default. This means that their values are hashed whenever the attribute itself is assigned a new value. Setting a muteable value which supports hashing (e.g a Struct instance) will read the hashed values of its current state. Hence, if you were to execute this code:
data = Struct()
self.attribute = data
data.x = 1
data.y = 2You would not modify the existing has for the Attribute instance 'attribute'. To avoid this, simply assign after setting the values
data = Struct()
data.x = 1
data.y = 2
self.attribute = dataThis also means that roles should not be replicated as complaining attributes.
Attributes cannot be coerced. (integers are treated as integers, and floats as floats, so you'll get errors trying to set them as such): It would not be sensible to support this, as side effects would be unwanted.
class Example(Replicable):
attribute = Attribute(0) #or Attribute(type_of=int)
def on_initialised(self):
super().on_initialised()
# TypeError raised here
self.attribute = 1.0 #Network
##Replication Overview
##Serialisation Data handlers
##Communication Messaging
#Game Framework ##Bindings Creating bindings