com.puzzlescapegames.services 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/DefineSymbols.meta +8 -0
- package/Editor/XCodePostProcess.cs +32 -0
- package/Editor/XCodePostProcess.cs.meta +11 -0
- package/Runtime/ApplicationBehaviour.cs +39 -0
- package/Runtime/ApplicationBehaviour.cs.meta +11 -0
- package/Runtime/Observer.cs +94 -0
- package/Runtime/Observer.cs.meta +11 -0
- package/Runtime/PuzzlescapeGames.Services.asmdef +3 -0
- package/Runtime/PuzzlescapeGames.Services.asmdef.meta +7 -0
- package/Runtime/Registrator.cs +97 -0
- package/Runtime/Registrator.cs.meta +11 -0
- package/Runtime/Version.cs +24 -0
- package/Runtime/Version.cs.meta +11 -0
- package/package.json +1 -1
- /package/Editor/{DefineSymbolsInstaller.cs → DefineSymbols/DefineSymbolsInstaller.cs} +0 -0
- /package/Editor/{DefineSymbolsInstaller.cs.meta → DefineSymbols/DefineSymbolsInstaller.cs.meta} +0 -0
- /package/Editor/{DefineSymbolsInstallerEditor.cs → DefineSymbols/DefineSymbolsInstallerEditor.cs} +0 -0
- /package/Editor/{DefineSymbolsInstallerEditor.cs.meta → DefineSymbols/DefineSymbolsInstallerEditor.cs.meta} +0 -0
- /package/Editor/{SymbolsDefinition.cs → DefineSymbols/SymbolsDefinition.cs} +0 -0
- /package/Editor/{SymbolsDefinition.cs.meta → DefineSymbols/SymbolsDefinition.cs.meta} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#if UNITY_IPHONE || UNITY_IOS
|
|
2
|
+
using System.IO;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEditor.Callbacks;
|
|
5
|
+
using UnityEditor.iOS.Xcode;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace PuzzlescapeGames.Services.Editor
|
|
9
|
+
{
|
|
10
|
+
public static class XCodePostProcess
|
|
11
|
+
{
|
|
12
|
+
[ PostProcessBuild ]
|
|
13
|
+
public static void ChangeXcodePlist( BuildTarget buildTarget, string path )
|
|
14
|
+
{
|
|
15
|
+
if ( buildTarget == BuildTarget.iOS )
|
|
16
|
+
{
|
|
17
|
+
string plistPath = path + "/Info.plist";
|
|
18
|
+
PlistDocument plist = new PlistDocument();
|
|
19
|
+
plist.ReadFromFile( plistPath );
|
|
20
|
+
|
|
21
|
+
PlistElementDict rootDict = plist.root;
|
|
22
|
+
|
|
23
|
+
Debug.Log( "[iOS] Change plist file" );
|
|
24
|
+
|
|
25
|
+
rootDict.SetBoolean( "ITSAppUsesNonExemptEncryption", false );
|
|
26
|
+
|
|
27
|
+
File.WriteAllText( plistPath, plist.WriteToString() );
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
#endif
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using Object = UnityEngine.Object;
|
|
4
|
+
|
|
5
|
+
namespace PuzzlescapeGames.Services
|
|
6
|
+
{
|
|
7
|
+
public sealed class ApplicationBehaviour : MonoBehaviour
|
|
8
|
+
{
|
|
9
|
+
public event Action< bool > OnApplicationFocusChanged;
|
|
10
|
+
|
|
11
|
+
public static ApplicationBehaviour Instance => IsValid() ? _instance : CreateSingleton();
|
|
12
|
+
private static ApplicationBehaviour _instance;
|
|
13
|
+
|
|
14
|
+
private static ApplicationBehaviour CreateSingleton()
|
|
15
|
+
{
|
|
16
|
+
_instance = new GameObject( "ApplicationBehaviour" ).AddComponent< ApplicationBehaviour >();
|
|
17
|
+
// _instance.gameObject.hideFlags = HideFlags.DontSave;
|
|
18
|
+
DontDestroyOnLoad( _instance.gameObject );
|
|
19
|
+
return _instance;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private void OnDestroy()
|
|
23
|
+
{
|
|
24
|
+
_instance = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private void OnApplicationFocus( bool focus )
|
|
28
|
+
{
|
|
29
|
+
OnApplicationFocusChanged?.Invoke( focus );
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private static bool IsValid()
|
|
33
|
+
{
|
|
34
|
+
if (_instance is Object unityObject)
|
|
35
|
+
return unityObject != null && unityObject;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
|
|
5
|
+
namespace PuzzlescapeGames.Services
|
|
6
|
+
{
|
|
7
|
+
public class Observer< T >
|
|
8
|
+
{
|
|
9
|
+
public event Action OnCollectionChanged;
|
|
10
|
+
public event Action< T > OnItemAdded;
|
|
11
|
+
public event Action< T > OnItemRemoved;
|
|
12
|
+
|
|
13
|
+
public IReadOnlyList< T > Observables => _observables;
|
|
14
|
+
protected readonly List< T > _observables = new();
|
|
15
|
+
|
|
16
|
+
public virtual void AddObserver( T observable, bool notify = true )
|
|
17
|
+
{
|
|
18
|
+
_observables.Add( observable );
|
|
19
|
+
|
|
20
|
+
if ( !notify ) return;
|
|
21
|
+
|
|
22
|
+
OnItemAdded?.Invoke( observable );
|
|
23
|
+
OnCollectionChanged?.Invoke();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public virtual void AddObservers( IEnumerable< T > observables, bool notify = true )
|
|
27
|
+
{
|
|
28
|
+
_observables.AddRange( observables );
|
|
29
|
+
|
|
30
|
+
if ( !notify ) return;
|
|
31
|
+
|
|
32
|
+
OnCollectionChanged?.Invoke();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public virtual void RemoveObserver( T observable, bool notify = true )
|
|
36
|
+
{
|
|
37
|
+
_observables.Remove( observable );
|
|
38
|
+
|
|
39
|
+
if ( !notify ) return;
|
|
40
|
+
|
|
41
|
+
OnItemRemoved?.Invoke( observable );
|
|
42
|
+
OnCollectionChanged?.Invoke();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void RemoveObserver< O >( bool notify = true )
|
|
46
|
+
where O : class, T
|
|
47
|
+
{
|
|
48
|
+
O item = GetAs< O >();
|
|
49
|
+
if ( item != null )
|
|
50
|
+
{
|
|
51
|
+
RemoveObserver( item, notify );
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public virtual void RemoveObservers( IEnumerable< T > observables, bool notify = true )
|
|
56
|
+
{
|
|
57
|
+
foreach ( var observable in observables )
|
|
58
|
+
{
|
|
59
|
+
_observables.Remove( observable );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ( !notify ) return;
|
|
63
|
+
|
|
64
|
+
OnCollectionChanged?.Invoke();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public T GetAs< T >()
|
|
68
|
+
{
|
|
69
|
+
return _observables.OfType< T >().FirstOrDefault();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public virtual bool Contains( T observable )
|
|
73
|
+
{
|
|
74
|
+
return _observables.Contains( observable );
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public virtual bool Contains< T >()
|
|
78
|
+
{
|
|
79
|
+
return _observables.OfType< T >().FirstOrDefault() != null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public bool ContainsType( Type observable )
|
|
83
|
+
{
|
|
84
|
+
return _observables.Any( ( x ) => x.GetType() == observable );
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public virtual void Clear()
|
|
88
|
+
{
|
|
89
|
+
_observables.Clear();
|
|
90
|
+
|
|
91
|
+
OnCollectionChanged?.Invoke();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
|
|
5
|
+
namespace PuzzlescapeGames.Services
|
|
6
|
+
{
|
|
7
|
+
public class Registrator<T>
|
|
8
|
+
{
|
|
9
|
+
public event Action OnCollectionChanged;
|
|
10
|
+
public event Action<T> OnItemAdded;
|
|
11
|
+
public event Action<T> OnItemRemoved;
|
|
12
|
+
|
|
13
|
+
public IReadOnlyList<T> Registers => _registers;
|
|
14
|
+
protected readonly List<T> _registers = new();
|
|
15
|
+
|
|
16
|
+
public void SetCollection( IEnumerable< T > items )
|
|
17
|
+
{
|
|
18
|
+
_registers.Clear();
|
|
19
|
+
_registers.AddRange( items );
|
|
20
|
+
|
|
21
|
+
OnCollectionChanged?.Invoke();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public virtual bool Registrate( T register )
|
|
25
|
+
{
|
|
26
|
+
if ( !_registers.Contains( register ) )
|
|
27
|
+
{
|
|
28
|
+
_registers.Add( register );
|
|
29
|
+
|
|
30
|
+
OnItemAdded?.Invoke( register );
|
|
31
|
+
OnCollectionChanged?.Invoke();
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public virtual void Registrate( IEnumerable< T > items )
|
|
40
|
+
{
|
|
41
|
+
foreach ( T register in items )
|
|
42
|
+
if ( !_registers.Contains( register ) )
|
|
43
|
+
_registers.Add( register );
|
|
44
|
+
|
|
45
|
+
OnCollectionChanged?.Invoke();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public virtual bool UnRegistrate( T register )
|
|
49
|
+
{
|
|
50
|
+
if ( _registers.Contains( register ) )
|
|
51
|
+
{
|
|
52
|
+
_registers.Remove( register );
|
|
53
|
+
|
|
54
|
+
OnItemRemoved?.Invoke( register );
|
|
55
|
+
OnCollectionChanged?.Invoke();
|
|
56
|
+
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public R GetAs< R >()
|
|
64
|
+
where R : class, T =>
|
|
65
|
+
Get<R>() as R;
|
|
66
|
+
|
|
67
|
+
public T Get< R >()
|
|
68
|
+
where R : T
|
|
69
|
+
{
|
|
70
|
+
if ( ContainsType< R >() ) return _registers.Where( x => x is R ).FirstOrDefault();
|
|
71
|
+
|
|
72
|
+
throw new Exception( $"REGISTRATOR DOESN'T CONTAINS {typeof(R)} ERROR" );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public bool ContainsType< R >()
|
|
76
|
+
where R : T =>
|
|
77
|
+
_registers.OfType< R >().Any();
|
|
78
|
+
|
|
79
|
+
public bool ContainsType< R >( R registr )
|
|
80
|
+
where R : T
|
|
81
|
+
{
|
|
82
|
+
return _registers.Any( ( x ) => x.GetType() == registr.GetType() );
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public bool ContainsType( Type registr )
|
|
86
|
+
{
|
|
87
|
+
return _registers.Any( ( x ) => x.GetType() == registr );
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public bool ContainsType< R >( out R registr )
|
|
91
|
+
where R : T
|
|
92
|
+
{
|
|
93
|
+
registr = _registers.OfType< R >().FirstOrDefault();
|
|
94
|
+
return registr != null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
namespace PuzzlescapeGames.Services
|
|
2
|
+
{
|
|
3
|
+
public class Version
|
|
4
|
+
{
|
|
5
|
+
public int Major;
|
|
6
|
+
public int Minor;
|
|
7
|
+
public int Patch;
|
|
8
|
+
|
|
9
|
+
public Version( string version )
|
|
10
|
+
{
|
|
11
|
+
var array = version.Split( "." );
|
|
12
|
+
Major = int.Parse( array[ 0 ] );
|
|
13
|
+
Minor = int.Parse( array[ 1 ] );
|
|
14
|
+
Patch = int.Parse( array[ 2 ] );
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public Version( int major, int minor, int patch )
|
|
18
|
+
{
|
|
19
|
+
Major = major;
|
|
20
|
+
Minor = minor;
|
|
21
|
+
Patch = patch;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
File without changes
|
/package/Editor/{DefineSymbolsInstaller.cs.meta → DefineSymbols/DefineSymbolsInstaller.cs.meta}
RENAMED
|
File without changes
|
/package/Editor/{DefineSymbolsInstallerEditor.cs → DefineSymbols/DefineSymbolsInstallerEditor.cs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|