def suspendPhysics(self): self.visible = False for child in self.childrenRecursive: child.suspendPhysics() child.visible = False KX_GameObject.suspendPhysics(self)
def restorePhysics(self): self.visible = True for child in self.childrenRecursive: child.restorePhysics() child.visible = True KX_GameObject.restorePhysics(self)
def endObject(self): active = [] if self.children: if not self.children.invalid: active = [i for i in range(len(self.children))] for i, child in enumerate(self.children): if "active" in child: active[i] = child["active"] else: active[i] = False child.endObject() core.reserveID(self) obj_dict = {k: getattr(self, k) for k in saveAttrs if hasattr(self, k)} obj_dict["c_active"] = active if self.parent: pos = Vector(self.localPosition) else: pos = Vector(self.worldPosition) rot = Vector(self.localOrientation.to_euler()) scale = Vector(self.localScale) core.objSuspended[self.id] = { "obj": str(self.name), "pos": pos, "rot": rot, "scale": scale, "d": obj_dict, "kls": str(self.kls) } core.world["cellDict"][self.worldKey]["objects"].append(self.id) KX_GameObject.endObject(self)
def endObject(self): if self.children: if not self.children.invalid: for child in self.children: child.endObject() core.discardID(self) KX_GameObject.endObject(self)
def __setitem__(self, key, value): if isinstance(value, KX_GameObject): try: value = [value.id, value.kls] except: None if "OBJ:" not in key: key = "OBJ:" + key KX_GameObject.__setitem__(self, key, value)
def endObject(self): if self.children: chunks = chunkIt(self.children, 18) for chunk in chunks: core.queues["endObject_mainScene"].append(chunk) core.queues["endObject_mainScene"].append(self) elif self not in core.queues["endObject_mainScene"]: core.reserveID(self) KX_GameObject.endObject(self)
def test_success(): other = KX_GameObject(None) camera = Camera() args = OrderedDict(( ("String Value", "DEF"), ("Bool Value", False), ("Int Value", 321), ("Float Value", 1.5), ("Object Value", other), ("Data Value", camera), )) comp = TestComp() comp.assert_is_none() comp.start(args) assert comp.string_value == "DEF" assert comp.bool_value is False assert comp.int_value == 321 assert comp.float_value == 1.5 assert comp.object_value == other assert comp.data_value == camera comp.dispose() comp.assert_is_none()
def test_success(): other = KX_GameObject(None) camera = Camera() args = OrderedDict(( ("String Value", "DEF"), ("Bool Value", False), ("Int Value", 321), ("Float Value", 1.5), ("Object Value", other), ("Data Value", camera), )) comp = TestComp() comp.assert_failure(NotStartedError("The proxy has not been started yet.")) comp.start(args) assert comp.string_value == Success("DEF") assert comp.bool_value == Success(False) assert comp.int_value == Success(321) assert comp.float_value == Success(1.5) assert comp.object_value == Success(other) assert comp.data_value == Success(camera) comp.dispose() comp.assert_failure( AlreadyDisposedError("The proxy instance has been disposed already."))
def test_valid(): other = KX_GameObject(None) camera = Camera() args = OrderedDict(( ("String Value", "DEF"), ("Bool Value", False), ("Int Value", 321), ("Float Value", 1.5), ("Object Value", other), ("Data Value", camera), )) comp = TestComp() comp.assert_nothing() comp.start(args) assert comp.string_value == Some("DEF") assert comp.bool_value == Some(False) assert comp.int_value == Some(321) assert comp.float_value == Some(1.5) assert comp.object_value == Some(other) assert comp.data_value == Some(camera) comp.dispose() comp.assert_nothing()
def __getitem__(self, key): if "OBJ:" + key in self: key = "OBJ:" + key value = KX_GameObject.__getitem__(self, key) if "OBJ:" in key: try: _id, kls = value return core.find(_id, kls) except: None return value
def endObject(self): core.discardID(self) KX_GameObject.endObject(self)
def applyMovement(self, vec, local=False, prop="", reloc=False): if not (self.solid or reloc): self.clipMove(vec, prop) KX_GameObject.applyMovement(self, vec, local)