Merge branch 'feature/scripted-dialogue-triggers' into 'main'

add prefab for scripted dialogue trigger zone

See merge request kernel-panic/revival!20
This commit is contained in:
Cinder Foster-Smith 2021-03-02 18:37:56 +00:00
commit 83b313dc8d
9 changed files with 182 additions and 1 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1b481c80f856b7c41a1157a5d66f53ef
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,61 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &592757652223086935
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 592757652223086933}
- component: {fileID: 592757652223086934}
- component: {fileID: 592757652223086932}
m_Layer: 0
m_Name: Dialogue Trigger Zone
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &592757652223086933
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592757652223086935}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &592757652223086934
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592757652223086935}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf23d7e814442a54888e34f51cbf3cc3, type: 3}
m_Name:
m_EditorClassIdentifier:
_dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2}
_key: SD_APPROACH
--- !u!65 &592757652223086932
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 592757652223086935}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 10, y: 10, z: 1}
m_Center: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b4c7a4f0875ec844a9abeec0c86084cf
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -123,6 +123,63 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &466003104
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalPosition.x
value: 6.99
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalPosition.z
value: 5.77
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalRotation.w
value: -0.49999666
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalRotation.y
value: 0.8660274
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 240
objectReference: {fileID: 0}
- target: {fileID: 592757652223086933, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 592757652223086935, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
propertyPath: m_Name
value: Dialogue Trigger Zone
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: b4c7a4f0875ec844a9abeec0c86084cf, type: 3}
--- !u!1001 &671236672
PrefabInstance:
m_ObjectHideFlags: 0
@ -964,6 +1021,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8626562367081348111, guid: 2dae894ec500e524a88f985657f9682d, type: 3}
propertyPath: data
value:
objectReference: {fileID: 11400000, guid: 8882f0bc24a2179459b1e851f8645241, type: 2}
- target: {fileID: 8781564213167799763, guid: 2dae894ec500e524a88f985657f9682d, type: 3}
propertyPath: m_Name
value: Artefact 1
@ -1132,6 +1193,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8626562367081348111, guid: 2dae894ec500e524a88f985657f9682d, type: 3}
propertyPath: data
value:
objectReference: {fileID: 11400000, guid: a071ae87c1fc7554db6ae524b4a6d115, type: 2}
- target: {fileID: 8781564213167799763, guid: 2dae894ec500e524a88f985657f9682d, type: 3}
propertyPath: m_Name
value: Artefact 2

View File

@ -16,9 +16,14 @@ public partial class DialogueSystem : ScriptableObject
public event EventHandler<DialogueLine> onDialogueLine;
private readonly Dictionary<string, string> _fmodKeyCache = new Dictionary<string, string>();
// a list of dialogue keys that have already been spoken
private readonly List<string> _usedKeys = new List<string>();
private void OnEnable()
{
_fmodKeyCache.Clear();
_usedKeys.Clear();
// cache all dialogue keys for FMOD at start to avoid allocations later
foreach (var key in DialogueDatabase.Keys)
{
@ -26,8 +31,16 @@ public partial class DialogueSystem : ScriptableObject
}
}
public void PlayLine(string key)
// noRepeat locks this key off from further use. further attempts to use the key will be discarded
public void PlayLine(string key, bool noRepeat = true)
{
if (noRepeat)
{
if (_usedKeys.Contains(key)) return;
_usedKeys.Add(key);
}
// retrieve cached key
var fmodKey = _fmodKeyCache[key];

View File

@ -0,0 +1,16 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
public class ScriptedDialogueTrigger : MonoBehaviour
{
[SerializeField] private DialogueSystem _dialogue;
[SerializeField] private string _key;
private void OnTriggerEnter(Collider other)
{
_dialogue.PlayLine(_key);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf23d7e814442a54888e34f51cbf3cc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: