""" 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. """ # fmt: off class Tests(): enter_game_mode = ("Entered game mode", "Failed to enter game mode") find_moving = ("Moving entity found", "Moving entity not found") find_destructable = ("Destructable entity found", "Destructable entity not found") find_root_actor = ("Root actor of destructable entity found", "Root actor of destructable entity not found") collisions = ("Collision occurred between entities", "Collision did not occur between entities") root_actor_destroyed = ("Root actor destroyed", "Root actor was not destroyed") child_actors_created = ("Child actors created", "Child actors were not created") exit_game_mode = ("Exited game mode", "Couldn't exit game mode") # fmt: on def run(): """ Summary: Open a Project that already has 1 rigid sphere entity and 1 destructable entity and verify collision and damage to destructable entity. Level Description: Moving Sphere and Destructable entities are created in level with same collision layer and same collision group. Moving Sphere entity is placed above the Destructable entity. Expected Behavior: Moving Sphere has to collide with Destructable entity under the effect of gravity. Destructable entity root actor should be destroyed and 2 child actors should be created to replace it. Test Steps: 1) Open level and Enter game mode 2) Retrieve and validate Entities 3) Get the entity representing root actor of destructable entity 4) Check moving sphere collides with root actor of destructable entity due to gravity 5) Check root actor is destroyed 6) Check child actors of root actor are created 7) Exit game mode 8) Close the editor :return: None """ import ImportPathHelper as imports imports.init() from utils import Report from utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus from Utils import CollisionHandler from Utils import BlastNotificationHandler # Constants TIMEOUT = 2.0 helper.init_idle() # 1) Open level and Enter game mode helper.open_level("Blast", "Blast_ActorSplitsAfterCollision") helper.enter_game_mode(Tests.enter_game_mode) # 2) Retrieve and validate Entities moving_id = general.find_game_entity("Sphere_Moving") Report.critical_result(Tests.find_moving, moving_id.IsValid()) destructable_id = general.find_game_entity("Destructable_Box") Report.critical_result(Tests.find_destructable, destructable_id.IsValid()) # 3) Get the entity representing root actor of destructable entity destructable_initial_actors = azlmbr.destruction.BlastFamilyComponentRequestBus(azlmbr.bus.Event, "Get Actors Data", destructable_id) Report.critical_result(Tests.find_root_actor, len(destructable_initial_actors) == 1) destructable_initial_actor_id = destructable_initial_actors[0].EntityId collision = CollisionHandler(destructable_initial_actor_id, moving_id) family_handler = BlastNotificationHandler(destructable_id) # 4) Check moving sphere collides with root actor of destructable entity due to gravity helper.wait_for_condition(lambda: collision.collision_happened, TIMEOUT) Report.result(Tests.collisions, collision.collision_happened) # 5) Check root actor is destroyed helper.wait_for_condition(lambda: family_handler.actors_destroyed == 1, TIMEOUT) Report.result(Tests.root_actor_destroyed, family_handler.actors_destroyed == 1) # 6) Check child actors of root actor are created helper.wait_for_condition(lambda: family_handler.actors_created == 2, TIMEOUT) Report.result(Tests.child_actors_created, family_handler.actors_created == 2) # 7) Exit game mode helper.exit_game_mode(Tests.exit_game_mode) # 8) Close the editor helper.close_editor() if __name__ == "__main__": run()