Merge branch 'main' into PlayerController

This commit is contained in:
Glence 2023-03-10 14:59:47 +08:00
commit 2cf67a1378
12 changed files with 190 additions and 67 deletions

View File

@ -38,6 +38,7 @@
idleClip: 227450439
runClip: 229125027
pickUpClip: 219605278
controlAniSys: true
- EID: 1
Name: Default
IsActive: true
@ -79,4 +80,5 @@
fullClip: 231416496
idleClip: 0
runClip: 0
pickUpClip: 0
pickUpClip: 0
controlAniSys: false

View File

@ -13,6 +13,8 @@ namespace SHADE.Test
private AnimationClipAsset runClip;
[SerializeField]
private AnimationClipAsset pickUpClip;
[SerializeField]
private bool controlAniSys = false;
#endregion
#region Components
@ -34,19 +36,30 @@ namespace SHADE.Test
// Play animations
if (Input.GetKeyUp(Input.KeyCode.Equals))
{
playFunc(fullClip);
if (fullClip)
playFunc(fullClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha1))
{
playFunc(idleClip);
if (idleClip)
playFunc(idleClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha2))
{
playFunc(runClip);
if (runClip)
playFunc(runClip);
}
else if (Input.GetKeyUp(Input.KeyCode.Alpha3))
{
playFunc(pickUpClip);
if (pickUpClip)
playFunc(pickUpClip);
}
// Play and pause
if (controlAniSys && Input.GetKeyUp(Input.KeyCode.Space))
{
AnimationSystem.TimeScale = AnimationSystem.TimeScale > 0.0f ? 0.0f
: AnimationSystem.DefaultTimeScale;
}
}
#endregion

View File

@ -32,6 +32,7 @@ namespace SHADE
void SHAnimationSystem::UpdateRoutine::Execute(double dt) noexcept
{
auto& animators = SHComponentManager::GetDense<SHAnimatorComponent>();
dt *= reinterpret_cast<SHAnimationSystem*>(system)->TimeScale;
for (auto& animator : animators)
{
animator.Update(dt);

View File

@ -42,6 +42,23 @@ namespace SHADE
void Execute(double dt) noexcept override final;
};
/*---------------------------------------------------------------------------------*/
/* Constants */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Default time scale used by the system.
/// </summary>
static constexpr double DEFAULT_TIME_SCALE = 1.0;
/*---------------------------------------------------------------------------------*/
/* Public Data Members */
/*---------------------------------------------------------------------------------*/
/// <summary>
/// Used by the system to multiply the given delta time to scale the animation
/// speed.
/// </summary>
double TimeScale = DEFAULT_TIME_SCALE;
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/

View File

@ -29,6 +29,17 @@ namespace SHADE
/// </summary>
public value struct AnimationClipAsset
{
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationClip is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationClipAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
@ -57,16 +68,6 @@ namespace SHADE
/// <param name="AnimationClipId">AssetID to the AnimationClip asset.</param>
AnimationClipAsset(AssetID AnimationClipId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationClip is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationClipAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -28,7 +28,18 @@ namespace SHADE
/// </summary>
public value struct AnimationControllerAsset
{
internal:
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationController is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationControllerAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
@ -56,16 +67,6 @@ namespace SHADE
/// <param name="AnimationControllerId">AssetID to the AnimationController asset.</param>
AnimationControllerAsset(AssetID AnimationControllerId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationController is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationControllerAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -28,6 +28,17 @@ namespace SHADE
/// </summary>
public value struct AnimationRigAsset
{
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationRig is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationRigAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
@ -56,16 +67,6 @@ namespace SHADE
/// <param name="AnimationRigId">AssetID to the AnimationRig asset.</param>
AnimationRigAsset(AssetID AnimationRigId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a AnimationRig is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(AnimationRigAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -28,6 +28,17 @@ namespace SHADE
/// </summary>
public value struct FontAsset
{
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Font is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(FontAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
@ -56,16 +67,6 @@ namespace SHADE
/// <param name="fontId">AssetID to the font asset.</param>
FontAsset(AssetID fontId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Font is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(FontAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -28,6 +28,17 @@ namespace SHADE
/// </summary>
public value struct MaterialAsset
{
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Material is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(MaterialAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
@ -56,16 +67,6 @@ namespace SHADE
/// <param name="MaterialId">AssetID to the Material asset.</param>
MaterialAsset(AssetID MaterialId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Material is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(MaterialAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -28,7 +28,18 @@ namespace SHADE
/// </summary>
public value struct MeshAsset
{
internal:
public:
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Mesh is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(MeshAsset asset);
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
@ -56,16 +67,6 @@ namespace SHADE
/// <param name="meshId">AssetID to the Mesh asset.</param>
MeshAsset(AssetID meshId);
/*-----------------------------------------------------------------------------*/
/* Operator Overloads */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Implicit conversion operator to enable checking if a Mesh is valid.
/// </summary>
/// <param name="gameObj">Asset to check.</param>
/// <returns>True if the Asset is valid.</returns>
static operator bool(MeshAsset asset);
/*-----------------------------------------------------------------------------*/
/* Conversion Operators */
/*-----------------------------------------------------------------------------*/

View File

@ -0,0 +1,37 @@
/************************************************************************************//*!
\file AnimationSystem.cxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Mar 10, 2023
\brief Contains the definition of the functions of the managed AnimationSystem
static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2023 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
// Precompiled Headers
#include "SHpch.h"
// Primary Header
#include "AnimationSystem.hxx"
// External Dependencies
#include "ECS_Base/Managers/SHSystemManager.h"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Properties */
/*---------------------------------------------------------------------------------*/
double AnimationSystem::TimeScale::get()
{
auto sys = SHSystemManager::GetSystem<SHAnimationSystem>();
return sys->TimeScale;
}
void AnimationSystem::TimeScale::set(double value)
{
auto sys = SHSystemManager::GetSystem<SHAnimationSystem>();
sys->TimeScale = value;
}
}

View File

@ -0,0 +1,47 @@
/************************************************************************************//*!
\file AnimationSystem.hxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Mar 10, 2023
\brief Contains the definition of the managed AnimationSystem static class.
Note: This file is written in C++17/CLI.
Copyright (C) 2023 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
#pragma once
#include "Animation/SHAnimationSystem.h"
namespace SHADE
{
/// <summary>
/// Static class for interfacing with the animation system.
/// </summary>
public ref class AnimationSystem abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Constants */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Default time scale used by the system.
/// </summary>
literal double DefaultTimeScale = SHAnimationSystem::DEFAULT_TIME_SCALE;
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Used by the system to multiply the given delta time to scale the animation
/// speed.
/// </summary>
static property double TimeScale
{
double get();
void set(double value);
}
};
}