From fefaf7ab39bbacf00c9d86df696a0675b8ea497a Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 14 Nov 2022 12:55:53 +0300 Subject: [PATCH] Moved Files from Movement Module --- IToggleState.cs | 10 ++++++++++ IToggleState.cs.meta | 11 +++++++++++ MemberToggleState.cs | 24 ++++++++++++++++++++++++ MemberToggleState.cs.meta | 11 +++++++++++ README.md.meta | 7 +++++++ ToggleState.cs | 25 +++++++++++++++++++++++++ ToggleState.cs.meta | 11 +++++++++++ 7 files changed, 99 insertions(+) create mode 100644 IToggleState.cs create mode 100644 IToggleState.cs.meta create mode 100644 MemberToggleState.cs create mode 100644 MemberToggleState.cs.meta create mode 100644 README.md.meta create mode 100644 ToggleState.cs create mode 100644 ToggleState.cs.meta diff --git a/IToggleState.cs b/IToggleState.cs new file mode 100644 index 0000000..1fa483a --- /dev/null +++ b/IToggleState.cs @@ -0,0 +1,10 @@ +using System; + +namespace Syntriax.Modules.Movement.State +{ + public interface IToggleState + { + bool Toggled { get; set; } + Action OnToggleStateChanged { get; set; } + } +} diff --git a/IToggleState.cs.meta b/IToggleState.cs.meta new file mode 100644 index 0000000..b7b04e6 --- /dev/null +++ b/IToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 174255e0fce0b3a4e8b5e34afa96ffd3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/MemberToggleState.cs b/MemberToggleState.cs new file mode 100644 index 0000000..e78be76 --- /dev/null +++ b/MemberToggleState.cs @@ -0,0 +1,24 @@ +using System; + +namespace Syntriax.Modules.Movement.State +{ + public class MemberToggleState : IToggleState + { + private bool _toggled = true; + public bool Toggled + { + get => _toggled; + set + { + bool oldValue = _toggled; + + _toggled = value; + + if (oldValue = !value) + OnToggleStateChanged?.Invoke(value); + } + } + + public Action OnToggleStateChanged { get; set; } = null; + } +} diff --git a/MemberToggleState.cs.meta b/MemberToggleState.cs.meta new file mode 100644 index 0000000..6b52b39 --- /dev/null +++ b/MemberToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7e03986725a3747459e11540e8915a56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..f04cefb --- /dev/null +++ b/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a21f9cba390715748b464c9228237ed1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ToggleState.cs b/ToggleState.cs new file mode 100644 index 0000000..9148508 --- /dev/null +++ b/ToggleState.cs @@ -0,0 +1,25 @@ +using System; +using UnityEngine; + +namespace Syntriax.Modules.Movement.State +{ + public class ToggleState : MonoBehaviour, IToggleState + { + private bool _toggled = true; + public bool Toggled + { + get => _toggled; + set + { + bool oldValue = _toggled; + + _toggled = value; + + if (oldValue = !value) + OnToggleStateChanged?.Invoke(value); + } + } + + public Action OnToggleStateChanged { get; set; } = null; + } +} diff --git a/ToggleState.cs.meta b/ToggleState.cs.meta new file mode 100644 index 0000000..c470298 --- /dev/null +++ b/ToggleState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ed1257e4c3c70343bdc02d2e01a95d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: