test3_general_dependencies.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 = "some/file/in/some/folder.cfg" }
  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. end
  24. -- This handler is called when we start spawning a slice.
  25. function SpawnerScriptSample:OnSpawnBegin(sliceTicket)
  26. -- Do something so we know if/when this is being called
  27. Debug.Log("Slice Spawn Begin")
  28. end
  29. -- This handler is called when we're finished spawning a slice.
  30. function SpawnerScriptSample:OnSpawnEnd(sliceTicket)
  31. -- Do something so we know if/when this is being called
  32. Debug.Log("Slice Spawn End")
  33. end
  34. -- This handler is called whenever an entity is spawned.
  35. function SpawnerScriptSample:OnEntitySpawned(sliceTicket, entityId)
  36. -- Do something so we know if/when this is being called
  37. Debug.Log("Entity Spawned: " .. tostring(entityId) )
  38. end
  39. function SpawnerScriptSample:OnDeactivate()
  40. -- Disconnect our spawner notificaton
  41. if self.spawnerNotiBusHandler ~= nil then
  42. self.spawnerNotiBusHandler:Disconnect()
  43. self.spawnerNotiBusHandler = nil
  44. end
  45. end
  46. return SpawnerScriptSample