Unity Package Structure (0.1.0)

This commit is contained in:
2022-12-16 23:24:02 +03:00
parent 8ee5c680f5
commit 7d409495b1
18 changed files with 66 additions and 10 deletions

33
Runtime/ActionBase.cs Normal file
View 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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d07cd6f6a7a635c41add4964a6aba382
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}
}

View 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
View 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
View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f1eb00830f616b40afd45bec1425a7f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eaf437843a281c74c86f7db482b44077
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7cd17689338eae84183e6b576fc9ae7c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: