rxactor.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # rxactor.py
  2. # Parent class for all actors in the world.
  3. #print "rxactor.................................."
  4. import sys
  5. import clr
  6. clr.AddReferenceToFile("OpenSim.Region.RexScriptModule.dll")
  7. import rxlslobject
  8. import rxworld
  9. class Actor(rxlslobject.LSLObject):
  10. def __init__(self, vId):
  11. #super(Actor,self).__init__()
  12. self.MyWorld = None
  13. self.Id = str(vId)
  14. self.MyTag = ""
  15. self.MyEvent = ""
  16. self.MyTimerCount = 0
  17. self.bTimerLoop = False
  18. #def __del__(self):
  19. # #print "DELETING ACTOR!"
  20. # #super(self.__class__, self).__del__()
  21. def GetScriptClassName():
  22. return "rxactor.Actor"
  23. def GetId(self):
  24. return str(self.Id)
  25. # Send python command to client
  26. def CommandToClient(self,vAgentId,vUnit,vCommand,vCmdParams):
  27. self.MyWorld.CS.CommandToClient(vAgentId,vUnit,vCommand,vCmdParams)
  28. # Velocity
  29. def SetVelocity(self,vVelocity):
  30. return self.MyWorld.CS.SetVelocity(self.Id,vVelocity)
  31. Velocity = property(fget=lambda self: self.llGetVel(),fset=lambda self, v: self.SetVelocity(v))
  32. # Physics
  33. def GetPhysics(self):
  34. return self.MyWorld.CS.GetPhysics(self.Id)
  35. def SetPhysics(self,vbPhysics):
  36. return self.MyWorld.CS.SetPhysics(self.Id,vbPhysics)
  37. Physics = property(fget=lambda self: self.GetPhysics(),fset=lambda self, v: self.SetPhysics(v))
  38. #Mass
  39. def SetMass(self,vMass):
  40. return self.MyWorld.CS.SetMass(self.Id,vMass)
  41. Mass = property(fget=lambda self: self.llGetMass(),fset=lambda self, v: self.SetMass(v))
  42. def GetUsePrimVolumeCollision(self):
  43. return self.MyWorld.CS.GetUsePrimVolumeCollision(self.Id)
  44. def SetUsePrimVolumeCollision(self,vUsePrimVolumeCol):
  45. self.MyWorld.CS.SetUsePrimVolumeCollision(self.Id,vUsePrimVolumeCol)
  46. def SendGeneralAlertAll(self,vString):
  47. self.MyWorld.CS.SendGeneralAlertAll(self.Id,vString)
  48. def SendAlertToAvatar(self,vAgentId,vString,vbModal):
  49. self.MyWorld.CS.SendAlertToAvatar(self.Id,vAgentId,vString,vbModal)
  50. def GetRadiusActors(self,vRadius):
  51. return self.MyWorld.CS.GetRadiusActors(self.Id,vRadius)
  52. def GetRadiusAvatars(self,vRadius):
  53. return self.MyWorld.CS.GetRadiusAvatars(self.Id,vRadius)
  54. def EnableTick(self):
  55. self.MyWorld.MyEventManager.EnableTickForActor(self)
  56. def DisableTick(self):
  57. self.MyWorld.MyEventManager.DisableTickForActor(self)
  58. def SetTimer(self,vTime,vbLoop):
  59. self.MyWorld.MyEventManager.SetTimerForActor(self,vTime,vbLoop)
  60. def SpawnActor(self,vLoc,vIndex,vbTemprorary,vPyClass):
  61. return self.MyWorld.CS.SpawnActor(vLoc,vIndex,vbTemprorary,vPyClass)
  62. def DestroyActor(self):
  63. return self.MyWorld.CS.DestroyActor(self.Id)
  64. def SetMesh(self,vMeshName):
  65. return self.MyWorld.CS.SetMesh(self.Id,vMeshName)
  66. def SetMeshByLLUUID(self,vMeshLLUUID):
  67. return self.MyWorld.CS.SetMeshByLLUUID(self.Id,vMeshLLUUID)
  68. def SetMaterial(self,vIndex,vName):
  69. return self.MyWorld.CS.SetMaterial(self.Id,vIndex,vName)
  70. # Scale
  71. Scale = property(fget=lambda self: self.llGetScale(),fset=lambda self, v: self.llSetScale(v))
  72. def GetTime(self):
  73. return self.MyWorld.MyEventManager.CurrTime
  74. # Events
  75. def EventPreCreated(self):
  76. pass
  77. def EventCreated(self):
  78. pass
  79. def EventDestroyed(self):
  80. pass
  81. def EventTouch(self,vAvatar):
  82. pass
  83. def EventTick(self,vDeltaTime):
  84. pass
  85. def EventTimer(self):
  86. pass
  87. def EventTrigger(self,vOther):
  88. pass
  89. def EventPrimVolumeCollision(self,vOther):
  90. pass
  91. # Trigger event
  92. def TriggerEvent(self,vEventStr,vOther):
  93. if len(vEventStr) == 0:
  94. print "TriggerEvent, no event string defined"
  95. return
  96. for iid, iactor in self.World.AllActors.iteritems():
  97. if iactor.MyTag == vEventStr:
  98. iactor.EventTrigger(vOther)
  99. def PrintActorList(self):
  100. print "Printing actor list..."
  101. print "Length is ",len(self.World.AllActors)
  102. for iid, iactor in self.World.AllActors.iteritems():
  103. print iid,iactor.Id
  104. #def GetFreezed(self):
  105. # return self.MyWorld.CS.GetFreezed(self.Id)
  106. #def SetFreezed(self,vbFreeze):
  107. # self.MyWorld.CS.SetFreezed(self.Id,vbFreeze)
  108. # PhysicsMode
  109. #def GetPhysicsMode(self):
  110. # return self.MyWorld.CS.GetPhysicsMode(self.Id)
  111. #def SetPhysicsMode(self,vPhysicsMode):
  112. # return self.MyWorld.CS.SetPhysicsMode(self.Id,vPhysicsMode)
  113. #PhysicsMode = property(fget=lambda self: self.GetPhysicsMode(),fset=lambda self, v: self.SetPhysicsMode(v))
  114. # Gravity
  115. #def GetUseGravity(self):
  116. # return self.MyWorld.CS.GetUseGravity(self.Id)
  117. #def SetUseGravity(self,vbGravity):
  118. # return self.MyWorld.CS.SetUseGravity(self.Id,vbGravity)
  119. #Gravity = property(fget=lambda self: self.GetUseGravity(),fset=lambda self, v: self.SetUseGravity(v))
  120. #def SetLocationFast(self,vLocation):
  121. # self.MyWorld.CS.SetLocationFast(self.Id,vLocation)