test1.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. local SpawnerScriptSample =
  12. {
  13. Properties =
  14. {
  15. ScriptVar = { default = "test3" }
  16. }
  17. }
  18. function SpawnerScriptSample:OnActivate()
  19. -- Register our handlers to receive notification from the spawner attached to this entity.
  20. if( self.spawnerNotiBusHandler == nil ) then
  21. self.spawnerNotiBusHandler = SpawnerComponentNotificationBus.Connect(self, self.entityId)
  22. end
  23. local test2 = require("test2")
  24. test2.ActivateMySpawner3(self.entityId)
  25. end
  26. -- This handler is called when we start spawning a slice.
  27. function SpawnerScriptSample:OnSpawnBegin(sliceTicket)
  28. -- Do something so we know if/when this is being called
  29. Debug.Log("Slice Spawn Begin")
  30. end
  31. -- This handler is called when we're finished spawning a slice.
  32. function SpawnerScriptSample:OnSpawnEnd(sliceTicket)
  33. -- Do something so we know if/when this is being called
  34. Debug.Log("Slice Spawn End")
  35. end
  36. -- This handler is called whenever an entity is spawned.
  37. function SpawnerScriptSample:OnEntitySpawned(sliceTicket, entityId)
  38. -- Do something so we know if/when this is being called
  39. Debug.Log("Entity Spawned: " .. tostring(entityId) )
  40. end
  41. function SpawnerScriptSample:OnDeactivate()
  42. -- Disconnect our spawner notificaton
  43. if self.spawnerNotiBusHandler ~= nil then
  44. self.spawnerNotiBusHandler:Disconnect()
  45. self.spawnerNotiBusHandler = nil
  46. end
  47. end
  48. return SpawnerScriptSample