3
0

held.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 held =
  12. {
  13. Properties =
  14. {
  15. IncomingInputEventName = "",
  16. OutgoingGameplayEventName = "",
  17. },
  18. }
  19. function held:OnActivate()
  20. local inputBusId = InputEventNotificationId(self.Properties.IncomingInputEventName)
  21. self.inputBus = InputEventNotificationBus.Connect(self, inputBusId)
  22. end
  23. function held:OnPressed(floatValue)
  24. GameplayNotificationBus.Event.OnEventBegin(GameplayNotificationId(self.entityId, self.Properties.OutgoingGameplayEventName, "float"), floatValue)
  25. end
  26. function held:OnHeld(floatValue)
  27. GameplayNotificationBus.Event.OnEventUpdating(GameplayNotificationId(self.entityId, self.Properties.OutgoingGameplayEventName, "float"), floatValue)
  28. end
  29. function held:OnReleased(floatValue)
  30. GameplayNotificationBus.Event.OnEventEnd(GameplayNotificationId(self.entityId, self.Properties.OutgoingGameplayEventName, "float"), floatValue)
  31. end
  32. function held:OnDeactivate()
  33. self.inputBus:Disconnect()
  34. end
  35. return held