Compare commits
	
		
			10 Commits
		
	
	
		
			463182ab43
			...
			developmen
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 02c23dad69 | |||
| f7f4dcf08c | |||
| af1e30058b | |||
| 01da5f8864 | |||
| da8a7bf668 | |||
| 1dc9689e5d | |||
| 8d5f9bd3c8 | |||
| ccb9666668 | |||
| 2237b2e355 | |||
| 6afed7407d | 
@@ -1,15 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Modules.ToggleState
 | 
			
		||||
{
 | 
			
		||||
    public interface IToggleState
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Called everytime the IsToggled field is changed
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <value>The new value of IsToggled</value>
 | 
			
		||||
        Action<bool> OnToggleStateChanged { get; set; }
 | 
			
		||||
 | 
			
		||||
        bool IsToggled { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
namespace Syntriax.Modules.ToggleState
 | 
			
		||||
{
 | 
			
		||||
    public static class IToggleStateExtensions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Checks if the provided parameter IToggleState is toggled, if the parameter is null returns the nullValue parameter
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="toggleState">IToggleState to be checked if toggled or not</param>
 | 
			
		||||
        /// <param name="nullValue">The value that will be returned if toggleState is null. Default value: true</param>
 | 
			
		||||
        /// <returns>IToggleState's toggle value, or if null return nullValue parameter</returns>
 | 
			
		||||
        public static bool IsToggledNullChecked(this IToggleState toggleState, bool nullValue = true)
 | 
			
		||||
            => toggleState == null ? nullValue : toggleState.IsToggled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								Runtime.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Runtime.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 3ca1a8a8e7759614dbe3aa94ca19f4a8
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
							
								
								
									
										8
									
								
								Runtime/Enable.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Runtime/Enable.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 488baa4b12357c44d83fcdba794ce57c
 | 
			
		||||
folderAsset: yes
 | 
			
		||||
DefaultImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
							
								
								
									
										15
									
								
								Runtime/Enable/IStateEnable.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Runtime/Enable/IStateEnable.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Modules.State
 | 
			
		||||
{
 | 
			
		||||
    public interface IStateEnable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Called everytime the <see cref="IsEnabled"/>> field is changed
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <value>The new value of <see cref="IsEnabled"/>></value>
 | 
			
		||||
        Action<bool> OnEnabledChanged { get; set; }
 | 
			
		||||
 | 
			
		||||
        bool IsEnabled { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 5be36869d5a2d95418a7db5213b80ccf
 | 
			
		||||
guid: 9017443f63486e0438e09eeb335eb8bc
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										14
									
								
								Runtime/Enable/IStateEnableExtensions.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Runtime/Enable/IStateEnableExtensions.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
namespace Syntriax.Modules.State
 | 
			
		||||
{
 | 
			
		||||
    public static class IStateEnableExtensions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Checks if the provided parameter <see cref="IStateEnable"/> is enabled, if the parameter is null returns the nullValue parameter
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="StateEnable"><see cref="IStateEnable"/> to be checked if enabled or not</param>
 | 
			
		||||
        /// <param name="nullValue">The value that will be returned if <see cref="IEnabledState"/> is null. Default value: true</param>
 | 
			
		||||
        /// <returns><see cref="IStateEnable"/>'s toggle value, or if null return nullValue parameter</returns>
 | 
			
		||||
        public static bool IsEnabledNullChecked(this IStateEnable stateEnable, bool nullValue = true)
 | 
			
		||||
            => stateEnable == null ? nullValue : stateEnable.IsEnabled;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 174255e0fce0b3a4e8b5e34afa96ffd3
 | 
			
		||||
guid: ff97669ed76e39540b7aa38be50a5e1a
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										27
									
								
								Runtime/Enable/StateEnableMember.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Runtime/Enable/StateEnableMember.cs
									
									
									
									
									
										Normal file
									
								
							@@ -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<bool> OnEnabledChanged { get; set; } = null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: d603bc1aca0fb74498aaa2270e82135b
 | 
			
		||||
guid: 39e2c42e15ad5304db28ad23b5cb666f
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										36
									
								
								Runtime/Enable/StateEnableMonoBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Runtime/Enable/StateEnableMonoBehaviour.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
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<bool> OnEnabledChanged { get; set; } = null;
 | 
			
		||||
 | 
			
		||||
        protected void Awake()
 | 
			
		||||
            => OnEnabledChanged += (state) => enabled = state;
 | 
			
		||||
 | 
			
		||||
        protected void OnEnable() => IsEnabled = true;
 | 
			
		||||
        protected void OnDisable()
 | 
			
		||||
        {
 | 
			
		||||
            IsEnabled = false;
 | 
			
		||||
 | 
			
		||||
            if (!gameObject.activeInHierarchy) // Just so we can get OnEnable called when the object is back active again in the hierarchy  
 | 
			
		||||
                this.enabled = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: d321123fb56053e49b20da45bfda3a65
 | 
			
		||||
guid: d72fab208f04d2f4983894530293b606
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
							
								
								
									
										3
									
								
								Runtime/Syntriax.Modules.State.asmdef
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Runtime/Syntriax.Modules.State.asmdef
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "Syntriax.Modules.State"
 | 
			
		||||
}
 | 
			
		||||
@@ -1,3 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "Syntriax.Modules.ToggleState"
 | 
			
		||||
}
 | 
			
		||||
@@ -1,24 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Syntriax.Modules.ToggleState
 | 
			
		||||
{
 | 
			
		||||
    public class ToggleStateMember : IToggleState
 | 
			
		||||
    {
 | 
			
		||||
        private bool _isToggled = true;
 | 
			
		||||
        public bool IsToggled
 | 
			
		||||
        {
 | 
			
		||||
            get => _isToggled;
 | 
			
		||||
            set
 | 
			
		||||
            {
 | 
			
		||||
                bool oldValue = _isToggled;
 | 
			
		||||
 | 
			
		||||
                _isToggled = value;
 | 
			
		||||
 | 
			
		||||
                if (oldValue = !value)
 | 
			
		||||
                    OnToggleStateChanged?.Invoke(value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Action<bool> OnToggleStateChanged { get; set; } = null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,25 +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
 | 
			
		||||
            {
 | 
			
		||||
                bool oldValue = _isToggled;
 | 
			
		||||
 | 
			
		||||
                _isToggled = value;
 | 
			
		||||
 | 
			
		||||
                if (oldValue = !value)
 | 
			
		||||
                    OnToggleStateChanged?.Invoke(value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public Action<bool> OnToggleStateChanged { get; set; } = null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "com.syntriax.state",
 | 
			
		||||
  "version": "0.2.1",
 | 
			
		||||
  "displayName": "State Module",
 | 
			
		||||
  "unity": "2019.1",
 | 
			
		||||
  "documentationUrl": "https://git.syntriax.com/Syntriax/State.git",
 | 
			
		||||
  "dependencies": {},
 | 
			
		||||
  "keywords": ["State"],
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Syntriax",
 | 
			
		||||
    "email": "Syntriax@gmail.com",
 | 
			
		||||
    "url": "https://syntriax.com"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								package.json.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								package.json.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: ebb44a9f2a85fea45818ad738979fa9e
 | 
			
		||||
TextScriptImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
		Reference in New Issue
	
	Block a user