AddModifyDelete_Utils.py 977 B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import azlmbr.legacy.general as general
  7. import azlmbr.bus as bus
  8. import azlmbr.components
  9. import azlmbr.physics
  10. class Box:
  11. def __init__(self, name):
  12. self.name = name
  13. self.distances = []
  14. def find(self):
  15. self.id = general.find_game_entity(self.name)
  16. self.start_position = self.position
  17. return self.id.IsValid()
  18. @property
  19. def position(self):
  20. return azlmbr.components.TransformBus(bus.Event, "GetWorldTranslation", self.id)
  21. def is_stationary(self):
  22. velocity = azlmbr.physics.RigidBodyRequestBus(bus.Event, "GetLinearVelocity", self.id)
  23. return velocity.IsZero()
  24. def push(self, impulse):
  25. azlmbr.physics.RigidBodyRequestBus(bus.Event, "ApplyLinearImpulse", self.id, impulse)