Added collision and trigger event functions for Script
This commit is contained in:
parent
40044cbbfe
commit
60c2c9facb
|
@ -14,6 +14,8 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
#include "SHpch.h"
|
#include "SHpch.h"
|
||||||
#include "CollisionInfo.hxx"
|
#include "CollisionInfo.hxx"
|
||||||
|
#include "Components/RigidBody.hxx"
|
||||||
|
#include "Components/Collider.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,19 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#pragma once
|
#pragma once
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "Engine/GameObject.hxx"
|
#include "Engine/GameObject.hxx"
|
||||||
#include "Components/RigidBody.hxx"
|
|
||||||
#include "Components/Collider.hxx"
|
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Forward Declarations */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
ref class RigidBody;
|
||||||
|
ref class Collider;
|
||||||
|
ref class CollisionShape;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Type Definitions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Struct that describes a collision
|
/// Struct that describes a collision
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -147,6 +147,48 @@ namespace SHADE
|
||||||
SAFE_NATIVE_CALL_END(this)
|
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 */
|
/* Constructors */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -169,4 +211,14 @@ namespace SHADE
|
||||||
void Script::update() {}
|
void Script::update() {}
|
||||||
void Script::lateUpdate() {}
|
void Script::lateUpdate() {}
|
||||||
void Script::onDestroy() {}
|
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) {}
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
|
|
||||||
// Project Includes
|
// Project Includes
|
||||||
#include "Engine/GameObject.hxx"
|
#include "Engine/GameObject.hxx"
|
||||||
|
#include "Physics/CollisionInfo.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -213,6 +214,46 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnDestroy();
|
void OnDestroy();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Event Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onCollisionEnter(). This should be called when a collision is
|
||||||
|
/// detected between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnCollisionEnter(CollisionInfo collision);
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onCollisionStay(). This should be called when a collision is
|
||||||
|
/// persistent between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnCollisionStay(CollisionInfo collision);
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onCollisionExit(). This should be called when a collision ends
|
||||||
|
/// between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnCollisionExit(CollisionInfo collision);
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onTriggerEnter(). This should be called when a trigger-type
|
||||||
|
/// collision is detected between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnTriggerEnter(CollisionInfo collision);
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onTriggerStay(). This should be called when a trigger-type
|
||||||
|
/// collision is detected between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnTriggerStay(CollisionInfo collision);
|
||||||
|
/// <summary>
|
||||||
|
/// Used to call onTriggerExit(). This should be called when a trigger-type
|
||||||
|
/// collision is detected between the attached GameObject and another GameObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collision">Information on the collision event.</param>
|
||||||
|
void OnTriggerExit(CollisionInfo collision);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
|
@ -273,6 +314,46 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
virtual void onDestroy();
|
virtual void onDestroy();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Virtual Event Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a trigger Collider and collides with
|
||||||
|
/// another GameObject with a Collider in the first frame of collision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onTriggerEnter(CollisionInfo info);
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a trigger Collider and collides with
|
||||||
|
/// another GameObject with a Collider in subsequent frames of collision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onTriggerStay(CollisionInfo info);
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a trigger Collider and leaves a
|
||||||
|
/// collision with another GameObject with a Collider2D.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onTriggerExit(CollisionInfo info);
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a Collider and collides with
|
||||||
|
/// another GameObject with a Collider in the first frame of collision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onCollisionEnter(CollisionInfo info);
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a Collider and collides with
|
||||||
|
/// another GameObject with a Collider in subsequent frames of collision.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onCollisionStay(CollisionInfo info);
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the attached GameObject has a Collider and leaves a
|
||||||
|
/// collision with another GameObject with a Collider2D.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Information on the collision event.</param>
|
||||||
|
virtual void onCollisionExit(CollisionInfo info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
|
@ -280,4 +361,4 @@ namespace SHADE
|
||||||
GameObject owner;
|
GameObject owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace PlushieAPI
|
}
|
||||||
|
|
Loading…
Reference in New Issue