Skip to content

Commit

Permalink
Update README.md and LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
OpOpYaDev authored and OpOpYaDev committed May 12, 2024
0 parents commit 6bc4c19
Show file tree
Hide file tree
Showing 57 changed files with 989 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Editor/BetterConditions.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "BetterConditions.Editor",
"rootNamespace": "Better.Conditions.EditorAddons",
"references": [
"GUID:01df13aca8d01e24a911bcc3e8277031",
"GUID:6adbd2a12d24f5d429f7ea1b1086e835",
"GUID:fe96bdec06a75af4184a0252929f642e"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/BetterConditions.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Arcueid D'athemon (https://github.com/uurha)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Better Conditions

[![openupm](https://img.shields.io/npm/v/com.tdw.better.conditions?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tdw.better.conditions/)

## Install
[How to install](https://github.com/uurha/BetterPluginCollection/wiki/How-to-install)
8 changes: 8 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Runtime/BetterConditions.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "BetterConditions.Runtime",
"rootNamespace": "Better.Conditions.Runtime",
"references": [
"GUID:01df13aca8d01e24a911bcc3e8277031",
"GUID:8bd4b41f8da90144d9006c4d926c9679",
"GUID:35101f455c979e94c9a0a4793484b7fd"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Runtime/BetterConditions.Runtime.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Extensions.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions Runtime/Extensions/ConditionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Better.Commons.Runtime.Conditions;
using Better.Commons.Runtime.Utility;

namespace Better.Commons.Runtime.Extensions
{
public static class ConditionExtensions
{
public static void Rebuild(this IEnumerable<Condition> self)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return;
}

foreach (var condition in self)
{
condition.Rebuild();
}
}

public static bool Validate(this IEnumerable<Condition> self, bool logException = Condition.DefaultLogException)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return false;
}

foreach (var condition in self)
{
if (!condition.Validate(logException))
{
return false;
}
}

return true;
}

public static bool InvokeAll(this IEnumerable<Condition> self)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return false;
}

foreach (var condition in self)
{
if (!condition.Invoke())
{
return false;
}
}

return true;
}

public static bool SafeInvokeAll(this IEnumerable<Condition> self, bool logException = Condition.DefaultLogException)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return false;
}

foreach (var condition in self)
{
if (!condition.SafeInvoke(logException))
{
return false;
}
}

return true;
}

public static bool InvokeAny(this IEnumerable<Condition> self)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return false;
}

foreach (var condition in self)
{
if (condition.Invoke())
{
return true;
}
}

return false;
}

public static bool SafeInvokeAny(this IEnumerable<Condition> self, bool logException = Condition.DefaultLogException)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return false;
}

foreach (var condition in self)
{
if (condition.SafeInvoke(logException))
{
return true;
}
}

return false;
}

public static void CollectValidated(this ICollection<Condition> self, IEnumerable<Condition> source, bool logException = true)
{
if (self == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(self));
return;
}

if (source == null)
{
DebugUtility.LogException<ArgumentNullException>(nameof(source));
return;
}

foreach (var condition in source)
{
if (condition.Validate(logException)
&& !self.Contains(condition))
{
self.Add(condition);
}
}
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Extensions/ConditionExtensions.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Implementations.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Runtime/Implementations/Application.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Runtime/Implementations/Application/ApplicationCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Better.Commons.Runtime.Conditions
{
[Serializable]
public abstract class ApplicationCondition<TState> : StateCondition<TState>
{
protected ApplicationCondition(TState targetState) : base(targetState)
{
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Runtime/Implementations/Application/FocusedApplicationCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using UnityEngine;

namespace Better.Commons.Runtime.Conditions
{
[Serializable]
public class FocusedApplicationCondition : ApplicationCondition<bool>
{
public FocusedApplicationCondition(bool state) : base(state)
{
}

public FocusedApplicationCondition() : this(true)
{
}

public override bool Invoke()
{
return Application.isFocused == TargetState;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using UnityEngine;

namespace Better.Commons.Runtime.Conditions
{
[Serializable]
public class PlatformApplicationCondition : ApplicationCondition<RuntimePlatform>
{
public PlatformApplicationCondition(RuntimePlatform state) : base(state)
{
}

protected PlatformApplicationCondition() : this(RuntimePlatform.WindowsEditor)
{
}

public override bool Invoke()
{
return Application.platform == TargetState;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Runtime/Implementations/Application/SystemLanguageCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using UnityEngine;

namespace Better.Commons.Runtime.Conditions
{
[Serializable]
public class SystemLanguageCondition : ApplicationCondition<SystemLanguage>
{
public SystemLanguageCondition(SystemLanguage state) : base(state)
{
}

protected SystemLanguageCondition() : this(SystemLanguage.English)
{
}

public override bool Invoke()
{
return Application.systemLanguage == TargetState;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6bc4c19

Please sign in to comment.