diff --git a/SHADE_Managed/src/Physics/CollisionInfo.cxx b/SHADE_Managed/src/Physics/CollisionInfo.cxx
index 9048837f..135760db 100644
--- a/SHADE_Managed/src/Physics/CollisionInfo.cxx
+++ b/SHADE_Managed/src/Physics/CollisionInfo.cxx
@@ -14,6 +14,8 @@ of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#include "SHpch.h"
#include "CollisionInfo.hxx"
+#include "Components/RigidBody.hxx"
+#include "Components/Collider.hxx"
namespace SHADE
{
diff --git a/SHADE_Managed/src/Physics/CollisionInfo.hxx b/SHADE_Managed/src/Physics/CollisionInfo.hxx
index a486b0d0..40cb9ccc 100644
--- a/SHADE_Managed/src/Physics/CollisionInfo.hxx
+++ b/SHADE_Managed/src/Physics/CollisionInfo.hxx
@@ -15,11 +15,19 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// Project Includes
#include "Engine/GameObject.hxx"
-#include "Components/RigidBody.hxx"
-#include "Components/Collider.hxx"
namespace SHADE
{
+ /*---------------------------------------------------------------------------------*/
+ /* Forward Declarations */
+ /*---------------------------------------------------------------------------------*/
+ ref class RigidBody;
+ ref class Collider;
+ ref class CollisionShape;
+
+ /*---------------------------------------------------------------------------------*/
+ /* Type Definitions */
+ /*---------------------------------------------------------------------------------*/
///
/// Struct that describes a collision
///
diff --git a/SHADE_Managed/src/Scripts/Script.cxx b/SHADE_Managed/src/Scripts/Script.cxx
index d4004e03..e476d69d 100644
--- a/SHADE_Managed/src/Scripts/Script.cxx
+++ b/SHADE_Managed/src/Scripts/Script.cxx
@@ -147,6 +147,48 @@ namespace SHADE
SAFE_NATIVE_CALL_END(this)
}
+ void Script::OnCollisionEnter(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onCollisionEnter(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
+ void Script::OnCollisionStay(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onCollisionStay(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
+ void Script::OnCollisionExit(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onCollisionExit(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
+ void Script::OnTriggerEnter(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onTriggerEnter(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
+ void Script::OnTriggerStay(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onTriggerStay(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
+ void Script::OnTriggerExit(CollisionInfo collision)
+ {
+ SAFE_NATIVE_CALL_BEGIN
+ onTriggerExit(collision);
+ SAFE_NATIVE_CALL_END(this)
+ }
+
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/
@@ -169,4 +211,14 @@ namespace SHADE
void Script::update() {}
void Script::lateUpdate() {}
void Script::onDestroy() {}
-}// namespace PlushieAPI
+
+ /*---------------------------------------------------------------------------------*/
+ /* Virtual Event Functions */
+ /*---------------------------------------------------------------------------------*/
+ void Script::onTriggerEnter(CollisionInfo) {}
+ void Script::onTriggerStay(CollisionInfo) {}
+ void Script::onTriggerExit(CollisionInfo) {}
+ void Script::onCollisionEnter(CollisionInfo) {}
+ void Script::onCollisionStay(CollisionInfo) {}
+ void Script::onCollisionExit(CollisionInfo) {}
+}
diff --git a/SHADE_Managed/src/Scripts/Script.hxx b/SHADE_Managed/src/Scripts/Script.hxx
index bd336726..afeaa8a0 100644
--- a/SHADE_Managed/src/Scripts/Script.hxx
+++ b/SHADE_Managed/src/Scripts/Script.hxx
@@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited.
// Project Includes
#include "Engine/GameObject.hxx"
+#include "Physics/CollisionInfo.hxx"
namespace SHADE
{
@@ -213,6 +214,46 @@ namespace SHADE
///
void OnDestroy();
+ /*-----------------------------------------------------------------------------*/
+ /* Event Functions */
+ /*-----------------------------------------------------------------------------*/
+ ///
+ /// Used to call onCollisionEnter(). This should be called when a collision is
+ /// detected between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnCollisionEnter(CollisionInfo collision);
+ ///
+ /// Used to call onCollisionStay(). This should be called when a collision is
+ /// persistent between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnCollisionStay(CollisionInfo collision);
+ ///
+ /// Used to call onCollisionExit(). This should be called when a collision ends
+ /// between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnCollisionExit(CollisionInfo collision);
+ ///
+ /// Used to call onTriggerEnter(). This should be called when a trigger-type
+ /// collision is detected between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnTriggerEnter(CollisionInfo collision);
+ ///
+ /// Used to call onTriggerStay(). This should be called when a trigger-type
+ /// collision is detected between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnTriggerStay(CollisionInfo collision);
+ ///
+ /// Used to call onTriggerExit(). This should be called when a trigger-type
+ /// collision is detected between the attached GameObject and another GameObject.
+ ///
+ /// Information on the collision event.
+ void OnTriggerExit(CollisionInfo collision);
+
protected:
/*-----------------------------------------------------------------------------*/
/* Constructors */
@@ -273,6 +314,46 @@ namespace SHADE
///
virtual void onDestroy();
+ /*-----------------------------------------------------------------------------*/
+ /* Virtual Event Functions */
+ /*-----------------------------------------------------------------------------*/
+ ///
+ /// Called when the attached GameObject has a trigger Collider and collides with
+ /// another GameObject with a Collider in the first frame of collision.
+ ///
+ /// Information on the collision event.
+ virtual void onTriggerEnter(CollisionInfo info);
+ ///
+ /// Called when the attached GameObject has a trigger Collider and collides with
+ /// another GameObject with a Collider in subsequent frames of collision.
+ ///
+ /// Information on the collision event.
+ virtual void onTriggerStay(CollisionInfo info);
+ ///
+ /// Called when the attached GameObject has a trigger Collider and leaves a
+ /// collision with another GameObject with a Collider2D.
+ ///
+ /// Information on the collision event.
+ virtual void onTriggerExit(CollisionInfo info);
+ ///
+ /// Called when the attached GameObject has a Collider and collides with
+ /// another GameObject with a Collider in the first frame of collision.
+ ///
+ /// Information on the collision event.
+ virtual void onCollisionEnter(CollisionInfo info);
+ ///
+ /// Called when the attached GameObject has a Collider and collides with
+ /// another GameObject with a Collider in subsequent frames of collision.
+ ///
+ /// Information on the collision event.
+ virtual void onCollisionStay(CollisionInfo info);
+ ///
+ /// Called when the attached GameObject has a Collider and leaves a
+ /// collision with another GameObject with a Collider2D.
+ ///
+ /// Information on the collision event.
+ virtual void onCollisionExit(CollisionInfo info);
+
private:
/*-----------------------------------------------------------------------------*/
/* Data Members */
@@ -280,4 +361,4 @@ namespace SHADE
GameObject owner;
};
-} // namespace PlushieAPI
+}