Unity Package Structure (0.1.0)
This commit is contained in:
33
Runtime/ActionBase.cs
Normal file
33
Runtime/ActionBase.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public abstract class ActionBase : MonoBehaviour, IAction
|
||||
{
|
||||
public IToggleState MemberToggleState { get; protected set; } = null;
|
||||
public Action<IAction> OnActivated { get; set; } = null;
|
||||
|
||||
protected IToggleState toggleState = null;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
toggleState = GetComponent<IToggleState>();
|
||||
MemberToggleState = new ToggleStateMember(true);
|
||||
OnActivated += (_) => OnActionActivated();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the current <see cref="ActionBase"/> gets activated
|
||||
/// </summary>
|
||||
protected abstract void OnActionActivated();
|
||||
public virtual void Activate()
|
||||
{
|
||||
if (!MemberToggleState.IsToggledNullChecked() || !toggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
||||
OnActivated?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
11
Runtime/ActionBase.cs.meta
Normal file
11
Runtime/ActionBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d07cd6f6a7a635c41add4964a6aba382
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
28
Runtime/ActionBaseWithDeactivation.cs
Normal file
28
Runtime/ActionBaseWithDeactivation.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public abstract class ActionBaseWithDeactivation : ActionBase, IActionWithDeactivation
|
||||
{
|
||||
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 (!MemberToggleState.IsToggledNullChecked() || !toggleState.IsToggledNullChecked())
|
||||
return;
|
||||
|
||||
OnDeactivated?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
11
Runtime/ActionBaseWithDeactivation.cs.meta
Normal file
11
Runtime/ActionBaseWithDeactivation.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bce8bd8b35a51f4785a3933e3526ddf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Runtime/IAction.cs
Normal file
24
Runtime/IAction.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Syntriax.Modules.ToggleState;
|
||||
|
||||
namespace Syntriax.Modules.Action
|
||||
{
|
||||
public interface IAction
|
||||
{
|
||||
/// <summary>
|
||||
/// The member <see cref="IToggleState"/> the Action uses to check if it's active or not
|
||||
/// </summary>
|
||||
IToggleState MemberToggleState { 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();
|
||||
}
|
||||
}
|
11
Runtime/IAction.cs.meta
Normal file
11
Runtime/IAction.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f1eb00830f616b40afd45bec1425a7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Runtime/IActionWithDeactivation.cs
Normal file
18
Runtime/IActionWithDeactivation.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
11
Runtime/IActionWithDeactivation.cs.meta
Normal file
11
Runtime/IActionWithDeactivation.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaf437843a281c74c86f7db482b44077
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Runtime/Syntriax.Modules.Action.asmdef
Normal file
16
Runtime/Syntriax.Modules.Action.asmdef
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Syntriax.Modules.Action",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:efa9a9bc94c60c74684aafb7428fbf61"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Runtime/Syntriax.Modules.Action.asmdef.meta
Normal file
7
Runtime/Syntriax.Modules.Action.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd17689338eae84183e6b576fc9ae7c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user