Unity Package Structure (0.1.0)

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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 341c2035d0254344cad44ff6138adf58 guid: c9bc11e81e88c784c95a3478b5e2ed52
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -6,12 +6,15 @@ namespace Syntriax.Modules.Action
{ {
public abstract class ActionBase : MonoBehaviour, IAction public abstract class ActionBase : MonoBehaviour, IAction
{ {
public IToggleState ToggleState { get; protected set; } = null; public IToggleState MemberToggleState { get; protected set; } = null;
public Action<IAction> OnActivated { get; set; } = null; public Action<IAction> OnActivated { get; set; } = null;
protected IToggleState toggleState = null;
protected virtual void Awake() protected virtual void Awake()
{ {
ToggleState = new ToggleStateMember(true); toggleState = GetComponent<IToggleState>();
MemberToggleState = new ToggleStateMember(true);
OnActivated += (_) => OnActionActivated(); OnActivated += (_) => OnActionActivated();
} }
@ -21,7 +24,7 @@ namespace Syntriax.Modules.Action
protected abstract void OnActionActivated(); protected abstract void OnActionActivated();
public virtual void Activate() public virtual void Activate()
{ {
if (!ToggleState.IsToggledNullChecked()) if (!MemberToggleState.IsToggledNullChecked() || !toggleState.IsToggledNullChecked())
return; return;
OnActivated?.Invoke(this); OnActivated?.Invoke(this);

View File

@ -19,7 +19,7 @@ namespace Syntriax.Modules.Action
protected abstract void OnActionDeactivated(); protected abstract void OnActionDeactivated();
public virtual void Deactivate() public virtual void Deactivate()
{ {
if (!ToggleState.IsToggledNullChecked()) if (!MemberToggleState.IsToggledNullChecked() || !toggleState.IsToggledNullChecked())
return; return;
OnDeactivated?.Invoke(this); OnDeactivated?.Invoke(this);

View File

@ -6,9 +6,9 @@ namespace Syntriax.Modules.Action
public interface IAction public interface IAction
{ {
/// <summary> /// <summary>
/// The <see cref="IToggleState"/> the Action uses to check if it's active or not /// The member <see cref="IToggleState"/> the Action uses to check if it's active or not
/// </summary> /// </summary>
IToggleState ToggleState { get; } IToggleState MemberToggleState { get; }
/// <summary> /// <summary>
/// Called when the <see cref="IAction"/> is Activated /// Called when the <see cref="IAction"/> is Activated

8
Samples.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fae7e0c9773c5434e81df0b2792ec57e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,7 @@
using Syntriax.Modules.ToggleState; using Syntriax.Modules.ToggleState;
using UnityEngine; using UnityEngine;
namespace Syntriax.Modules.Action namespace Syntriax.Modules.Action.Samples
{ {
[RequireComponent(typeof(Rigidbody2D))] [RequireComponent(typeof(Rigidbody2D))]
public class PlatformerJump : ActionBaseWithDeactivation public class PlatformerJump : ActionBaseWithDeactivation
@ -40,7 +40,7 @@ namespace Syntriax.Modules.Action
protected virtual void FixedUpdate() protected virtual void FixedUpdate()
{ {
if (!ToggleState.IsToggledNullChecked() || !gameObjectToggleState.IsToggledNullChecked()) if (!MemberToggleState.IsToggledNullChecked() || !gameObjectToggleState.IsToggledNullChecked())
return; return;
if (rigid.velocity.y < FallThreshold) if (rigid.velocity.y < FallThreshold)

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e45c80df261a5714e9a22fd73a2cd39a guid: c55e74ac98f03704bb026843c9b84a1e
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -0,0 +1,17 @@
{
"name": "Syntriax.Modules.Action.Samples",
"rootNamespace": "",
"references": [
"GUID:efa9a9bc94c60c74684aafb7428fbf61",
"GUID:7cd17689338eae84183e6b576fc9ae7c"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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

14
package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "com.syntriax.action",
"version": "0.1.0",
"displayName": "Action Module",
"unity": "2019.1",
"documentationUrl": "https://git.syntriax.com/Syntriax/Action.git",
"dependencies": {},
"keywords": ["Action"],
"author": {
"name": "Syntriax",
"email": "Syntriax@gmail.com",
"url": "https://syntriax.com"
}
}

7
package.json.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 93b283f7bc30906478f36ce9e596fa9f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: