From f7f4dcf08c0a6590bb3b8b1d9a7cca1ac162f4d1 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 20 Mar 2023 22:15:21 +0300 Subject: [PATCH] BREAKING CHANGES: Repo Overhaul - Renamed the repo to use State rather than ToggleState - IToggleState renamed to IStateEnable --- README.md | 2 +- Runtime/Enable.meta | 8 +++++ Runtime/Enable/IStateEnable.cs | 15 ++++++++++ .../IStateEnable.cs.meta} | 2 +- Runtime/Enable/IStateEnableExtensions.cs | 14 +++++++++ .../IStateEnableExtensions.cs.meta} | 2 +- Runtime/Enable/StateEnableMember.cs | 27 +++++++++++++++++ .../StateEnableMember.cs.meta} | 2 +- Runtime/Enable/StateEnableMonoBehaviour.cs | 30 +++++++++++++++++++ .../StateEnableMonoBehaviour.cs.meta} | 2 +- Runtime/IToggleState.cs | 15 ---------- Runtime/IToggleStateExtensions.cs | 14 --------- Runtime/Syntriax.Modules.State.asmdef | 3 ++ ...eta => Syntriax.Modules.State.asmdef.meta} | 0 Runtime/Syntriax.Modules.ToggleState.asmdef | 3 -- Runtime/ToggleStateMember.cs | 27 ----------------- Runtime/ToggleStateMonoBehaviour.cs | 30 ------------------- package.json | 10 +++---- 18 files changed, 107 insertions(+), 99 deletions(-) create mode 100644 Runtime/Enable.meta create mode 100644 Runtime/Enable/IStateEnable.cs rename Runtime/{ToggleStateMember.cs.meta => Enable/IStateEnable.cs.meta} (83%) create mode 100644 Runtime/Enable/IStateEnableExtensions.cs rename Runtime/{IToggleState.cs.meta => Enable/IStateEnableExtensions.cs.meta} (83%) create mode 100644 Runtime/Enable/StateEnableMember.cs rename Runtime/{ToggleStateMonoBehaviour.cs.meta => Enable/StateEnableMember.cs.meta} (83%) create mode 100644 Runtime/Enable/StateEnableMonoBehaviour.cs rename Runtime/{IToggleStateExtensions.cs.meta => Enable/StateEnableMonoBehaviour.cs.meta} (83%) delete mode 100644 Runtime/IToggleState.cs delete mode 100644 Runtime/IToggleStateExtensions.cs create mode 100644 Runtime/Syntriax.Modules.State.asmdef rename Runtime/{Syntriax.Modules.ToggleState.asmdef.meta => Syntriax.Modules.State.asmdef.meta} (100%) delete mode 100644 Runtime/Syntriax.Modules.ToggleState.asmdef delete mode 100644 Runtime/ToggleStateMember.cs delete mode 100644 Runtime/ToggleStateMonoBehaviour.cs diff --git a/README.md b/README.md index 2e5af54..6fe53d7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# ToggleState +# State diff --git a/Runtime/Enable.meta b/Runtime/Enable.meta new file mode 100644 index 0000000..00f1511 --- /dev/null +++ b/Runtime/Enable.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 488baa4b12357c44d83fcdba794ce57c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Enable/IStateEnable.cs b/Runtime/Enable/IStateEnable.cs new file mode 100644 index 0000000..30794f6 --- /dev/null +++ b/Runtime/Enable/IStateEnable.cs @@ -0,0 +1,15 @@ +using System; + +namespace Syntriax.Modules.State +{ + public interface IStateEnable + { + /// + /// Called everytime the > field is changed + /// + /// The new value of > + Action OnEnabledChanged { get; set; } + + bool IsEnabled { get; set; } + } +} diff --git a/Runtime/ToggleStateMember.cs.meta b/Runtime/Enable/IStateEnable.cs.meta similarity index 83% rename from Runtime/ToggleStateMember.cs.meta rename to Runtime/Enable/IStateEnable.cs.meta index 34e7433..27340a1 100644 --- a/Runtime/ToggleStateMember.cs.meta +++ b/Runtime/Enable/IStateEnable.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5be36869d5a2d95418a7db5213b80ccf +guid: 9017443f63486e0438e09eeb335eb8bc MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Enable/IStateEnableExtensions.cs b/Runtime/Enable/IStateEnableExtensions.cs new file mode 100644 index 0000000..17e1025 --- /dev/null +++ b/Runtime/Enable/IStateEnableExtensions.cs @@ -0,0 +1,14 @@ +namespace Syntriax.Modules.State +{ + public static class IStateEnableExtensions + { + /// + /// Checks if the provided parameter is enabled, if the parameter is null returns the nullValue parameter + /// + /// to be checked if enabled or not + /// The value that will be returned if is null. Default value: true + /// 's toggle value, or if null return nullValue parameter + public static bool IsEnabledNullChecked(this IStateEnable stateEnable, bool nullValue = true) + => stateEnable == null ? nullValue : stateEnable.IsEnabled; + } +} diff --git a/Runtime/IToggleState.cs.meta b/Runtime/Enable/IStateEnableExtensions.cs.meta similarity index 83% rename from Runtime/IToggleState.cs.meta rename to Runtime/Enable/IStateEnableExtensions.cs.meta index b7b04e6..2d0a734 100644 --- a/Runtime/IToggleState.cs.meta +++ b/Runtime/Enable/IStateEnableExtensions.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 174255e0fce0b3a4e8b5e34afa96ffd3 +guid: ff97669ed76e39540b7aa38be50a5e1a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Enable/StateEnableMember.cs b/Runtime/Enable/StateEnableMember.cs new file mode 100644 index 0000000..d392e56 --- /dev/null +++ b/Runtime/Enable/StateEnableMember.cs @@ -0,0 +1,27 @@ +using System; + +namespace Syntriax.Modules.State +{ + public class StateEnableMember : IStateEnable + { + private bool _isEnabled = true; + + public StateEnableMember() { } + public StateEnableMember(bool isEnabled) => IsEnabled = isEnabled; + + public bool IsEnabled + { + get => _isEnabled; + set + { + if (value == _isEnabled) + return; + + _isEnabled = value; + OnEnabledChanged?.Invoke(value); + } + } + + public Action OnEnabledChanged { get; set; } = null; + } +} diff --git a/Runtime/ToggleStateMonoBehaviour.cs.meta b/Runtime/Enable/StateEnableMember.cs.meta similarity index 83% rename from Runtime/ToggleStateMonoBehaviour.cs.meta rename to Runtime/Enable/StateEnableMember.cs.meta index 5c13dc5..6407c8d 100644 --- a/Runtime/ToggleStateMonoBehaviour.cs.meta +++ b/Runtime/Enable/StateEnableMember.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d603bc1aca0fb74498aaa2270e82135b +guid: 39e2c42e15ad5304db28ad23b5cb666f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Enable/StateEnableMonoBehaviour.cs b/Runtime/Enable/StateEnableMonoBehaviour.cs new file mode 100644 index 0000000..08d64b2 --- /dev/null +++ b/Runtime/Enable/StateEnableMonoBehaviour.cs @@ -0,0 +1,30 @@ +using System; +using UnityEngine; + +namespace Syntriax.Modules.State +{ + public class StateEnableMonoBehaviour : MonoBehaviour, IStateEnable + { + private bool _isEnabled = true; + public bool IsEnabled + { + get => _isEnabled; + set + { + if (value == _isEnabled) + return; + + _isEnabled = value; + OnEnabledChanged?.Invoke(value); + } + } + + public Action OnEnabledChanged { get; set; } = null; + + protected void Awake() + => OnEnabledChanged += (state) => enabled = state; + + protected void OnEnable() => IsEnabled = true; + protected void OnDisable() => IsEnabled = false; + } +} diff --git a/Runtime/IToggleStateExtensions.cs.meta b/Runtime/Enable/StateEnableMonoBehaviour.cs.meta similarity index 83% rename from Runtime/IToggleStateExtensions.cs.meta rename to Runtime/Enable/StateEnableMonoBehaviour.cs.meta index 7bec1ab..16b4742 100644 --- a/Runtime/IToggleStateExtensions.cs.meta +++ b/Runtime/Enable/StateEnableMonoBehaviour.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d321123fb56053e49b20da45bfda3a65 +guid: d72fab208f04d2f4983894530293b606 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/IToggleState.cs b/Runtime/IToggleState.cs deleted file mode 100644 index ad35534..0000000 --- a/Runtime/IToggleState.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Syntriax.Modules.ToggleState -{ - public interface IToggleState - { - /// - /// Called everytime the IsToggled field is changed - /// - /// The new value of IsToggled - Action OnToggleStateChanged { get; set; } - - bool IsToggled { get; set; } - } -} diff --git a/Runtime/IToggleStateExtensions.cs b/Runtime/IToggleStateExtensions.cs deleted file mode 100644 index 9d68fdb..0000000 --- a/Runtime/IToggleStateExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Syntriax.Modules.ToggleState -{ - public static class IToggleStateExtensions - { - /// - /// Checks if the provided parameter IToggleState is toggled, if the parameter is null returns the nullValue parameter - /// - /// IToggleState to be checked if toggled or not - /// The value that will be returned if toggleState is null. Default value: true - /// IToggleState's toggle value, or if null return nullValue parameter - public static bool IsToggledNullChecked(this IToggleState toggleState, bool nullValue = true) - => toggleState == null ? nullValue : toggleState.IsToggled; - } -} diff --git a/Runtime/Syntriax.Modules.State.asmdef b/Runtime/Syntriax.Modules.State.asmdef new file mode 100644 index 0000000..d28fbc0 --- /dev/null +++ b/Runtime/Syntriax.Modules.State.asmdef @@ -0,0 +1,3 @@ +{ + "name": "Syntriax.Modules.State" +} diff --git a/Runtime/Syntriax.Modules.ToggleState.asmdef.meta b/Runtime/Syntriax.Modules.State.asmdef.meta similarity index 100% rename from Runtime/Syntriax.Modules.ToggleState.asmdef.meta rename to Runtime/Syntriax.Modules.State.asmdef.meta diff --git a/Runtime/Syntriax.Modules.ToggleState.asmdef b/Runtime/Syntriax.Modules.ToggleState.asmdef deleted file mode 100644 index d87a1e9..0000000 --- a/Runtime/Syntriax.Modules.ToggleState.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Syntriax.Modules.ToggleState" -} diff --git a/Runtime/ToggleStateMember.cs b/Runtime/ToggleStateMember.cs deleted file mode 100644 index c6424f2..0000000 --- a/Runtime/ToggleStateMember.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; - -namespace Syntriax.Modules.ToggleState -{ - public class ToggleStateMember : IToggleState - { - private bool _isToggled = true; - - public ToggleStateMember() { } - public ToggleStateMember(bool isToggled) => IsToggled = isToggled; - - public bool IsToggled - { - get => _isToggled; - set - { - if (value == _isToggled) - return; - - _isToggled = value; - OnToggleStateChanged?.Invoke(value); - } - } - - public Action OnToggleStateChanged { get; set; } = null; - } -} diff --git a/Runtime/ToggleStateMonoBehaviour.cs b/Runtime/ToggleStateMonoBehaviour.cs deleted file mode 100644 index 625f0a0..0000000 --- a/Runtime/ToggleStateMonoBehaviour.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using UnityEngine; - -namespace Syntriax.Modules.ToggleState -{ - public class ToggleStateMonoBehaviour : MonoBehaviour, IToggleState - { - private bool _isToggled = true; - public bool IsToggled - { - get => _isToggled; - set - { - if (value == _isToggled) - return; - - _isToggled = value; - OnToggleStateChanged?.Invoke(value); - } - } - - public Action OnToggleStateChanged { get; set; } = null; - - protected void Awake() - => OnToggleStateChanged += (state) => enabled = state; - - protected void OnEnable() => IsToggled = true; - protected void OnDisable() => IsToggled = false; - } -} diff --git a/package.json b/package.json index baf0428..4117416 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "com.syntriax.toggle-state", - "version": "0.1.0", - "displayName": "Toggle State Module", + "name": "com.syntriax.state", + "version": "0.2.0", + "displayName": "State Module", "unity": "2019.1", - "documentationUrl": "https://git.syntriax.com/Syntriax/ToggleState.git", + "documentationUrl": "https://git.syntriax.com/Syntriax/State.git", "dependencies": {}, - "keywords": ["Toggle State", "Switch"], + "keywords": ["State"], "author": { "name": "Syntriax", "email": "Syntriax@gmail.com",