fr.jeanf.eventsystem 0.1.95 → 0.1.97

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.
@@ -0,0 +1,50 @@
1
+ using System;
2
+ using UnityEngine;
3
+ using UnityEngine.Events;
4
+
5
+ /// <summary>
6
+ /// To use a generic UnityEvent type you must override the generic type.
7
+ /// </summary>
8
+ namespace jeanf.EventSystem
9
+ {
10
+ [System.Serializable]
11
+ public class IntEnumEvent : UnityEvent<int, Enum>
12
+ {
13
+
14
+ }
15
+
16
+ /// <summary>
17
+ /// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
18
+ /// </summary>
19
+ public class IntEnumEventListener : MonoBehaviour, IDebugBehaviour
20
+ {
21
+ public bool isDebug
22
+ {
23
+ get => _isDebug;
24
+ set => _isDebug = value;
25
+ }
26
+ [SerializeField] private bool _isDebug = false;
27
+
28
+ [SerializeField] private IntEnumEventChannelSO _channel = default;
29
+
30
+ public IntEnumEvent OnEventRaised;
31
+
32
+ private void OnEnable()
33
+ {
34
+ if (_channel != null)
35
+ _channel.OnEventRaised += Respond;
36
+ }
37
+
38
+ private void OnDisable()
39
+ {
40
+ if (_channel != null)
41
+ _channel.OnEventRaised -= Respond;
42
+ }
43
+
44
+ private void Respond(int nb, Enum value)
45
+ {
46
+ OnEventRaised?.Invoke(nb, value);
47
+ if(isDebug) Debug.Log($" int-bool event raised: <{nb},{value}>");
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 20a10c4d556620f4882b58ec857a3227
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -52,17 +52,15 @@ namespace jeanf.EventSystem
52
52
  if (assignTimelineToPlayableDirector) _playableDirectorToControl.playableAsset = timeline;
53
53
  if(timeline != _playableDirectorToControl.playableAsset) return;
54
54
  OnEventRaised?.Invoke(timeline, value);
55
- switch (value)
55
+ if (value)
56
56
  {
57
- case true:
58
- _playableDirectorToControl.Play();
59
- if(isDebug) Debug.Log($" received timeline play instruction: <{timeline},{value}>");
60
- break;
61
- case false when timeline == _playableDirectorToControl.playableAsset:
62
- _playableDirectorToControl.Stop();
63
- if(isDebug) Debug.Log($" received timeline stop instruction: <{timeline},{value}>");
64
- break;
57
+ _playableDirectorToControl.Play();
65
58
  }
59
+ else
60
+ {
61
+ _playableDirectorToControl.Stop();
62
+ }
63
+ if(isDebug) Debug.Log($" timeline-bool event raised: <{timeline},{value}>");
66
64
  }
67
65
  }
68
66
  }
@@ -0,0 +1,18 @@
1
+ using System;
2
+ using UnityEngine;
3
+ using UnityEngine.Events;
4
+
5
+ namespace jeanf.EventSystem
6
+ {
7
+ [CreateAssetMenu(menuName = "Events/Advanced/<Int,Enum> Event Channel")]
8
+
9
+ public class IntEnumEventChannelSO : DescriptionBaseSO
10
+ {
11
+ public UnityAction<int, Enum> OnEventRaised;
12
+
13
+ public void RaiseEvent(int nb, Enum value)
14
+ {
15
+ OnEventRaised?.Invoke(nb, value);
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ac39704fae6958d4396fd823796f97cd
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,20 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using UnityEngine.Events;
5
+
6
+ namespace jeanf.EventSystem
7
+ {
8
+ [CreateAssetMenu(menuName = "Events/Lists/String List Event Channel")]
9
+ public class StringListEventChannelSO : DescriptionBaseSO
10
+ {
11
+ public UnityAction<List<string>> OnEventRaised;
12
+
13
+ public void RaiseEvent(List<string> strings)
14
+ {
15
+ if (OnEventRaised != null)
16
+ OnEventRaised.Invoke(strings);
17
+ }
18
+
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 699ed1ecc45b8a74faf76333f0d06418
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,24 @@
1
+ using System;
2
+ using UnityEngine;
3
+
4
+ namespace jeanf.EventSystem
5
+ {
6
+ public class IntEnumEventSender : MonoBehaviour, IDebugBehaviour
7
+ {
8
+ public bool isDebug
9
+ {
10
+ get => _isDebug;
11
+ set => _isDebug = value;
12
+ }
13
+
14
+ [SerializeField] private bool _isDebug = false;
15
+
16
+ [field: Header("Broadcasting on:")] public IntEnumEventChannelSO intEnumMessageChannel;
17
+
18
+ public void SendIntEnum(int nb, Enum value)
19
+ {
20
+ intEnumMessageChannel.RaiseEvent(nb, value);
21
+ }
22
+ }
23
+ }
24
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c6b09f9e56b867948a7d9c46f79a3b05
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fr.jeanf.eventsystem",
3
- "version": "0.1.95",
3
+ "version": "0.1.97",
4
4
  "displayName": "Event System",
5
5
  "description": "This package contains a basic Event System based on Scriptable Objects as communication medium",
6
6
  "unity": "2021.3",