net.dreditor.triggers 0.0.0-stage → 0.1.6
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/Actuator.cs +47 -0
- package/Actuator.cs.meta +11 -0
- package/ActuatorBehaviourBase.cs +62 -0
- package/ActuatorBehaviourBase.cs.meta +11 -0
- package/DREditor.Triggers.asmdef +18 -0
- package/DREditor.Triggers.asmdef.meta +7 -0
- package/DialogueSubsequent.cs +113 -0
- package/DialogueSubsequent.cs.meta +11 -0
- package/EventTrigger.cs +49 -0
- package/EventTrigger.cs.meta +11 -0
- package/FlagActuatorData.cs +60 -0
- package/FlagActuatorData.cs.meta +11 -0
- package/GenericActuator.cs +48 -0
- package/GenericActuator.cs.meta +11 -0
- package/GenericSubsequent.cs +24 -0
- package/GenericSubsequent.cs.meta +11 -0
- package/GenericTriggerBase.cs +53 -0
- package/GenericTriggerBase.cs.meta +11 -0
- package/HitboxActuator.cs +82 -0
- package/HitboxActuator.cs.meta +11 -0
- package/HitboxActuatorData.cs +46 -0
- package/HitboxActuatorData.cs.meta +11 -0
- package/IActuatorBehaviour.cs +21 -0
- package/IActuatorBehaviour.cs.meta +11 -0
- package/IActuatorConvert.cs +23 -0
- package/IActuatorConvert.cs.meta +11 -0
- package/IEventTriggerSaver.cs +22 -0
- package/IEventTriggerSaver.cs.meta +11 -0
- package/ISubsequentBehaviour.cs +15 -0
- package/ISubsequentBehaviour.cs.meta +11 -0
- package/ISubsequentConvert.cs +25 -0
- package/ISubsequentConvert.cs.meta +11 -0
- package/LDialogueSubsequent.cs +88 -0
- package/LDialogueSubsequent.cs.meta +11 -0
- package/LocalDialogueSubsequentData.cs +55 -0
- package/LocalDialogueSubsequentData.cs.meta +11 -0
- package/MovePlayerSubsequent.cs +142 -0
- package/MovePlayerSubsequent.cs.meta +11 -0
- package/OLFlagActuator.cs +67 -0
- package/OLFlagActuator.cs.meta +11 -0
- package/OnLoadActuator.cs +66 -0
- package/OnLoadActuator.cs.meta +11 -0
- package/PositionEventSubsequentData.cs +85 -0
- package/PositionEventSubsequentData.cs.meta +11 -0
- package/Samples/Transition_Finished_Subscriber.prefab +137 -0
- package/Samples/Transition_Finished_Subscriber.prefab.meta +7 -0
- package/Samples.meta +8 -0
- package/ScriptableObjectsSubsequentData.cs +58 -0
- package/ScriptableObjectsSubsequentData.cs.meta +11 -0
- package/SimpleActuatorData.cs +29 -0
- package/SimpleActuatorData.cs.meta +11 -0
- package/Subsequent.cs +44 -0
- package/Subsequent.cs.meta +11 -0
- package/TransitionFinishedSubscriber.cs +40 -0
- package/TransitionFinishedSubscriber.cs.meta +11 -0
- package/package.json +36 -6
- package/package.json.meta +7 -0
- package/README.md +0 -3
package/Actuator.cs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using UnityEngine.Serialization;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.Triggers
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
[Serializable]
|
|
13
|
+
public class Actuator : GenericActuator, IActuatorConvert
|
|
14
|
+
{
|
|
15
|
+
public Vector3 HitBoxSize;
|
|
16
|
+
|
|
17
|
+
[FormerlySerializedAs("stringList")]
|
|
18
|
+
public List<string> strings = new();
|
|
19
|
+
|
|
20
|
+
public bool boolValue;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/// <inheritdoc/>
|
|
24
|
+
public virtual bool CanConvert(GenericActuator genericActuator) => false;
|
|
25
|
+
|
|
26
|
+
/// <inheritdoc/>
|
|
27
|
+
public virtual void Convert(ref GenericActuator genericSubsequents, GenericActuator oldActuator) { }
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Kept for archival purposes, as this class will eventually be deleted.
|
|
31
|
+
///// <summary></summary>
|
|
32
|
+
///// <param name="a"></param>
|
|
33
|
+
///// <param name="i"></param>
|
|
34
|
+
///// <returns></returns>
|
|
35
|
+
//public static Actuator MergeInstance(Actuator a, Actuator i) // Use data of i to apply instance data
|
|
36
|
+
//{
|
|
37
|
+
// Actuator act = new();
|
|
38
|
+
// act.Type = a.Type;
|
|
39
|
+
// act.Triggered = i.Triggered;
|
|
40
|
+
// act.position = i.position;
|
|
41
|
+
// act.HitBoxSize = i.HitBoxSize;
|
|
42
|
+
// act.stringList = i.stringList;
|
|
43
|
+
// act.boolValue = i.boolValue;
|
|
44
|
+
// return null;
|
|
45
|
+
//}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/Actuator.cs.meta
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Services;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Triggers
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
/// <remarks>
|
|
12
|
+
///
|
|
13
|
+
/// </remarks>
|
|
14
|
+
public abstract class ActuatorBehaviourBase : MonoBehaviour, IActuatorBehaviour
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
protected virtual void Awake()
|
|
20
|
+
{
|
|
21
|
+
if (ServiceLocator.HasService<TransitionFinishedSubscriber>())
|
|
22
|
+
ServiceLocator.GetService<TransitionFinishedSubscriber>().SubscribeToRoomTransitionsFinished(InitializeActuator);
|
|
23
|
+
else
|
|
24
|
+
UnityEngine.Debug.LogWarning(gameObject.name + " Actuator: ALERT: The service for when the room transition finishes" +
|
|
25
|
+
" could not be found, therefore, this actuator will not initialize.");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
protected virtual void OnDestroy()
|
|
32
|
+
{
|
|
33
|
+
if (ServiceLocator.HasService<TransitionFinishedSubscriber>())
|
|
34
|
+
ServiceLocator.GetService<TransitionFinishedSubscriber>().UnsubscribeToRoomTransitionsFinished(InitializeActuator);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
protected abstract void InitializeActuator();
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/// <inheritdoc/>
|
|
44
|
+
public abstract object Save();
|
|
45
|
+
|
|
46
|
+
/// <inheritdoc/>
|
|
47
|
+
public abstract void Load(object ob);
|
|
48
|
+
|
|
49
|
+
/// <inheritdoc/>
|
|
50
|
+
public virtual void Call()
|
|
51
|
+
{
|
|
52
|
+
var subsequents = GetSubsequents();
|
|
53
|
+
|
|
54
|
+
foreach (ISubsequentBehaviour subsequent in subsequents)
|
|
55
|
+
subsequent.Call();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// <inheritdoc/>
|
|
59
|
+
public virtual ISubsequentBehaviour[] GetSubsequents() =>
|
|
60
|
+
GetComponents<MonoBehaviour>().OfType<ISubsequentBehaviour>().ToArray();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "DREditor.Triggers",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"DREditor",
|
|
6
|
+
"DREditor.LocalDialogues",
|
|
7
|
+
"DREditor.Progressing.Handling"
|
|
8
|
+
],
|
|
9
|
+
"includePlatforms": [],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [],
|
|
16
|
+
"versionDefines": [],
|
|
17
|
+
"noEngineReferences": false
|
|
18
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Dialogues;
|
|
3
|
+
using DREditor.Dialogues.Loading;
|
|
4
|
+
using DREditor.EventObjects;
|
|
5
|
+
using DREditor.Services;
|
|
6
|
+
using System;
|
|
7
|
+
using System.Collections.Generic;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Triggers
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[ClassHeader(nameof(ISubsequentBehaviour) + ", " + nameof(IDialogueHolder) +
|
|
16
|
+
"\n\n")]
|
|
17
|
+
public class DialogueSubsequent : MonoBehaviour, ISubsequentBehaviour, IDialogueHolder
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected List<Dialogue> dialogues = new();
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
///
|
|
28
|
+
/// </summary>
|
|
29
|
+
protected ScriptableObjectsSubsequentData data = new();
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/// <inheritdoc/>
|
|
33
|
+
public virtual void Call()
|
|
34
|
+
{
|
|
35
|
+
GameObject tryActor = null;
|
|
36
|
+
|
|
37
|
+
try
|
|
38
|
+
{
|
|
39
|
+
tryActor = GameObject.Find(dialogues[0].Lines[0].Speaker.FirstName);
|
|
40
|
+
}
|
|
41
|
+
catch (NullReferenceException)
|
|
42
|
+
{
|
|
43
|
+
UnityEngine.Debug.Log("REPORT: First Speaker on dialogue is null.");
|
|
44
|
+
}
|
|
45
|
+
catch (Exception e)
|
|
46
|
+
{
|
|
47
|
+
UnityEngine.Debug.Log("REPORT: Trouble getting first speaker: " + e.ToString());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
SelectableObject actor = null;
|
|
51
|
+
|
|
52
|
+
if (tryActor)
|
|
53
|
+
tryActor.GetComponent<SelectableObject>();
|
|
54
|
+
|
|
55
|
+
UnityEngine.Debug.Log("REPORT: Calling StartDialogue from Subsequent");
|
|
56
|
+
|
|
57
|
+
ServiceLocator.GetService<IDialogueManager>().StartDialogue(actor, dialogues.ToArray());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// <inheritdoc/>
|
|
61
|
+
public virtual bool CheckIfSaveDialogue()
|
|
62
|
+
{
|
|
63
|
+
if (data.scriptableObject is Dialogue dia)
|
|
64
|
+
if (ServiceLocator.GetService<IDialogueManager>()
|
|
65
|
+
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
66
|
+
.CheckDialogue<Line>(dia))
|
|
67
|
+
return true;
|
|
68
|
+
|
|
69
|
+
foreach (var dialogue in data.scriptableObjects)
|
|
70
|
+
if (ServiceLocator.GetService<IDialogueManager>()
|
|
71
|
+
.GetManagerComponent<DialogueLoadIdentifier>()
|
|
72
|
+
.CheckDialogue<Line>((Dialogue)dialogue))
|
|
73
|
+
return true;
|
|
74
|
+
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// <inheritdoc/>
|
|
79
|
+
public virtual object Save()
|
|
80
|
+
{
|
|
81
|
+
ScriptableObjectsSubsequentData newData = (ScriptableObjectsSubsequentData)data.Clone();
|
|
82
|
+
|
|
83
|
+
newData.SetType(GetType().Name);
|
|
84
|
+
|
|
85
|
+
newData.SetScriptableObject(data.scriptableObject);
|
|
86
|
+
|
|
87
|
+
foreach(var dialogue in dialogues)
|
|
88
|
+
if (!newData.scriptableObjects.Contains(dialogue))
|
|
89
|
+
newData.scriptableObjects.Add(dialogue);
|
|
90
|
+
|
|
91
|
+
return newData;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/// <inheritdoc/>
|
|
95
|
+
public virtual void Load(object ob)
|
|
96
|
+
{
|
|
97
|
+
data = (ScriptableObjectsSubsequentData)Convert.ChangeType(ob, typeof(ScriptableObjectsSubsequentData));
|
|
98
|
+
|
|
99
|
+
foreach (var dialogue in data.scriptableObjects)
|
|
100
|
+
dialogues.Add((Dialogue)dialogue);
|
|
101
|
+
|
|
102
|
+
if (dialogues.Count == 0 && data.scriptableObject != null)
|
|
103
|
+
dialogues.Add((Dialogue)data.scriptableObject);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
///
|
|
109
|
+
/// </summary>
|
|
110
|
+
[ContextMenu("Call")]
|
|
111
|
+
public void DebugCall() => Call();
|
|
112
|
+
}
|
|
113
|
+
}
|
package/EventTrigger.cs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Triggers
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[Serializable]
|
|
12
|
+
public class EventTrigger
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Header("")]
|
|
18
|
+
[Divider]
|
|
19
|
+
[Tooltip("")]
|
|
20
|
+
[SerializeReference]
|
|
21
|
+
public GenericActuator GenericActuator;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeReference]
|
|
28
|
+
public List<GenericSubsequent> GenericSubsequents = new();
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
[Tooltip("")]
|
|
34
|
+
public Actuator Actuator;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
[Tooltip("")]
|
|
40
|
+
public List<Subsequent> Subsequents = new();
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
///
|
|
45
|
+
/// </summary>
|
|
46
|
+
/// <param name="GenericActuator"></param>
|
|
47
|
+
public virtual void SetActuator(GenericActuator GenericActuator) => this.GenericActuator = GenericActuator;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Triggers
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[Serializable]
|
|
12
|
+
public class FlagActuatorData : GenericActuator, IActuatorConvert
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[Tooltip("")]
|
|
18
|
+
public bool callIfFlagsAre = true;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
[Tooltip("")]
|
|
24
|
+
public List<string> flags = new();
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
///
|
|
29
|
+
/// </summary>
|
|
30
|
+
/// <param name="flags"></param>
|
|
31
|
+
public virtual void SetStringList(List<string> flags) => this.flags = flags;
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
///
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <param name="callIfFlagsAre"></param>
|
|
37
|
+
public virtual void SetBoolValue(bool callIfFlagsAre) => this.callIfFlagsAre = callIfFlagsAre;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/// <inheritdoc/>
|
|
41
|
+
public virtual bool CanConvert(GenericActuator oldActuator) => ((Actuator)oldActuator).strings.Count > 0;
|
|
42
|
+
|
|
43
|
+
/// <inheritdoc/>
|
|
44
|
+
public virtual void Convert(ref GenericActuator genericActuator, GenericActuator oldActuator)
|
|
45
|
+
{
|
|
46
|
+
var newData = new FlagActuatorData(oldActuator.Type, oldActuator.Triggered, oldActuator.position)
|
|
47
|
+
{
|
|
48
|
+
flags = ((Actuator)oldActuator).strings,
|
|
49
|
+
callIfFlagsAre = ((Actuator)oldActuator).boolValue
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
genericActuator = newData;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public FlagActuatorData() { }
|
|
57
|
+
|
|
58
|
+
public FlagActuatorData(string Type, bool Triggered, Vector3 position) : base(Type, Triggered, position) { }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.Triggers
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
[Serializable]
|
|
11
|
+
public abstract class GenericActuator : GenericTriggerBase
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[Tooltip("")]
|
|
17
|
+
public bool Triggered = false;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
///
|
|
21
|
+
/// </summary>
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
public Vector3 position;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
///
|
|
28
|
+
/// </summary>
|
|
29
|
+
/// <param name="Triggered"></param>
|
|
30
|
+
public virtual void SetTriggered(bool Triggered) => this.Triggered = Triggered;
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
///
|
|
34
|
+
/// </summary>
|
|
35
|
+
/// <param name="position"></param>
|
|
36
|
+
public virtual void SetPosition(Vector3 position) => this.position = position;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
protected GenericActuator() { }
|
|
40
|
+
|
|
41
|
+
protected GenericActuator(string Type, bool Triggered, Vector3 position) : base(Type)
|
|
42
|
+
{
|
|
43
|
+
this.Triggered = Triggered;
|
|
44
|
+
|
|
45
|
+
this.position = position;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.Triggers
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
[Serializable]
|
|
10
|
+
public abstract class GenericSubsequent : GenericTriggerBase
|
|
11
|
+
{
|
|
12
|
+
protected GenericSubsequent() { }
|
|
13
|
+
|
|
14
|
+
protected GenericSubsequent(string Type) : base(Type) { }
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
/// <param name="instance"></param>
|
|
21
|
+
/// <returns></returns>
|
|
22
|
+
public abstract GenericSubsequent MergeInstance(GenericSubsequent instance);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.Triggers
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
[Serializable]
|
|
11
|
+
public abstract class GenericTriggerBase
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[Tooltip("")]
|
|
17
|
+
public string Type;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <param name="Type"></param>
|
|
24
|
+
public virtual void SetType(string Type) => this.Type = Type;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// Because the class type name might change namespaces, having this would
|
|
28
|
+
// help at least store and allow for a converter to be made.
|
|
29
|
+
// But at the moment the TriggerLoader class just scans assemblies to always find the right class,
|
|
30
|
+
// therefore this isn't needed at the moment, but it uses system.reflection, so it is only a
|
|
31
|
+
// temporary solution and should eventually be fixed in a future update.
|
|
32
|
+
//public string classTypeName;
|
|
33
|
+
|
|
34
|
+
//public void SetClassTypeName(string classTypeName) => this.classTypeName = classTypeName;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
/// <returns></returns>
|
|
40
|
+
public virtual object Clone() => MemberwiseClone();
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
protected GenericTriggerBase() { }
|
|
44
|
+
|
|
45
|
+
protected GenericTriggerBase(string Type)
|
|
46
|
+
{
|
|
47
|
+
this.Type = Type;
|
|
48
|
+
|
|
49
|
+
// See classTypeName comments
|
|
50
|
+
//classTypeName = GetType().ToString();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.Triggers
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
[RequireComponent(typeof(BoxCollider))]
|
|
11
|
+
[ClassHeader(nameof(IActuatorBehaviour) +
|
|
12
|
+
"\n\n")]
|
|
13
|
+
public class HitboxActuator : ActuatorBehaviourBase
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
[Tooltip("")]
|
|
19
|
+
protected HitboxActuatorData data = new();
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
protected BoxCollider hitbox = null;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/// <inheritdoc/>
|
|
29
|
+
protected override void InitializeActuator()
|
|
30
|
+
{
|
|
31
|
+
hitbox = GetComponent<BoxCollider>();
|
|
32
|
+
|
|
33
|
+
if (data.Triggered == false)
|
|
34
|
+
hitbox.enabled = true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected virtual void OnTriggerEnter(Collider other)
|
|
38
|
+
{
|
|
39
|
+
if (!data.Triggered)
|
|
40
|
+
{
|
|
41
|
+
data.SetTriggered(!data.Triggered);
|
|
42
|
+
|
|
43
|
+
hitbox.enabled = false;
|
|
44
|
+
|
|
45
|
+
base.Call();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// <inheritdoc/>
|
|
50
|
+
public override object Save()
|
|
51
|
+
{
|
|
52
|
+
HitboxActuatorData newData = (HitboxActuatorData)data.Clone();
|
|
53
|
+
|
|
54
|
+
newData.SetType(GetType().Name);
|
|
55
|
+
|
|
56
|
+
newData.SetTriggered(data.Triggered);
|
|
57
|
+
|
|
58
|
+
newData.SetPosition(transform.position);
|
|
59
|
+
|
|
60
|
+
newData.SetHitboxSize(hitbox.size);
|
|
61
|
+
|
|
62
|
+
return newData;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// <inheritdoc/>
|
|
66
|
+
public override void Load(object ob)
|
|
67
|
+
{
|
|
68
|
+
data = (HitboxActuatorData)Convert.ChangeType(ob, typeof(HitboxActuatorData));
|
|
69
|
+
|
|
70
|
+
transform.position = data.position;
|
|
71
|
+
|
|
72
|
+
if (!TryGetComponent(out hitbox))
|
|
73
|
+
hitbox = gameObject.AddComponent<BoxCollider>();
|
|
74
|
+
|
|
75
|
+
hitbox.enabled = false;
|
|
76
|
+
|
|
77
|
+
hitbox.isTrigger = true;
|
|
78
|
+
|
|
79
|
+
hitbox.size = data.HitboxSize;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|