test1.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. require("scripts.test3")
  12. local utilities = require "scripts.test4"
  13. local SpawnerScriptSample =
  14. {
  15. Properties =
  16. {
  17. ScriptVar = { default = "test3" }
  18. }
  19. }
  20. function SpawnerScriptSample:OnActivate()
  21. -- Register our handlers to receive notification from the spawner attached to this entity.
  22. if( self.spawnerNotiBusHandler == nil ) then
  23. self.spawnerNotiBusHandler = SpawnerComponentNotificationBus.Connect(self, self.entityId)
  24. end
  25. local test2 = require("scripts.test2")
  26. if self.requiresInit == true then
  27. end
  28. end
  29. -- This handler is called when we start spawning a slice.
  30. function SpawnerScriptSample:OnSpawnBegin(sliceTicket)
  31. -- Do something so we know if/when this is being called
  32. Debug.Log("Slice Spawn Begin")
  33. end
  34. -- This handler is called when we're finished spawning a slice.
  35. function SpawnerScriptSample:OnSpawnEnd(sliceTicket)
  36. -- Do something so we know if/when this is being called
  37. Debug.Log("Slice Spawn End")
  38. end
  39. -- This handler is called whenever an entity is spawned.
  40. function SpawnerScriptSample:OnEntitySpawned(sliceTicket, entityId)
  41. -- Do something so we know if/when this is being called
  42. Debug.Log("Entity Spawned: " .. tostring(entityId) )
  43. end
  44. function SpawnerScriptSample:OnDeactivate()
  45. -- Disconnect our spawner notificaton
  46. if self.spawnerNotiBusHandler ~= nil then
  47. self.spawnerNotiBusHandler:Disconnect()
  48. self.spawnerNotiBusHandler = nil
  49. end
  50. end
  51. return SpawnerScriptSample