Renaming
This commit is contained in:
parent
588a5fbdd2
commit
2f16d0d334
|
@ -1,21 +1,30 @@
|
|||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public abstract class ActionBase : MonoBehaviour, IActionActivate
|
||||
public abstract class ActionBase : MonoBehaviour, IAction
|
||||
{
|
||||
public IToggleState ToggleState { get; protected set; } = null;
|
||||
public Action<IAction> OnActivated { get; set; } = null;
|
||||
|
||||
protected virtual void Awake() => ToggleState = new ToggleStateMember(true);
|
||||
protected virtual void Awake()
|
||||
{
|
||||
ToggleState = new ToggleStateMember(true);
|
||||
OnActivated += (_) => OnActionActivated();
|
||||
}
|
||||
|
||||
protected abstract void OnActivated();
|
||||
/// <summary>
|
||||
/// Called when the current <see cref="ActionBase"/> gets activated
|
||||
/// </summary>
|
||||
protected abstract void OnActionActivated();
|
||||
public virtual void Activate()
|
||||
{
|
||||
if (!ToggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
||||
OnActivated();
|
||||
OnActivated?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public abstract class ActionBaseWithDeactivation : ActionBase, IActionDeactivate
|
||||
public abstract class ActionBaseWithDeactivation : ActionBase, IActionWithDeactivation
|
||||
{
|
||||
protected abstract void OnDeactivated();
|
||||
public Action<IAction> OnDeactivated { get; set; } = null;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
OnDeactivated += (_) => OnActionDeactivated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the current <see cref="ActionBase"/> gets deactivated
|
||||
/// </summary>
|
||||
protected abstract void OnActionDeactivated();
|
||||
public virtual void Deactivate()
|
||||
{
|
||||
if (!ToggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
||||
OnDeactivated();
|
||||
OnDeactivated?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Syntriax.Modules.Action
|
|||
rigid.velocity = velocity;
|
||||
}
|
||||
|
||||
protected override void OnDeactivated()
|
||||
protected override void OnActionDeactivated()
|
||||
{
|
||||
if (!gameObjectToggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
@ -67,7 +67,7 @@ namespace Syntriax.Modules.Action
|
|||
airSuspension = false;
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
protected override void OnActionActivated()
|
||||
{
|
||||
if (!gameObjectToggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public interface IAction
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IToggleState"/> the Action uses to check if it's active or not
|
||||
/// </summary>
|
||||
IToggleState ToggleState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="IAction"/> is Activated
|
||||
/// </summary>
|
||||
/// <value>The <see cref="IAction"/> that Activated</value>
|
||||
Action<IAction> OnActivated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the <see cref="IAction"/>
|
||||
/// </summary>
|
||||
void Activate();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ff9f1a7b70a47e4aa97dfda371fbf21
|
||||
guid: 4f1eb00830f616b40afd45bec1425a7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -1,17 +0,0 @@
|
|||
using Syntriax.Modules.ToggleState;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public interface IActionActivate
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IToggleState"> the Action uses to check if it's active or not
|
||||
/// </summary>
|
||||
IToggleState ToggleState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the Action
|
||||
/// </summary>
|
||||
void Activate();
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public interface IActionDeactivate : IActionActivate
|
||||
{
|
||||
/// <summary>
|
||||
/// Deactivates the action
|
||||
/// </summary>
|
||||
void Deactivate();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public interface IActionWithDeactivation : IAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when the <see cref="IAction"/> is Deactivated
|
||||
/// </summary>
|
||||
/// <value>The <see cref="IAction"/> that Deactivated</value>
|
||||
Action<IAction> OnDeactivated { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="IAction"/> is Deactivated
|
||||
/// </summary>
|
||||
void Deactivate();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10a30eb2debabdf40b2f8120a5f1ad01
|
||||
guid: eaf437843a281c74c86f7db482b44077
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
Loading…
Reference in New Issue