You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
"""
|
|
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
its licensors.
|
|
|
|
For complete copyright and license terms please see the LICENSE at the root of this
|
|
distribution (the "License"). All use of this software is governed by the License,
|
|
or, if provided, by the license below or the license accompanying this file. Do not
|
|
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
"""
|
|
|
|
import azlmbr
|
|
from enum import Enum
|
|
|
|
class Constants():
|
|
DAMAGE_MIN_RADIUS = 1.0
|
|
DAMAGE_MAX_RADIUS = 1.0
|
|
DAMAGE_AMOUNT = 10.0 # Enough to break a `brittle` object
|
|
|
|
|
|
class CollisionHandler:
|
|
def __init__(self, id, target_id):
|
|
self.id = id
|
|
self.target_id = target_id
|
|
self.collision_happened = False
|
|
self.create_collision_handler()
|
|
|
|
def on_collision_begin(self, args):
|
|
if args[0].Equal(self.target_id):
|
|
self.collision_happened = True
|
|
|
|
def create_collision_handler(self):
|
|
self.handler = azlmbr.physics.CollisionNotificationBusHandler()
|
|
self.handler.connect(self.id)
|
|
self.handler.add_callback("OnCollisionBegin", self.on_collision_begin)
|
|
|
|
|
|
class BlastNotificationHandler:
|
|
def __init__(self, id):
|
|
self.id = id
|
|
self.actors_destroyed = 0
|
|
self.actors_created = 0
|
|
self.create_collision_handler()
|
|
|
|
def on_actor_created(self, args):
|
|
self.actors_created += 1
|
|
|
|
def on_actor_destroyed(self, args):
|
|
self.actors_destroyed += 1
|
|
|
|
def create_collision_handler(self):
|
|
self.handler = azlmbr.destruction.BlastFamilyComponentNotificationBusHandler()
|
|
self.handler.connect(self.id)
|
|
self.handler.add_callback("On Actor Created", self.on_actor_created)
|
|
self.handler.add_callback("On Actor Destroyed", self.on_actor_destroyed) |