Exemplo n.º 1
0
    def _UnRegisterComponents(self, entity):
        with uthread.BlockTrapSection():
            with entity.entityLock:
                try:
                    if entity.state == const.cef.ENTITY_STATE_READY:
                        registerCalls = []
                        for name, component in entity.components.iteritems():
                            systems = self.GetComponentSystems(name)
                            if systems:
                                for system in systems:
                                    f = getattr(system, 'UnRegisterComponent', None)
                                    if f:
                                        registerCalls.append((f, (entity, component)))

                        if registerCalls:
                            for f, args in registerCalls:
                                try:
                                    f(*args)
                                except Exception as e:
                                    self._deadEntityList[entity.entityID] = entity
                                    log.LogException(e)

                    elif entity.state in (const.cef.ENTITY_STATE_UNINITIALIZED, const.cef.ENTITY_STATE_DEAD, const.cef.ENTITY_STATE_DESTROYING):
                        self.LogError('UnRegisterComponents: Entity state should be either ', const.cef.ENTITY_STATE_NAMES[const.cef.ENTITY_STATE_CREATING], ' or ', const.cef.ENTITY_STATE_NAMES[const.cef.ENTITY_STATE_READY], ', is instead ', const.cef.ENTITY_STATE_NAMES[entity.state], '. Entity:', str(entity))
                    entity.scene.RemoveEntityFromRegisteredList(entity)
                    self.entitySceneManager.Unregister(entity.entityID)
                    entity.state = const.cef.ENTITY_STATE_DESTROYING
                except Exception as e:
                    self._deadEntityList[entity.entityID] = entity
                    if entity.scene and entity.entityID in entity.scene.entities:
                        del entity.scene.entities[entity.entityID]
                        self.entitySceneManager.Unregister(entity.entityID)
                    log.LogException(e)
Exemplo n.º 2
0
    def _RegisterComponents(self, entity, initData = None):
        with uthread.BlockTrapSection():
            with entity.entityLock:
                try:
                    if entity.state == const.cef.ENTITY_STATE_CREATING:
                        entity.state = const.cef.ENTITY_STATE_READY
                        entity.scene.AddEntityToRegisteredList(entity)
                        registerCalls = []
                        for name, component in entity.components.iteritems():
                            systems = self.GetComponentSystems(name)
                            if systems:
                                for system in systems:
                                    f = getattr(system, 'RegisterComponent', None)
                                    if f:
                                        registerCalls.append((f, (entity, component)))

                        if registerCalls:
                            for f, args in registerCalls:
                                f(*args)

                        del self.loadingEntities[entity.entityID]
                    elif entity.state in (const.cef.ENTITY_STATE_UNINITIALIZED, const.cef.ENTITY_STATE_DEAD, const.cef.ENTITY_STATE_READY):
                        self.LogError('RegisterComponents: Entity state should be either', const.cef.ENTITY_STATE_NAMES[const.cef.ENTITY_STATE_CREATING], 'or', const.cef.ENTITY_STATE_NAMES[const.cef.ENTITY_STATE_DESTROYING], ', is instead', const.cef.ENTITY_STATE_NAMES[entity.state], '. Entity:', str(entity))
                    sm.ScatterEvent('OnEntityCreated', entity.entityID)
                    GameWorld.GetNetworkEntityQueueManager().ClearEntity(entity.entityID)
                except Exception as e:
                    log.LogException(e)
                    self._deadEntityList[entity.entityID] = entity
                    if entity.scene and entity.entityID in entity.scene.entities:
                        del entity.scene.entities[entity.entityID]
                        self.entitySceneManager.Unregister(entity.entityID)
Exemplo n.º 3
0
 def OnGraphicSettingsChanged(self, changes):
     flaresEnabled = sm.GetService('device').GetAppFeatureState(
         'Interior.LensflaresEnabled', True)
     with uthread.BlockTrapSection():
         for entity in self.flareEntities:
             flareComponent = entity.GetComponent('lensFlare')
             if not flaresEnabled and flareComponent.trinityObject is not None:
                 self.RemoveFromScene(entity, flareComponent)
             elif flaresEnabled and flareComponent.trinityObject is None:
                 self.AddToScene(entity, flareComponent)
Exemplo n.º 4
0
 def OnGraphicSettingsChanged(self, changes):
     particlesEnabled = sm.GetService('device').GetAppFeatureState(
         'Interior.ParticlesEnabled', True)
     with uthread.BlockTrapSection():
         for entity in self.particleObjectEntities:
             particleComponent = entity.GetComponent('particleObject')
             if not particlesEnabled and particleComponent.trinityObject is not None:
                 self.RemoveFromScene(entity, particleComponent)
             elif particlesEnabled and particleComponent.trinityObject is None:
                 self.AddToScene(entity, particleComponent)
 def OnGraphicSettingsChanged(self, changes):
     """
     Detects if particles have been turned on or off, or there is some other sort of change.
     Updates flares accordingly.
     """
     flaresEnabled = sm.GetService('device').GetAppFeatureState(
         'Interior.LensflaresEnabled', True)
     with uthread.BlockTrapSection():
         for entity in self.flareEntities:
             flareComponent = entity.GetComponent('lensFlare')
             if not flaresEnabled and flareComponent.trinityObject is not None:
                 self.RemoveFromScene(entity, flareComponent)
             elif flaresEnabled and flareComponent.trinityObject is None:
                 self.AddToScene(entity, flareComponent)
Exemplo n.º 6
0
def ZactionCommonBasePythonProcMethod(method, args, blocking):
    if blocking:
        callbackHandle = GameWorld.GetResultHandleForCurrentPythonProc()

        def _CallBlockingMethod():
            result = method(*args)
            GameWorld.SetResultForPythonProcFromHandle(callbackHandle, int(result))

        thread = uthread.new(_CallBlockingMethod)
        thread.localStorage['callbackHandle'] = callbackHandle
        return False
    else:
        try:
            with uthread.BlockTrapSection():
                result = method(*args)
        except:
            log.LogException()
            result = False

        return result