Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _GetLinkWeight(self, link, pinA, pinB):
spA = planet.SurfacePoint(radius=1.0, theta=pinA.longitude, phi=pinA.latitude)
spB = planet.SurfacePoint(radius=1.0, theta=pinB.longitude, phi=pinB.latitude)
return spA.GetDistanceToOther(spB)
def GetDistanceBetweenPins(pinA, pinB, planetRadius):
spA = planet.SurfacePoint(radius=planetRadius, theta=pinA.longitude, phi=pinA.latitude)
spB = planet.SurfacePoint(radius=planetRadius, theta=pinB.longitude, phi=pinB.latitude)
return spA.GetDistanceToOther(spB)
def _GetLinkWeight(self, link, pinA, pinB):
spA = planet.SurfacePoint(radius=1.0, theta=pinA.longitude, phi=pinA.latitude)
spB = planet.SurfacePoint(radius=1.0, theta=pinB.longitude, phi=pinB.latitude)
return spA.GetDistanceToOther(spB)
def RenderExtractionHeads(self):
self.RemoveAllHeads()
for (headID, phi, theta,) in self.pin.heads:
surfacePoint = planet.SurfacePoint(theta=theta, phi=phi)
self.AddHead(headID, surfacePoint)
def RenderCommandCentersOfOtherCharacters(self):
if not settings.user.ui.Get('planetShowOtherCharactersPins', True):
return
commandCenters = self.GetCommandCentersOfOtherCharacters()
for (charid, cc,) in commandCenters.iteritems():
if charid == session.charid:
continue
sp = planet.SurfacePoint(theta=cc.longitude, phi=cc.latitude)
pin = planet.ui.OtherPlayersPin(sp, cc.pinID, cc.typeID, cc.ownerID, self.planetUISvc.pinOthersTransform)
self.otherPlayerPinsByPinID[cc.pinID] = pin
self.planetUISvc.curveLineDrawer.SubmitLineset('otherLinks')
model.translation = (0.0, 0.0, 1500.0)
model.rotation = geo2.QuaternionRotationSetYawPitchRoll(math.pi, 0.0, 0.0)
scene2.objects.append(inclinationRoot)
ls = trinity.EveCurveLineSet()
ls.scaling = (1.0, 1.0, 1.0)
tex2D1 = trinity.TriTexture2DParameter()
tex2D1.name = 'TexMap'
tex2D1.resourcePath = 'res:/UI/Texture/Planet/link.dds'
ls.lineEffect.resources.append(tex2D1)
tex2D2 = trinity.TriTexture2DParameter()
tex2D2.name = 'OverlayTexMap'
tex2D2.resourcePath = 'res:/UI/Texture/Planet/link.dds'
ls.lineEffect.resources.append(tex2D2)
lineColor = (1.0, 1.0, 1.0, 0.05)
p1 = planet.SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
p2 = planet.SurfacePoint(5.0, 0.0, 1498.0, 1000.0)
l1 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0)
p1 = planet.SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
p2 = planet.SurfacePoint(-5.0, 0.0, 1498.0, 1000.0)
l2 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0)
animationColor = (0.3, 0.3, 0.3, 0.5)
ls.ChangeLineAnimation(l1, animationColor, 0.25, 1.0)
ls.ChangeLineAnimation(l2, animationColor, -0.25, 1.0)
ls.ChangeLineSegmentation(l1, 100)
ls.ChangeLineSegmentation(l2, 100)
ls.SubmitChanges()
orbitRoot.children.append(ls)
trinity.WaitForResourceLoads()
for model in addedObjects:
model.display = 1
pin = self.GetPin(pinID)
if not pin:
raise UserError('PinDoesNotExist')
if not pin.IsExtractor():
raise UserError('PinDoesNotHaveHeads')
if pin.FindHead(headID) is not None:
raise UserError('CannotAddHeadAlreadyExists')
if len(pin.heads) >= planetCommon.ECU_MAX_HEADS:
raise UserError('CannotPlaceHeadLimitReached')
cpuDelta = pin.GetCpuUsage(numHeads=len(pin.heads) + 1) - pin.GetCpuUsage()
powerDelta = pin.GetPowerUsage(numHeads=len(pin.heads) + 1) - pin.GetPowerUsage()
if cpuDelta + self.colonyData.GetColonyCpuUsage() > self.colonyData.GetColonyCpuSupply():
raise UserError('CannotAddToColonyCPUUsageExceeded', {'typeName': (const.UE_LOC, 'UI/PI/Common/ExtractorHead')})
if powerDelta + self.colonyData.GetColonyPowerUsage() > self.colonyData.GetColonyPowerSupply():
raise UserError('CannotAddToColonyPowerUsageExceeded', {'typeName': (const.UE_LOC, 'UI/PI/Common/ExtractorHead')})
spA = SurfacePoint(radius=self.GetPlanetRadius(), theta=pin.longitude, phi=pin.latitude)
spB = SurfacePoint(radius=self.GetPlanetRadius(), theta=longitude, phi=latitude)
angleBetween = spA.GetAngleBetween(spB)
areaOfInfluence = pin.GetAreaOfInfluence()
if angleBetween > areaOfInfluence:
raise UserError('CannotPlaceHeadTooFarAway', {'maxDist': util.FmtDist(areaOfInfluence * self.planet.radius)})
self.PostValidateAddExtractorHead(pinID, latitude, longitude)
scene2.objects.append(inclinationRoot)
ls = trinity.EveCurveLineSet()
ls.scaling = (1.0, 1.0, 1.0)
tex2D1 = trinity.TriTexture2DParameter()
tex2D1.name = 'TexMap'
tex2D1.resourcePath = 'res:/UI/Texture/Planet/link.dds'
ls.lineEffect.resources.append(tex2D1)
tex2D2 = trinity.TriTexture2DParameter()
tex2D2.name = 'OverlayTexMap'
tex2D2.resourcePath = 'res:/UI/Texture/Planet/link.dds'
ls.lineEffect.resources.append(tex2D2)
lineColor = (1.0, 1.0, 1.0, 0.05)
p1 = planet.SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
p2 = planet.SurfacePoint(5.0, 0.0, 1498.0, 1000.0)
l1 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0)
p1 = planet.SurfacePoint(0.0, 0.0, -1500.0, 1000.0)
p2 = planet.SurfacePoint(-5.0, 0.0, 1498.0, 1000.0)
l2 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0)
animationColor = (0.3, 0.3, 0.3, 0.5)
ls.ChangeLineAnimation(l1, animationColor, 0.25, 1.0)
ls.ChangeLineAnimation(l2, animationColor, -0.25, 1.0)
ls.ChangeLineSegmentation(l1, 100)
ls.ChangeLineSegmentation(l2, 100)
ls.SubmitChanges()
orbitRoot.children.append(ls)
trinity.WaitForResourceLoads()
for model in addedObjects:
model.display = 1
def PlaceProbeAtDefaultPosition(self, headID):
OFFSET = 0.08
VEC_X = (-1, 0, 0)
rotAngle = float(headID) / planetCommon.ECU_MAX_HEADS * 2 * math.pi
ecuVector = self.planetUISvc.myPinManager.pinsByID[self.pin.id].surfacePoint.GetAsXYZTuple()
normal = geo2.Vec3Cross(ecuVector, VEC_X)
normal = geo2.Vector(*normal) * OFFSET
posVec = geo2.Vec3Subtract(ecuVector, normal)
posVec = geo2.Vec3Normalize(posVec)
rotMat = geo2.MatrixRotationAxis(ecuVector, rotAngle)
posVec = geo2.Multiply(rotMat, posVec)
surfacePoint = planet.SurfacePoint(*posVec)
self.planetUISvc.myPinManager.PlaceExtractionHead(self.pin.id, headID, surfacePoint, self.currentRadius)
self.UpdateHeadPosition(headID, surfacePoint)