Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ResetPinData(self, newPin):
oldHeads = [ head for head in self.pin.heads ]
newHeads = [ head for head in newPin.heads ]
toRemove = [ head for head in oldHeads if head not in newHeads ]
for (headID, phi, theta,) in toRemove:
self.RemoveHead(headID)
toAdd = [ head for head in newHeads if head not in oldHeads ]
for (headID, phi, theta,) in toAdd:
surfacePoint = planet.SurfacePoint(theta=theta, phi=phi)
self.AddHead(headID, surfacePoint)
for headUI in self.extractionHeadsByNum.values():
headUI.pin = self.pin
BasePlanetPin.ResetPinData(self, newPin)
def OnPlanetZoomChanged(self, zoom):
self.zoom = zoom
self.SetResourceIconAppearance()
def ProcessColonyDataSet(self, planetID):
if sm.GetService('planetUI').planetID != planetID:
return
self.pin = sm.GetService('planetSvc').GetPlanet(planetID).GetPin(self.pin.id)
class CommandCenterPin(BasePlanetPin):
__guid__ = 'planet.ui.CommandCenterPin'
BasePlanetPin.__notifyevents__.append('OnEditModeBuiltOrDestroyed')
def __init__(self, surfacePoint, pin, transform):
BasePlanetPin.__init__(self, surfacePoint, pin, transform)
gaugeRadius = 0.005
gaugeRadiusExtended = 0.0082
powerGauge = self.powerGauge = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=11, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_POWER)
powerGaugeUnderlay = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=10, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=(0.35, 0, 0))
powerGauge.name = powerGaugeUnderlay.name = '%s,%s' % (planetCommon.PINTYPE_NORMAL, self.pin.id)
self.pinExpansions.append((powerGauge, gaugeRadius, gaugeRadiusExtended))
self.pinExpansions.append((powerGaugeUnderlay, gaugeRadius, gaugeRadiusExtended))
cpuGauge = self.cpuGauge = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=11, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_CPU)
cpuGaugeUnderlay = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=10, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=(0.0, 0.329, 0.267, 1.0))
cpuGauge.name = cpuGaugeUnderlay.name = '%s,%s' % (planetCommon.PINTYPE_NORMAL, self.pin.id)
cpuGauge.pinRotation = cpuGaugeUnderlay.pinRotation = math.pi
def OnClicked(self):
BasePlanetPin.OnClicked(self)
for head in self.extractionHeadsByNum.values():
head.Show3DModel()
self.zoom = zoom
self.SetResourceIconAppearance()
def ProcessColonyDataSet(self, planetID):
if sm.GetService('planetUI').planetID != planetID:
return
self.pin = sm.GetService('planetSvc').GetPlanet(planetID).GetPin(self.pin.id)
class CommandCenterPin(BasePlanetPin):
__guid__ = 'planet.ui.CommandCenterPin'
BasePlanetPin.__notifyevents__.append('OnEditModeBuiltOrDestroyed')
def __init__(self, surfacePoint, pin, transform):
BasePlanetPin.__init__(self, surfacePoint, pin, transform)
gaugeRadius = 0.005
gaugeRadiusExtended = 0.0082
powerGauge = self.powerGauge = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=11, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_POWER)
powerGaugeUnderlay = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=10, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=(0.35, 0, 0))
powerGauge.name = powerGaugeUnderlay.name = '%s,%s' % (planetCommon.PINTYPE_NORMAL, self.pin.id)
self.pinExpansions.append((powerGauge, gaugeRadius, gaugeRadiusExtended))
self.pinExpansions.append((powerGaugeUnderlay, gaugeRadius, gaugeRadiusExtended))
cpuGauge = self.cpuGauge = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=11, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_CPU)
cpuGaugeUnderlay = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/hash15px.dds', layer=10, radius=gaugeRadius, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=(0.0, 0.329, 0.267, 1.0))
cpuGauge.name = cpuGaugeUnderlay.name = '%s,%s' % (planetCommon.PINTYPE_NORMAL, self.pin.id)
cpuGauge.pinRotation = cpuGaugeUnderlay.pinRotation = math.pi
self.pinExpansions.append((cpuGauge, gaugeRadius, gaugeRadiusExtended))
self.pinExpansions.append((cpuGaugeUnderlay, gaugeRadius, gaugeRadiusExtended))
def GetGMMenu(self):
menu = []
menu.extend(BasePlanetPin.GetGMMenu(self))
return menu
def GetContainer(self, parent):
return planet.ui.ExtractorContainer(parent=parent, pin=self.pin)
class EcuPin(BasePlanetPin):
__guid__ = 'planet.ui.EcuPin'
baseColor = planetCommon.PLANET_COLOR_EXTRACTOR
def __init__(self, surfacePoint, pin, transform):
BasePlanetPin.__init__(self, surfacePoint, pin, transform)
self.rings = []
self.extractionHeadsByNum = {}
self.linksByHeadID = {}
numRings = 6
self.transform = transform
for i in xrange(numRings):
ring = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/gauge_15px.dds', layer=0, radius=0.0, transform=transform, color=util.Color(*planetCommon.PLANET_COLOR_EXTRACTOR).SetAlpha(0.3).GetRGBA())
self.rings.append(ring)
self.CreateSpherePin(textureName='res:/UI/Texture/Planet/pin_base.dds', layer=0, radius=RADIUS_PIN * 0.25, scale=SCALE_ONGROUND * 1.0005, transform=transform, color=planetCommon.PLANET_COLOR_EXTRACTOR)
areaOfInfluence = pin.GetAreaOfInfluence()
def GetGMMenu(self):
menu = []
menu.extend(BasePlanetPin.GetGMMenu(self))
if session.role & ROLE_GMH == ROLE_GMH and not sm.GetService('planetUI').GetCurrentPlanet().IsInEditMode():
menu.append(('Convert Command Center', self.ConvertCommandCenter))
return menu
def OnRefreshPins(self):
BasePlanetPin.OnRefreshPins(self)
self.UpdatePowerCPUGauge()
rotation = 2 * math.pi * (float(i) / numIngredients + gapConst / 2.0)
self.hopperGauges[i].pinAlphaThreshold = gaugeThreshold
self.hopperGaugeUnderlays[i].pinAlphaThreshold = underlayThreshold
self.hopperGauges[i].pinRotation = rotation
self.hopperGaugeUnderlays[i].pinRotation = rotation
def GetContainer(self, parent):
return planet.ui.ProcessorContainer(parent=parent, pin=self.pin)
class ExtractorPin(BasePlanetPin):
__guid__ = 'planet.ui.ExtractorPin'
baseColor = planetCommon.PLANET_COLOR_EXTRACTOR
def __init__(self, surfacePoint, pin, transform):
BasePlanetPin.__init__(self, surfacePoint, pin, transform)
def GetMenu(self):
menu = []
menu.extend(BasePlanetPin.GetMenu(self))
return menu
def GetGMMenu(self):
return menu
def ConvertCommandCenter(self):
sm.GetService('planetUI').planet.GMConvertCommandCenter(self.pin.id)
def GetContainer(self, parent):
return planet.ui.CommandCenterContainer(parent=parent, pin=self.pin)
class ProcessorPin(BasePlanetPin):
__guid__ = 'planet.ui.ProcessorPin'
def __init__(self, surfacePoint, pin, transform):
self.hopperGauges = []
self.hopperGaugeUnderlays = []
BasePlanetPin.__init__(self, surfacePoint, pin, transform)
self.gauge.display = self.gaugeUnderlay.display = False
for i in xrange(3):
gauge = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/gauge_15px.dds', layer=11, radius=RADIUS_PIN, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_USED_PROCESSOR)
gaugeUnderlay = self.CreateSpherePin(textureName='res:/UI/Texture/Planet/gauge_15px.dds', layer=10, radius=RADIUS_PIN, transform=transform, scale=SCALE_PINLIFTED, isGauge=True, color=planetCommon.PLANET_COLOR_PROCESSOR)
gauge.display = gaugeUnderlay.display = False
self.hopperGauges.append(gauge)
self.hopperGaugeUnderlays.append(gaugeUnderlay)
self.pinExpansions.append((gauge, RADIUS_PIN, RADIUS_PINEXTENDED))
self.pinExpansions.append((gaugeUnderlay, RADIUS_PIN, RADIUS_PINEXTENDED))
def __init__(self, surfacePoint, pin, transform):
BasePlanetPin.__init__(self, surfacePoint, pin, transform)