Merge remote-tracking branch 'origin/main' into SP3-2-Physics
This commit is contained in:
commit
99f41e947f
|
@ -105,6 +105,7 @@ namespace Sandbox
|
|||
SHSystemManager::RegisterRoutine<SHTransformSystem, SHTransformSystem::TransformPostPhysicsUpdate>();
|
||||
SHSystemManager::RegisterRoutine<SHDebugDrawSystem, SHDebugDrawSystem::ProcessPointsRoutine>();
|
||||
|
||||
SHSystemManager::RegisterRoutine<SHScriptEngine, SHScriptEngine::GizmosDrawRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BatcherDispatcherRoutine>();
|
||||
SHSystemManager::RegisterRoutine<SHGraphicsSystem, SHGraphicsSystem::BeginRoutine>();
|
||||
|
||||
|
|
|
@ -34,6 +34,99 @@ namespace SHADE
|
|||
Object TargetObject { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a function call that can be serialised and put togetheer with scripts.
|
||||
/// This variant accepts functions with 0 parameter.
|
||||
/// </summary>
|
||||
public class CallbackAction : ICallbackAction
|
||||
{
|
||||
#region Properties ------------------------------------------------------------
|
||||
/// <inheritdoc/>
|
||||
public Object TargetObject { get; private set; }
|
||||
/// <inheritdoc/>
|
||||
public string TargetMethodName => targetMethod == null ? "" : targetMethod.Name;
|
||||
/// <inheritdoc/>
|
||||
public bool IsRuntimeAction => targetAction != null;
|
||||
#endregion
|
||||
|
||||
#region Fields ------------------------------------------------------------------
|
||||
private MethodInfo targetMethod;
|
||||
private Action targetAction;
|
||||
private Object[] parameters;
|
||||
#endregion
|
||||
|
||||
#region Constructors ------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Constructs an empty Callback action.
|
||||
/// </summary>
|
||||
public CallbackAction() {}
|
||||
/// <summary>
|
||||
/// Constructs a CallbackAction that represents a call to the specified static
|
||||
/// method.
|
||||
/// </summary>
|
||||
/// <param name="method">Method to call.</param>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if a method that is not compatible with the target is specified. The method's
|
||||
/// source type must match the target's type.
|
||||
/// </exception>
|
||||
public CallbackAction(MethodInfo method)
|
||||
{
|
||||
// No errors, assign
|
||||
targetMethod = method;
|
||||
|
||||
// Create storage for parameters for calling
|
||||
parameters = new Object[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a CallbackAction that represents a call to a specified member
|
||||
/// method on the specified target.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if a method that is not compatible with the target is specified. The method's
|
||||
/// source type must match the target's type.
|
||||
/// </exception>
|
||||
public CallbackAction(Object target, MethodInfo method)
|
||||
{
|
||||
// Error Checks
|
||||
if (method.DeclaringType != target.GetType())
|
||||
throw new ArgumentException("[CallbackAction] Attempted register an action using an incompatible target object and method.");
|
||||
|
||||
// No errors, assign
|
||||
TargetObject = target;
|
||||
targetMethod = method;
|
||||
|
||||
// Create storage for parameters for calling
|
||||
parameters = new Object[0];
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a Callback action based on an action.
|
||||
/// </summary>
|
||||
/// <param name="action">Action that wraps a function to be called.</param>
|
||||
public CallbackAction(Action action)
|
||||
{
|
||||
targetAction = action;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Usage Functions ---------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Invokes the CallbackAction's stored method/action with the specified parameters.
|
||||
/// </summary>
|
||||
public void Invoke()
|
||||
{
|
||||
if (targetAction != null)
|
||||
{
|
||||
targetAction.Invoke();
|
||||
}
|
||||
else if (targetMethod != null)
|
||||
{
|
||||
_ = targetMethod.Invoke(TargetObject, parameters);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Represents a function call that can be serialised and put togetheer with scripts.
|
||||
/// This variant accepts functions with 1 parameter.
|
||||
|
|
|
@ -50,12 +50,12 @@ namespace SHADE
|
|||
Object TargetObject { get; }
|
||||
}
|
||||
|
||||
<# for (int i = 1; i <= max; ++i) { #>
|
||||
<# for (int i = 0; i <= max; ++i) { #>
|
||||
/// <summary>
|
||||
/// Represents a function call that can be serialised and put togetheer with scripts.
|
||||
/// This variant accepts functions with <#=i#> parameter<# if (i > 1) {#>s<#} #>.
|
||||
/// </summary>
|
||||
public class CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> : ICallbackAction
|
||||
public class CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> : ICallbackAction
|
||||
{
|
||||
#region Properties ------------------------------------------------------------
|
||||
/// <inheritdoc/>
|
||||
|
@ -68,7 +68,7 @@ namespace SHADE
|
|||
|
||||
#region Fields ------------------------------------------------------------------
|
||||
private MethodInfo targetMethod;
|
||||
private Action<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> targetAction;
|
||||
private Action<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> targetAction;
|
||||
private Object[] parameters;
|
||||
#endregion
|
||||
|
||||
|
@ -121,7 +121,7 @@ namespace SHADE
|
|||
/// Constructs a Callback action based on an action.
|
||||
/// </summary>
|
||||
/// <param name="action">Action that wraps a function to be called.</param>
|
||||
public CallbackAction(Action<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> action)
|
||||
public CallbackAction(Action<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action)
|
||||
{
|
||||
targetAction = action;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,92 @@ namespace SHADE
|
|||
IEnumerable<ICallbackAction> Actions { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A container of CallbackActions that is correlated to a specific scenario as
|
||||
/// specified by the user of this class.
|
||||
/// This variant accepts CallbackEvents with 1 generic parameter.
|
||||
/// </summary>
|
||||
public class CallbackEvent : ICallbackEvent
|
||||
{
|
||||
#region Properties --------------------------------------------------------------
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<ICallbackAction> Actions => actions;
|
||||
#endregion
|
||||
|
||||
#region Fields ------------------------------------------------------------------
|
||||
private List<ICallbackAction> actions = new List<ICallbackAction>();
|
||||
#endregion
|
||||
|
||||
#region Usage Functions ---------------------------------------------------------
|
||||
/// <inheritdoc/>
|
||||
public void RegisterAction()
|
||||
{
|
||||
actions.Add(new CallbackAction());
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RegisterAction(ICallbackAction action)
|
||||
{
|
||||
// Check if valid action
|
||||
if (action.GetType() != typeof(CallbackAction))
|
||||
{
|
||||
Debug.LogWarning("Attempted to register an invalid CallbackAction type. Ignoring.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">CallbackAction to add.</param>
|
||||
public void RegisterAction(CallbackAction action)
|
||||
{
|
||||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action action)
|
||||
{
|
||||
actions.Add(new CallbackAction(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
public void RegisterAction(Object target, MethodInfo method)
|
||||
{
|
||||
actions.Add(new CallbackAction(target, method));
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void DeregisterAction(ICallbackAction action)
|
||||
{
|
||||
if (!actions.Remove(action))
|
||||
{
|
||||
Debug.LogWarning("Attempted to deregister invalid action. Ignored.", this);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Invokes all stored CallbackActions with the specified parameters.
|
||||
/// </summary>
|
||||
public void Invoke()
|
||||
{
|
||||
foreach (CallbackAction action in actions)
|
||||
{
|
||||
try
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// A container of CallbackActions that is correlated to a specific scenario as
|
||||
/// specified by the user of this class.
|
||||
|
@ -88,7 +174,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1> action)
|
||||
|
@ -96,7 +182,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -174,7 +260,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2> action)
|
||||
|
@ -182,7 +268,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -260,7 +346,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3> action)
|
||||
|
@ -268,7 +354,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -346,7 +432,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4> action)
|
||||
|
@ -354,7 +440,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -432,7 +518,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5> action)
|
||||
|
@ -440,7 +526,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -518,7 +604,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5, T6> action)
|
||||
|
@ -526,7 +612,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -604,7 +690,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5, T6, T7> action)
|
||||
|
@ -612,7 +698,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -690,7 +776,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5, T6, T7, T8> action)
|
||||
|
@ -698,7 +784,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -776,7 +862,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> action)
|
||||
|
@ -784,7 +870,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
@ -862,7 +948,7 @@ namespace SHADE
|
|||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action)
|
||||
|
@ -870,7 +956,7 @@ namespace SHADE
|
|||
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
|
|
|
@ -61,13 +61,13 @@ namespace SHADE
|
|||
IEnumerable<ICallbackAction> Actions { get; }
|
||||
}
|
||||
|
||||
<# for (int i = 1; i <= max; ++i) { #>
|
||||
<# for (int i = 0; i <= max; ++i) { #>
|
||||
/// <summary>
|
||||
/// A container of CallbackActions that is correlated to a specific scenario as
|
||||
/// specified by the user of this class.
|
||||
/// This variant accepts CallbackEvents with 1 generic parameter.
|
||||
/// </summary>
|
||||
public class CallbackEvent<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> : ICallbackEvent
|
||||
public class CallbackEvent<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> : ICallbackEvent
|
||||
{
|
||||
#region Properties --------------------------------------------------------------
|
||||
/// <inheritdoc/>
|
||||
|
@ -82,13 +82,13 @@ namespace SHADE
|
|||
/// <inheritdoc/>
|
||||
public void RegisterAction()
|
||||
{
|
||||
actions.Add(new CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>>());
|
||||
actions.Add(new CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>());
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void RegisterAction(ICallbackAction action)
|
||||
{
|
||||
// Check if valid action
|
||||
if (action.GetType() != typeof(CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>>))
|
||||
if (action.GetType() != typeof(CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>))
|
||||
{
|
||||
Debug.LogWarning("Attempted to register an invalid CallbackAction type. Ignoring.", this);
|
||||
return;
|
||||
|
@ -100,26 +100,26 @@ namespace SHADE
|
|||
/// Adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">CallbackAction to add.</param>
|
||||
public void RegisterAction(CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> action)
|
||||
public void RegisterAction(CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action)
|
||||
{
|
||||
actions.Add(action);
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="action">System.Action to add as a CallbackAction.</param>
|
||||
public void RegisterAction(Action<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> action)
|
||||
public void RegisterAction(Action<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action)
|
||||
{
|
||||
actions.Add(new CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>>(action));
|
||||
actions.Add(new CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>(action));
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs and adds a CallbackACtion into the event.
|
||||
/// Constructs and adds a CallbackAction into the event.
|
||||
/// </summary>
|
||||
/// <param name="target">Object to call the method on.</param>
|
||||
/// <param name="method">Method to call.</param>
|
||||
public void RegisterAction(Object target, MethodInfo method)
|
||||
{
|
||||
actions.Add(new CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>>(target, method));
|
||||
actions.Add(new CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #>(target, method));
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void DeregisterAction(ICallbackAction action)
|
||||
|
@ -132,9 +132,9 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Invokes all stored CallbackActions with the specified parameters.
|
||||
/// </summary>
|
||||
public void Invoke(<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#> t<#=t#><# if (t != i) { #>, <# } #><# } #>)
|
||||
public void Invoke(<# if (i != 0) { for (int t = 1; t < i + 1; ++t) { #>T<#=t#> t<#=t#><# if (t != i) { #>, <# } #><# } } #>)
|
||||
{
|
||||
foreach (CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>> action in actions)
|
||||
foreach (CallbackAction<# if (i != 0) { #><<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>><# } #> action in actions)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -81,9 +81,8 @@ namespace SHADE
|
|||
//! The push constant data for the command buffer
|
||||
uint8_t pushConstantData[PUSH_CONSTANT_SIZE];
|
||||
|
||||
#ifdef _DEBUG
|
||||
//! Depth of segmenting of the command buffer (used for debug data)
|
||||
int segmentDepth;
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* PRIVATE MEMBER FUNCTIONS */
|
||||
|
|
|
@ -323,7 +323,7 @@ namespace SHADE
|
|||
static const SHMeshData SPHERE = SHPrimitiveGenerator::Sphere();
|
||||
for (const auto& idx : SPHERE.Indices)
|
||||
{
|
||||
spherePoints.emplace_back(SPHERE.VertexPositions[idx]);
|
||||
spherePoints.emplace_back(SPHERE.VertexPositions[idx] * radius);
|
||||
}
|
||||
}
|
||||
drawLineSet(storage, color, spherePoints.begin(), spherePoints.end());
|
||||
|
|
|
@ -379,6 +379,12 @@ namespace SHADE
|
|||
DEFAULT_CSHARP_LIB_NAME,
|
||||
DEFAULT_CSHARP_NAMESPACE + ".ScriptStore",
|
||||
"ExecuteLateUpdate"
|
||||
);
|
||||
csScriptsExecuteDrawGizmos = dotNet.GetFunctionPtr<CsFuncPtr>
|
||||
(
|
||||
DEFAULT_CSHARP_LIB_NAME,
|
||||
DEFAULT_CSHARP_NAMESPACE + ".ScriptStore",
|
||||
"ExecuteOnDrawGizmos"
|
||||
);
|
||||
csScriptsExecutePhysicsEvents = dotNet.GetFunctionPtr<CsFuncPtr>
|
||||
(
|
||||
|
|
|
@ -55,6 +55,12 @@ namespace SHADE
|
|||
LateUpdateRoutine();
|
||||
void Execute(double dt) noexcept override final;
|
||||
};
|
||||
class SH_API GizmosDrawRoutine final : public SHSystemRoutine
|
||||
{
|
||||
public:
|
||||
GizmosDrawRoutine();
|
||||
void Execute(double dt) noexcept override final;
|
||||
};
|
||||
class SH_API FrameCleanUpRoutine final : public SHSystemRoutine
|
||||
{
|
||||
public:
|
||||
|
@ -250,6 +256,7 @@ namespace SHADE
|
|||
CsFuncPtr csScriptsExecuteFixedUpdate = nullptr;
|
||||
CsFuncPtr csScriptsExecuteUpdate = nullptr;
|
||||
CsFuncPtr csScriptsExecuteLateUpdate = nullptr;
|
||||
CsFuncPtr csScriptsExecuteDrawGizmos = nullptr;
|
||||
CsFuncPtr csScriptsExecutePhysicsEvents = nullptr;
|
||||
CsFuncPtr csScriptsFrameCleanUp = nullptr;
|
||||
CsScriptManipFuncPtr csScriptsAdd = nullptr;
|
||||
|
|
|
@ -50,6 +50,17 @@ namespace SHADE
|
|||
reinterpret_cast<SHScriptEngine*>(system)->csScriptsExecuteLateUpdate();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* System Routine Functions - GizmosDrawRoutine */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
SHScriptEngine::GizmosDrawRoutine::GizmosDrawRoutine()
|
||||
: SHSystemRoutine("Script Engine Gizmos Draw", true)
|
||||
{}
|
||||
void SHScriptEngine::GizmosDrawRoutine::Execute(double dt) noexcept
|
||||
{
|
||||
reinterpret_cast<SHScriptEngine*>(system)->csScriptsExecuteDrawGizmos();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* System Routine Functions - FrameCleanUpRoutine */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Removes all Scripts of the specified type from this GameObject.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of PLushieScripts to remove.</typeparam>
|
||||
/// <typeparam name="T">Type of Scripts to remove.</typeparam>
|
||||
generic<typename T> where T : ref class, Script
|
||||
void RemoveScript();
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/************************************************************************************//*!
|
||||
\file Light.cxx
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Nov 8, 2022
|
||||
\brief Contains the definition of the functions of the managed Light class.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2022 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 "Light.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
Light::Light(Entity entity)
|
||||
: Component(entity)
|
||||
{}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Properties */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
Vector3 Light::Position::get()
|
||||
{
|
||||
return Convert::ToCLI(GetNativeComponent()->GetPosition());
|
||||
}
|
||||
void Light::Position::set(Vector3 value)
|
||||
{
|
||||
GetNativeComponent()->SetPosition(Convert::ToNative(value));
|
||||
}
|
||||
Light::Type Light::LightType::get()
|
||||
{
|
||||
return static_cast<Type>(GetNativeComponent()->GetType());
|
||||
}
|
||||
void Light::LightType::set(Light::Type value)
|
||||
{
|
||||
GetNativeComponent()->SetType(static_cast<SH_LIGHT_TYPE>(value));
|
||||
}
|
||||
Vector3 Light::Direction::get()
|
||||
{
|
||||
return Convert::ToCLI(GetNativeComponent()->GetDirection());
|
||||
}
|
||||
void Light::Direction::set(Vector3 value)
|
||||
{
|
||||
GetNativeComponent()->SetDirection(Convert::ToNative(value));
|
||||
}
|
||||
Color Light::Color::get()
|
||||
{
|
||||
return Convert::ToCLI(SHColour(GetNativeComponent()->GetColor()));
|
||||
}
|
||||
void Light::Color::set(SHADE::Color value)
|
||||
{
|
||||
GetNativeComponent()->SetColor(Convert::ToNative(value));
|
||||
}
|
||||
System::UInt32 Light::CullingMask::get()
|
||||
{
|
||||
return GetNativeComponent()->GetCullingMask();
|
||||
}
|
||||
void Light::CullingMask::set(System::UInt32 value)
|
||||
{
|
||||
GetNativeComponent()->SetCullingMask(value);
|
||||
}
|
||||
float Light::Strength::get()
|
||||
{
|
||||
return GetNativeComponent()->GetStrength();
|
||||
}
|
||||
void Light::Strength::set(float value)
|
||||
{
|
||||
GetNativeComponent()->SetStrength(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/************************************************************************************//*!
|
||||
\file Light.hxx
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Nov 8, 2022
|
||||
\brief Contains the definition of the managed Light class with the declaration
|
||||
of functions for working with it.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2022 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
|
||||
|
||||
// Project Includes
|
||||
#include "Components/Component.hxx"
|
||||
#include "Math/Vector3.hxx"
|
||||
// External Dependencies
|
||||
#include "Graphics/MiddleEnd/Lights/SHLightComponent.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/// <summary>
|
||||
/// CLR version of the SHADE Engine's SHLightComponent.
|
||||
/// </summary>
|
||||
public ref class Light : public Component<SHLightComponent>
|
||||
{
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Constructs a Light Component that represents a native Light component tied to
|
||||
/// the specified Entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||
Light(Entity entity);
|
||||
|
||||
public:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constants */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Supported types of the Light Component.
|
||||
/// </summary>
|
||||
enum class Type
|
||||
{
|
||||
/// <summary>
|
||||
/// Light applied uniformly across the scene at a specified direction.
|
||||
/// </summary>
|
||||
Directional,
|
||||
/// <summary>
|
||||
/// Light that originates from a certain point in all directions.
|
||||
/// Not implemented yet.
|
||||
/// </summary>
|
||||
Point,
|
||||
/// <summary>
|
||||
/// Light that originates from a certain point within a angle.
|
||||
/// Not implemented yet.
|
||||
/// </summary>
|
||||
Spot,
|
||||
/// <summary>
|
||||
/// Light applied to all objects. Has no source point.
|
||||
/// </summary>
|
||||
Ambient
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Properties */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Position of the light. Only works for Point Light (unimplemented).
|
||||
/// </summary>
|
||||
[System::ObsoleteAttribute("Not implemented yet.", true)]
|
||||
property Vector3 Position
|
||||
{
|
||||
Vector3 get();
|
||||
void set(Vector3 val);
|
||||
}
|
||||
/// <summary>
|
||||
/// Type of lighting that this Light component will apply onto the scene.
|
||||
/// </summary>
|
||||
property Type LightType
|
||||
{
|
||||
Type get();
|
||||
void set(Type val);
|
||||
}
|
||||
/// <summary>
|
||||
/// Direction of the light. Only applicable for Directional Lights.
|
||||
/// </summary>
|
||||
property Vector3 Direction
|
||||
{
|
||||
Vector3 get();
|
||||
void set(Vector3 val);
|
||||
}
|
||||
/// <summary>
|
||||
/// Colour of the Light.
|
||||
/// </summary>
|
||||
property SHADE::Color Color
|
||||
{
|
||||
SHADE::Color get();
|
||||
void set(SHADE::Color val);
|
||||
}
|
||||
/// <summary>
|
||||
/// Culling mask that is used to control what types of Materials would be
|
||||
/// affected by this Light.
|
||||
/// </summary>
|
||||
property System::UInt32 CullingMask
|
||||
{
|
||||
System::UInt32 get();
|
||||
void set(System::UInt32 val);
|
||||
}
|
||||
/// <summary>
|
||||
/// Intensity of the Light
|
||||
/// </summary>
|
||||
property float Strength
|
||||
{
|
||||
float get();
|
||||
void set(float val);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -414,19 +414,10 @@ namespace SHADE
|
|||
generic<typename Attribute>
|
||||
Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field)
|
||||
{
|
||||
array<System::Object^>^ attributes = field->GetCustomAttributes(true);
|
||||
for each (System::Object^ attrib in attributes)
|
||||
array<System::Object^>^ attributes = field->GetCustomAttributes(Attribute::typeid, false);
|
||||
if (attributes->Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Attribute attribute = safe_cast<Attribute>(attrib);
|
||||
if (attribute != nullptr)
|
||||
return attribute;
|
||||
}
|
||||
catch (System::InvalidCastException^)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return safe_cast<Attribute>(attributes[0]);
|
||||
}
|
||||
// Failed to find
|
||||
return Attribute{};
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace SHADE
|
|||
/// <param name="entity">The Entity to render the Scripts of.</param>
|
||||
static void RenderScriptsInInspector(Entity entity);
|
||||
/// <summary>
|
||||
/// Renders a dropdown button that allows for the addition of PlushieScripts
|
||||
/// onto the specified Entity.
|
||||
/// Renders a dropdown button that allows for the addition of Scripts onto the
|
||||
/// specified Entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">The Entity to add PlushieScripts to.</param>
|
||||
/// <param name="entity">The Entity to add Scripts to.</param>
|
||||
static void RenderScriptAddButton(Entity entity);
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -22,8 +22,8 @@ of DigiPen Institute of Technology is prohibited.
|
|||
// External Dependencies
|
||||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
#include "Physics\Components\SHColliderComponent.h"
|
||||
#include "Physics\Components\SHRigidBodyComponent.h"
|
||||
#include "Physics/Components/SHColliderComponent.h"
|
||||
#include "Physics/Components/SHRigidBodyComponent.h"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
#include "Scene/SHSceneGraph.h"
|
||||
#include "Tools/SHLog.h"
|
||||
|
@ -31,10 +31,11 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Utility/Convert.hxx"
|
||||
#include "Utility/Debug.hxx"
|
||||
#include "Components/Transform.hxx"
|
||||
#include "Components\RigidBody.hxx"
|
||||
#include "Components\Collider.hxx"
|
||||
#include "Components/RigidBody.hxx"
|
||||
#include "Components/Collider.hxx"
|
||||
#include "Components/Camera.hxx"
|
||||
#include "Components/CameraArm.hxx"
|
||||
#include "Components/Light.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -252,6 +253,7 @@ namespace SHADE
|
|||
componentMap.Add(createComponentSet<SHRigidBodyComponent, RigidBody>());
|
||||
componentMap.Add(createComponentSet<SHCameraComponent, Camera>());
|
||||
componentMap.Add(createComponentSet<SHCameraArmComponent, CameraArm>());
|
||||
componentMap.Add(createComponentSet<SHLightComponent, Light>());
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace SHADE
|
|||
{
|
||||
/// <summary>
|
||||
/// Static class that contains the functions for interfacing with the core
|
||||
/// PlushieEngine written in C++ for managing the lifecycle of managed code.
|
||||
/// SHADE Engine written in C++ for managing the lifecycle of managed code.
|
||||
/// </summary>
|
||||
private ref class EngineInterface abstract sealed
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Removes all Scripts of the specified type from this GameObject.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of PLushieScripts to remove.</typeparam>
|
||||
/// <typeparam name="T">Type of Scripts to remove.</typeparam>
|
||||
generic<typename T> where T : ref class, Script
|
||||
void RemoveScript();
|
||||
|
||||
|
|
|
@ -25,95 +25,85 @@ namespace SHADE
|
|||
{
|
||||
public:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Type Definitions */
|
||||
/* Properties */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// A static class that contains a set of default Colors.
|
||||
/// Pure black.
|
||||
/// </summary>
|
||||
ref class Defaults abstract sealed
|
||||
static property Color Black
|
||||
{
|
||||
public:
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/* Properties */
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Pure black.
|
||||
/// </summary>
|
||||
static property Color Black
|
||||
{
|
||||
Color get() { return Color(0.0f, 0.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Light Gray, lighter than gray.
|
||||
/// </summary>
|
||||
static property Color LightGray
|
||||
{
|
||||
Color get() { return Color(0.827451f, 0.827451f, 0.827451f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gray, halfway between black and white.
|
||||
/// </summary>
|
||||
static property Color Gray
|
||||
{
|
||||
Color get() { return Color(0.5f, 0.5f, 0.5f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Dark Gray, darker than gray.
|
||||
/// </summary>
|
||||
static property Color DarkGray
|
||||
{
|
||||
Color get() { return Color(0.622f, 0.622f, 0.622f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure white.
|
||||
/// </summary>
|
||||
static property Color White
|
||||
{
|
||||
Color get() { return Color(1.0f, 1.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure red.
|
||||
/// </summary>
|
||||
static property Color Red
|
||||
{
|
||||
Color get() { return Color(1.0f, 0.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure green.
|
||||
/// </summary>
|
||||
static property Color Green
|
||||
{
|
||||
Color get() { return Color(0.0f, 1.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure blue.
|
||||
/// </summary>
|
||||
static property Color Blue
|
||||
{
|
||||
Color get() { return Color(0.0f, 0.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure cyan, mix of pure green and blue.
|
||||
/// </summary>
|
||||
static property Color Cyan
|
||||
{
|
||||
Color get() { return Color(0.0f, 1.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure magenta, mix of pure red and blue.
|
||||
/// </summary>
|
||||
static property Color Magenta
|
||||
{
|
||||
Color get() { return Color(1.0f, 0.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure yellow, mix of pure red and green.
|
||||
/// </summary>
|
||||
static property Color Yellow
|
||||
{
|
||||
Color get() { return Color(1.0f, 1.0f, 0.0f); }
|
||||
}
|
||||
};
|
||||
Color get() { return Color(0.0f, 0.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Light Gray, lighter than gray.
|
||||
/// </summary>
|
||||
static property Color LightGray
|
||||
{
|
||||
Color get() { return Color(0.827451f, 0.827451f, 0.827451f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gray, halfway between black and white.
|
||||
/// </summary>
|
||||
static property Color Gray
|
||||
{
|
||||
Color get() { return Color(0.5f, 0.5f, 0.5f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Dark Gray, darker than gray.
|
||||
/// </summary>
|
||||
static property Color DarkGray
|
||||
{
|
||||
Color get() { return Color(0.622f, 0.622f, 0.622f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure white.
|
||||
/// </summary>
|
||||
static property Color White
|
||||
{
|
||||
Color get() { return Color(1.0f, 1.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure red.
|
||||
/// </summary>
|
||||
static property Color Red
|
||||
{
|
||||
Color get() { return Color(1.0f, 0.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure green.
|
||||
/// </summary>
|
||||
static property Color Green
|
||||
{
|
||||
Color get() { return Color(0.0f, 1.0f, 0.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure blue.
|
||||
/// </summary>
|
||||
static property Color Blue
|
||||
{
|
||||
Color get() { return Color(0.0f, 0.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure cyan, mix of pure green and blue.
|
||||
/// </summary>
|
||||
static property Color Cyan
|
||||
{
|
||||
Color get() { return Color(0.0f, 1.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure magenta, mix of pure red and blue.
|
||||
/// </summary>
|
||||
static property Color Magenta
|
||||
{
|
||||
Color get() { return Color(1.0f, 0.0f, 1.0f); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pure yellow, mix of pure red and green.
|
||||
/// </summary>
|
||||
static property Color Yellow
|
||||
{
|
||||
Color get() { return Color(1.0f, 1.0f, 0.0f); }
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors */
|
||||
|
|
|
@ -276,4 +276,4 @@ namespace SHADE
|
|||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
} // namespace PlushieAPI::Mathematics
|
||||
}
|
||||
|
|
|
@ -294,4 +294,4 @@ namespace SHADE
|
|||
{
|
||||
return Vector3(vec);
|
||||
}
|
||||
} // namespace PlushieAPI::Mathematics
|
||||
}
|
||||
|
|
|
@ -439,4 +439,5 @@ namespace SHADE
|
|||
/// <param name="vec">Vector2 to convert from.</param>
|
||||
static explicit operator Vector3(Vector2 vec);
|
||||
};
|
||||
} // namespace PlushieAPI::Mathematics
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Oct 28, 2021
|
||||
\brief Contains the definition of the functions for the PlushieScript managed
|
||||
class.
|
||||
\brief Contains the definition of the functions for the Script managed class.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
|
@ -140,6 +139,13 @@ namespace SHADE
|
|||
lateUpdate();
|
||||
SAFE_NATIVE_CALL_END(this)
|
||||
}
|
||||
void Script::OnDrawGizmos()
|
||||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
OnGizmosDrawOverriden = true;
|
||||
onDrawGizmos();
|
||||
SAFE_NATIVE_CALL_END(this)
|
||||
}
|
||||
void Script::OnDestroy()
|
||||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
|
@ -194,6 +200,7 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
Script::Script(GameObject gameObj)
|
||||
: owner { gameObj }
|
||||
, OnGizmosDrawOverriden { false }
|
||||
{}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
@ -210,6 +217,10 @@ namespace SHADE
|
|||
void Script::fixedUpdate() {}
|
||||
void Script::update() {}
|
||||
void Script::lateUpdate() {}
|
||||
void Script::onDrawGizmos()
|
||||
{
|
||||
OnGizmosDrawOverriden = false;
|
||||
}
|
||||
void Script::onDestroy() {}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -164,6 +164,14 @@ namespace SHADE
|
|||
static operator bool(Script^ s);
|
||||
|
||||
internal:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Properties */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// If true, the OnGizmosDraw function was overridden.
|
||||
/// </summary>
|
||||
bool OnGizmosDrawOverriden;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* "All-Time" Lifecycle Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
@ -208,6 +216,11 @@ namespace SHADE
|
|||
/// </summary>
|
||||
void LateUpdate();
|
||||
/// <summary>
|
||||
/// Used to call onDrawGizmos(). This should be called just before rendering
|
||||
/// the scene. This will only be called when working in the editor.
|
||||
/// </summary>
|
||||
void OnDrawGizmos();
|
||||
/// <summary>
|
||||
/// Used to call onDestroy(). This should be called at the end of the frame
|
||||
/// where the attached GameObject or this script is destroyed directly or
|
||||
/// indirectly due to destruction of the owner.
|
||||
|
@ -308,6 +321,10 @@ namespace SHADE
|
|||
/// </summary>
|
||||
virtual void lateUpdate();
|
||||
/// <summary>
|
||||
/// Called every frame just before rendering but only if working in the editor.
|
||||
/// </summary>
|
||||
virtual void onDrawGizmos();
|
||||
/// <summary>
|
||||
/// Called just before the end of the frame where the attached GameObject or
|
||||
/// this script is destroyed directly or indirectly due to destruction of the
|
||||
/// owner.
|
||||
|
|
|
@ -478,6 +478,24 @@ namespace SHADE
|
|||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
}
|
||||
|
||||
void ScriptStore::ExecuteOnDrawGizmos()
|
||||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
for each (System::Collections::Generic::KeyValuePair<Entity, ScriptList^> entity in scripts)
|
||||
{
|
||||
// Check active state
|
||||
if (!isEntityActive(entity.Key))
|
||||
continue;
|
||||
|
||||
// Update each script
|
||||
for each (Script^ script in entity.Value)
|
||||
{
|
||||
script->OnDrawGizmos();
|
||||
}
|
||||
}
|
||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.ScriptStore")
|
||||
}
|
||||
|
||||
void ScriptStore::ExecuteCollisionFunctions()
|
||||
{
|
||||
SAFE_NATIVE_CALL_BEGIN
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace SHADE
|
|||
/// </summary>
|
||||
/// <typeparam name="T">
|
||||
/// Type of script to add.
|
||||
/// This needs to be a default constructable PlushieScript.
|
||||
/// This needs to be a default constructable Script.
|
||||
/// </typeparam>
|
||||
/// <param name="entity">The entity to add a script to.</param>
|
||||
/// <returns>Reference to the script added.</returns>
|
||||
|
@ -234,6 +234,10 @@ namespace SHADE
|
|||
/// </summary>
|
||||
static void ExecuteLateUpdate();
|
||||
/// <summary>
|
||||
/// Executes OnDrawGizmos() for all scripts.
|
||||
/// </summary>
|
||||
static void ExecuteOnDrawGizmos();
|
||||
/// <summary>
|
||||
/// Executes OnCollision*() and OnTrigger*() for all scripts.
|
||||
/// </summary>
|
||||
static void ExecuteCollisionFunctions();
|
||||
|
|
|
@ -72,6 +72,16 @@ namespace SHADE
|
|||
return Ray(ToCLI(vec.position), ToCLI(vec.direction));
|
||||
}
|
||||
|
||||
SHColour Convert::ToNative(Color col)
|
||||
{
|
||||
return SHColour(col.r, col.g, col.b, col.a);
|
||||
}
|
||||
|
||||
Color Convert::ToCLI(const SHColour& vec)
|
||||
{
|
||||
return Color(vec.x, vec.y, vec.z, vec.w);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* String Conversions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -29,6 +29,8 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Math/Quaternion.hxx"
|
||||
#include "Math/Ray.hxx"
|
||||
#include "Engine/GenericHandle.hxx"
|
||||
#include "Math/SHColour.h"
|
||||
#include "Graphics/Color.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -104,6 +106,17 @@ namespace SHADE
|
|||
/// <param name="vec">The native Vector2 to convert from.</param>
|
||||
/// <returns>Managed copy of a native Vector2.</returns>
|
||||
static Ray ToCLI(const SHRay& vec);
|
||||
/// Converts from a managed Color to a native Colour.
|
||||
/// </summary>
|
||||
/// <param name="vec">The managed Color to convert from.</param>
|
||||
/// <returns>Native copy of a managed Color.</returns>
|
||||
static SHColour ToNative(Color col);
|
||||
/// <summary>
|
||||
/// Converts from a native Colour to a managed Color.
|
||||
/// </summary>
|
||||
/// <param name="vec">The native Colour to convert from.</param>
|
||||
/// <returns>Managed copy of a native Colour.</returns>
|
||||
static Color ToCLI(const SHColour& vec);
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* String Conversions */
|
||||
|
|
|
@ -33,4 +33,4 @@ namespace SHADE
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace PlushieAPI
|
||||
}
|
||||
|
|
|
@ -36,4 +36,4 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------*/
|
||||
System::Reflection::Assembly^ Load(System::Reflection::AssemblyName^ assemblyName) override;
|
||||
};
|
||||
} // namespace PlushieAPI
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/************************************************************************************//*!
|
||||
\file Gizmos.cxx
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Nov 8, 2022
|
||||
\brief Contains the definition of the functions for the Convert managed static
|
||||
class.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2022 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 "Gizmos.hxx"
|
||||
#include "Convert.hxx"
|
||||
#include "Tools/SHDebugDraw.h"
|
||||
// External Dependencies
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Public Properties */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
Color Gizmos::Color::get()
|
||||
{
|
||||
return defaultColor;
|
||||
}
|
||||
void Gizmos::Color::set(SHADE::Color color)
|
||||
{
|
||||
defaultColor = color;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Debug Draw Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
void Gizmos::DrawLine(Vector3 from, Vector3 to)
|
||||
{
|
||||
DrawLine(from, to, defaultColor);
|
||||
}
|
||||
|
||||
void Gizmos::DrawLine(Vector3 from, Vector3 to, SHADE::Color color)
|
||||
{
|
||||
SHDebugDraw::Line(Convert::ToNative(color), Convert::ToNative(from), Convert::ToNative(to));
|
||||
}
|
||||
|
||||
void Gizmos::DrawWireCube(Vector3 center, Vector3 extents)
|
||||
{
|
||||
DrawWireCube(center, extents, defaultColor);
|
||||
}
|
||||
|
||||
void Gizmos::DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color)
|
||||
{
|
||||
SHDebugDraw::Cube(Convert::ToNative(color), Convert::ToNative(center), Convert::ToNative(extents));
|
||||
}
|
||||
|
||||
void Gizmos::DrawWireSphere(Vector3 center, float radius)
|
||||
{
|
||||
DrawWireSphere(center, radius, defaultColor);
|
||||
}
|
||||
|
||||
void Gizmos::DrawWireSphere(Vector3 center, float radius, SHADE::Color color)
|
||||
{
|
||||
SHDebugDraw::Sphere(Convert::ToNative(color), Convert::ToNative(center), radius);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/************************************************************************************//*!
|
||||
\file Gizmos.hxx
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Nov 8, 2022
|
||||
\brief Contains the definition of the Gizmos static class and the
|
||||
declaration of its functions.
|
||||
|
||||
Note: This file is written in C++17/CLI.
|
||||
|
||||
Copyright (C) 2022 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
|
||||
|
||||
// Project Includes
|
||||
#include "Math/Vector3.hxx"
|
||||
#include "Graphics/Color.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functions for implementing debug drawing.
|
||||
/// </summary>
|
||||
public value class Gizmos abstract sealed
|
||||
{
|
||||
public:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Public Properties */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Default colour that will be used for drawing debug primitives if the color
|
||||
/// parameter is not specified.
|
||||
/// </summary>
|
||||
static property Color Color
|
||||
{
|
||||
SHADE::Color get();
|
||||
void set(SHADE::Color color);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Debug Draw Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/// <summary>
|
||||
/// Renders a line between two points in world space.
|
||||
/// Uses <see cref="Gizmos.Color">Color</see> to render.
|
||||
/// </summary>
|
||||
/// <param name="from">First point of the line.</param>
|
||||
/// <param name="to">Second point of the line.</param>
|
||||
static void DrawLine(Vector3 from, Vector3 to);
|
||||
/// <summary>
|
||||
/// Renders a line between two points in world space.
|
||||
/// </summary>
|
||||
/// <param name="from">First point of the line.</param>
|
||||
/// <param name="to">Second point of the line.</param>
|
||||
/// <param name="color">Colour of the line.</param>
|
||||
static void DrawLine(Vector3 from, Vector3 to, SHADE::Color color);
|
||||
/// <summary>
|
||||
/// Renders a wireframe cube centered around the position specified in world
|
||||
/// space.
|
||||
/// Uses <see cref="Gizmos.Color">Color</see> to render.
|
||||
/// </summary>
|
||||
/// <param name="center">Position where the cube wil be centered at.</param>
|
||||
/// <param name="extents">Size of the rendered cube.</param>
|
||||
static void DrawWireCube(Vector3 center, Vector3 extents);
|
||||
/// <summary>
|
||||
/// Renders a wireframe cube centered around the position specified in world
|
||||
/// space.
|
||||
/// </summary>
|
||||
/// <param name="center">Position where the cube wil be centered at.</param>
|
||||
/// <param name="extents">Size of the rendered cube.</param>
|
||||
/// <param name="color">Colour of the cube.</param>
|
||||
static void DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color);
|
||||
/// <summary>
|
||||
/// Renders a wireframe sphere centered around the position specified in world
|
||||
/// space.
|
||||
/// Uses <see cref="Gizmos.Color">Color</see> to render.
|
||||
/// </summary>
|
||||
/// <param name="center">Position where the sphere wil be centered at.</param>
|
||||
/// <param name="radius">Radius of the rendered sphere.</param>
|
||||
static void DrawWireSphere(Vector3 center, float radius);
|
||||
/// <summary>
|
||||
/// Renders a wireframe sphere centered around the position specified in world
|
||||
/// space.
|
||||
/// </summary>
|
||||
/// <param name="center">Position where the sphere wil be centered at.</param>
|
||||
/// <param name="radius">Radius of the rendered sphere.</param>
|
||||
/// <param name="color">Colour of the sphere.</param>
|
||||
static void DrawWireSphere(Vector3 center, float radius, SHADE::Color color);
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
static SHADE::Color defaultColor = SHADE::Color::White;
|
||||
};
|
||||
}
|
|
@ -36,4 +36,10 @@ public class RaccoonShowcase : Script
|
|||
//Transform.LocalRotation = new Vector3(0.0f, rotation, 0.0f);
|
||||
//Transform.LocalScale = new Vector3(System.Math.Abs(System.Math.Sin(scale.x)) * originalScale, System.Math.Abs(System.Math.Cos(scale.y)) * originalScale, System.Math.Abs(System.Math.Sin(scale.z)) * originalScale);
|
||||
}
|
||||
|
||||
protected override void onDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawLine(new Vector3(-1.0f, 0.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f));
|
||||
Gizmos.DrawLine(new Vector3(-1.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f), Color.Red);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ public class RaccoonSpin : Script
|
|||
private float RotateSpeed = 1.0f;
|
||||
private float rotation = 0.0f;
|
||||
[SerializeField]
|
||||
private CallbackEvent emptyEvent;
|
||||
[SerializeField]
|
||||
private CallbackEvent<int> testEvent;
|
||||
[SerializeField]
|
||||
private CallbackEvent<int, double, Vector3> testEvent3 = new CallbackEvent<int, double, Vector3>();
|
||||
|
@ -17,6 +19,8 @@ public class RaccoonSpin : Script
|
|||
|
||||
protected override void awake()
|
||||
{
|
||||
emptyEvent = new CallbackEvent();
|
||||
emptyEvent.RegisterAction(() => Debug.Log("Empty event action!"));
|
||||
testEvent = new CallbackEvent<int>();
|
||||
Action<int> action = (x) => Debug.Log($"{x}");
|
||||
testEvent.RegisterAction(action);
|
||||
|
|
Loading…
Reference in New Issue