def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.ballIDs = [trigger.shipID] self.gfx = None self.gfxModel = None self.radius = 5000.0 self.moduleTypeID = trigger.moduleTypeID self.translationCurve = None
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) if trigger.moduleID is not None and trigger.moduleID != trigger.shipID: self.ballIDs = [trigger.moduleID] else: self.ballIDs = [trigger.shipID] self.fxSequencer = sm.GetService('FxSequencer') self.gfx = None
def __init__(self, trigger, transformFlags=0, mergeFlags=0, graphicFile=None, scaleTime=True, duration=10000): GenericEffect.__init__(self, trigger, transformFlags, mergeFlags, graphicFile, scaleTime, duration)
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.ballIDs = [trigger.shipID] self.gfx = None self.gfxModel = None self.radius = 5000.0 self.moduleTypeID = trigger.moduleTypeID self.translationCurve = None self.trigger = trigger self.ballpark = sm.GetService('michelle').GetBallpark()
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.gfxModel_ship = None self.gfxModel_trace = None self.startPos = (0, 0, 0) self.lastPos = (0, 0, 0) self.gotStopCommand = False self.abort = False self.direction = (0, 0, 1) self.gfxBall = None self.observer = None self.isShortWarp = False
def AddTrigger(self, trigger): if self.TriggerAlreadyExists(trigger): return heapq.heappush(self.triggers, trigger) stampUpdated = self.UpdateRepeatTime() if self.effect is None: try: self.effect = self.GetEffectFromGuid(trigger) except: self.effect = GenericEffect(trigger) log.LogException() sys.exc_clear() self.balls = set(self.effect.GetBalls()) self.PrepareAndStart() self.isOn = True else: self.balls.add(trigger.shipID) self.balls.add(trigger.targetID) return stampUpdated
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.position = trigger.graphicInfo self.gfxModel = None
class Activation(): def __init__(self, broker): self.triggers = [] self.effect = None self.guid = None self.stamp = -1 self.duration = -1 self.broker = broker self.key = None self.isOn = False self.balls = set() self.isZombie = False def __le__(self, other): return self.stamp <= other.stamp def Zombify(self): self.isZombie = True self.triggers = [] self.balls = set() self.broker = None def TriggerAlreadyExists(self, trigger): for t in self.triggers: if trigger.moduleID == t.moduleID: return True return False @telemetry.ZONE_METHOD def AddTrigger(self, trigger): if self.TriggerAlreadyExists(trigger): return heapq.heappush(self.triggers, trigger) stampUpdated = self.UpdateRepeatTime() if self.effect is None: try: self.effect = self.GetEffectFromGuid(trigger) except: self.effect = GenericEffect(trigger) log.LogException() sys.exc_clear() self.guid = trigger.guid self.balls = set(self.effect.GetBalls()) self.PrepareAndStart() self.isOn = True else: self.balls.add(trigger.shipID) self.balls.add(trigger.targetID) return stampUpdated @telemetry.ZONE_METHOD def PrepareAndStart(self): try: self.effect.Prepare() self.effect.Start(self.duration) except: log.LogException() sys.exc_clear() @telemetry.ZONE_METHOD def RemoveTrigger(self, trigger): try: ix = self.triggers.index(trigger) except ValueError: ix = -1 if ix >= 0: del self.triggers[ix] heapq.heapify(self.triggers) self.PurgeTriggers() return self.UpdateRepeatTime() @telemetry.ZONE_METHOD def UpdateRepeatTime(self): lastTime = -1 candidate = None for trigger in self.triggers: if trigger.stamp > lastTime: lastTime = trigger.stamp candidate = trigger if candidate is None: return -1 now = blue.os.GetSimTime() duration = int(candidate.duration) durationInBluetime = SECOND * duration / 1000 wholeRepeatsLeft = long((candidate.stamp - now) / durationInBluetime) if wholeRepeatsLeft == candidate.repeat: wholeRepeatsLeft -= 1 newStamp = candidate.stamp - wholeRepeatsLeft * durationInBluetime if newStamp == self.stamp: return 0 self.stamp = newStamp self.duration = candidate.duration return 1 @telemetry.ZONE_METHOD def Repeat(self): if self.effect is None: raise RuntimeError('Activation::Repeat: No effect defined') stampUpdated = self.PurgeTriggers() if not self.triggers: self.Stop() return -1 if not self.isOn: return stampUpdated try: self.effect.Repeat(self.duration) except: log.LogException() sys.exc_clear() return stampUpdated @telemetry.ZONE_METHOD def Stop(self, reason=STOP_REASON_DEFAULT): if not self.isOn: return if self.effect is None: raise RuntimeError('Activation::Stop: No effect defined') try: self.effect.Stop(reason) except: log.LogException() sys.exc_clear() self.isOn = False @telemetry.ZONE_METHOD def PurgeTriggers(self): now = blue.os.GetSimTime() while self.triggers and self.triggers[0].stamp <= now: heapq.heappop(self.triggers) return self.UpdateRepeatTime() def GetBalls(self): return self.balls def GetName(self): if self.triggers: return self.triggers[0].guid else: return 'unknown' def GetEffectFromGuid(self, trigger): classification = GetClassification(trigger.guid) if classification is None: raise RuntimeError('Activation::Unable to load effect for guid:', trigger.guid) classType = classification[0] args = classification[1:] return classType(trigger, *args)
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.ballpark = sm.GetService('michelle').GetBallpark() self.trigger = trigger
def __init__(self, trigger, *args, **kwargs): GenericEffect.__init__(self, trigger, *args, **kwargs) self.trigger = trigger
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.gfxBall = None self.gfxModel = None self.gfxModel_ship = None self.observer = None
def __init__(self, trigger, *args): GenericEffect.__init__(self, trigger, *args) self.ballIDs = [trigger.shipID] self.ballpark = sm.GetService('michelle').GetBallpark() self.trigger = trigger self.gfx = None