dungeonHelper.py (6459B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\parklife\dungeonHelper.py 2 import blue 3 from eve.client.script.parklife import dungeonEditorTools 4 import math 5 from ballparkCommon.ballRadius import ComputeRadiusFromQuantity, ComputeQuantityFromRadius 6 import trinity 7 import geo2 8 9 def IsJessicaOpen(): 10 return '/jessica' in blue.pyos.GetArg() 11 12 13 def IsObjectLocked(objectID): 14 return (False, []) 15 16 17 def SetObjectPosition(objectID, x = None, y = None, z = None): 18 scenario = sm.StartService('scenario') 19 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 20 if slimItem is None: 21 raise RuntimeError('No slim item?') 22 dX = 0 23 if x is not None: 24 dX = x - slimItem.dunX 25 slimItem.dunX = x 26 dY = 0 27 if y is not None: 28 dY = y - slimItem.dunY 29 slimItem.dunY = y 30 dZ = 0 31 if z is not None: 32 dZ = z - slimItem.dunZ 33 slimItem.dunZ = z 34 targetModel = getattr(targetBall, 'model', None) 35 if targetModel: 36 targetModel.translationCurve.x += dX 37 targetModel.translationCurve.y += dY 38 targetModel.translationCurve.z += dZ 39 scenario.UpdateUnsavedObjectChanges(slimItem.itemID, dungeonEditorTools.CHANGE_TRANSLATION) 40 41 42 def SetObjectRotation(objectID, yaw = None, pitch = None, roll = None): 43 scenario = sm.StartService('scenario') 44 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 45 if slimItem is None: 46 raise RuntimeError('No slim item?') 47 targetModel = getattr(targetBall, 'model', None) 48 if not targetModel: 49 return 50 try: 51 mYaw, mPitch, mRoll = geo2.QuaternionRotationGetYawPitchRoll(targetModel.rotationCurve.value) 52 except: 53 mYaw, mPitch, mRoll = targetBall.yaw, targetBall.pitch, targetBall.roll 54 55 if yaw is None: 56 yaw = mYaw 57 if pitch is None: 58 pitch = mPitch 59 if roll is None: 60 roll = mRoll 61 targetBall.typeData['dunRotation'] = (yaw, pitch, roll) 62 targetBall.SetStaticRotation() 63 scenario.UpdateUnsavedObjectChanges(slimItem.itemID, dungeonEditorTools.CHANGE_ROTATION) 64 65 66 def SetObjectRadius(objectID, radius): 67 scenario = sm.StartService('scenario') 68 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 69 if slimItem is None: 70 raise RuntimeError('No slim item?') 71 if slimItem.categoryID == const.categoryAsteroid or slimItem.groupID in (const.groupHarvestableCloud, const.groupCloud): 72 godma = sm.GetService('godma') 73 computedQuantity = ComputeQuantityFromRadius(slimItem.categoryID, slimItem.groupID, slimItem.typeID, radius, godma) 74 SetObjectQuantity(objectID, computedQuantity) 75 76 77 def SetObjectQuantity(objectID, quantity): 78 scenario = sm.StartService('scenario') 79 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 80 if slimItem is None: 81 raise RuntimeError('No slim item?') 82 targetModel = getattr(targetBall, 'model', None) 83 if not targetModel: 84 return 85 if slimItem.categoryID == const.categoryAsteroid or slimItem.groupID in (const.groupHarvestableCloud, const.groupCloud): 86 godma = sm.GetService('godma') 87 computedRadius = ComputeRadiusFromQuantity(slimItem.categoryID, slimItem.groupID, slimItem.typeID, quantity, godma) 88 if hasattr(targetModel, 'modelScale'): 89 targetModel.modelScale = computedRadius 90 elif hasattr(targetModel, 'scaling'): 91 scaleVector = trinity.TriVector(computedRadius, computedRadius, computedRadius) 92 targetModel.scaling = scaleVector 93 else: 94 raise RuntimeError('Model has neither modelScale nor scaling') 95 slimItem.dunRadius = quantity 96 scenario.UpdateUnsavedObjectChanges(slimItem.itemID, dungeonEditorTools.CHANGE_SCALE) 97 else: 98 raise RuntimeError("Can't scale type %d" % slimItem.categoryID) 99 100 101 def GetObjectPosition(objectID): 102 scenario = sm.StartService('scenario') 103 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 104 if slimItem is None: 105 raise RuntimeError('No slim item?') 106 return (slimItem.dunX, slimItem.dunY, slimItem.dunZ) 107 108 109 def GetObjectRotation(objectID): 110 scenario = sm.StartService('scenario') 111 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 112 if slimItem is None: 113 raise RuntimeError('No slim item?') 114 targetModel = getattr(targetBall, 'model', None) 115 if not targetModel or not targetModel.rotationCurve or not hasattr(targetModel.rotationCurve, 'value'): 116 return (None, None, None) 117 return (x * 180.0 / math.pi for x in geo2.QuaternionRotationGetYawPitchRoll(targetModel.rotationCurve.value)) 118 119 120 def GetObjectQuantity(objectID): 121 scenario = sm.StartService('scenario') 122 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 123 if slimItem is None: 124 raise RuntimeError('No slim item?') 125 targetModel = getattr(targetBall, 'model', None) 126 if not targetModel: 127 return 128 if hasattr(targetModel, 'scaling') or hasattr(targetModel, 'modelScale'): 129 if not getattr(slimItem, 'dunRadius', None): 130 slimItem.dunRadius = targetBall.radius 131 if slimItem.categoryID == const.categoryAsteroid: 132 return slimItem.dunRadius 133 if slimItem.groupID in (const.groupHarvestableCloud, const.groupCloud): 134 return slimItem.dunRadius 135 136 137 def GetObjectRadius(objectID): 138 scenario = sm.StartService('scenario') 139 targetBall, slimItem = scenario.GetBallAndSlimItemFromObjectID(objectID) 140 if slimItem is None: 141 raise RuntimeError('No slim item?') 142 targetModel = getattr(targetBall, 'model', None) 143 if not targetModel: 144 return 145 if hasattr(targetModel, 'scaling') or hasattr(targetModel, 'modelScale'): 146 godma = sm.GetService('godma') 147 if not getattr(slimItem, 'dunRadius', None): 148 slimItem.dunRadius = ComputeQuantityFromRadius(slimItem.categoryID, slimItem.groupID, slimItem.typeID, targetBall.radius, godma) 149 if slimItem.categoryID == const.categoryAsteroid: 150 return ComputeRadiusFromQuantity(slimItem.categoryID, slimItem.groupID, slimItem.typeID, slimItem.dunRadius, godma) 151 if slimItem.groupID in (const.groupHarvestableCloud, const.groupCloud): 152 return ComputeRadiusFromQuantity(slimItem.categoryID, slimItem.groupID, slimItem.typeID, slimItem.dunRadius, godma)