added use unce to dialogue trigger and trigger editor

This commit is contained in:
2025-02-11 17:02:03 +01:00
parent c7bac778a7
commit 613008e7f2
2 changed files with 7 additions and 2 deletions

View File

@@ -165,6 +165,8 @@ namespace PixelCrushers.DialogueSystem
questPicker.showReferenceDatabase = false; questPicker.showReferenceDatabase = false;
} }
if (newDatabase != null) EditorTools.selectedDatabase = newDatabase; if (newDatabase != null) EditorTools.selectedDatabase = newDatabase;
var fireOnceProperty = serializedObject.FindProperty("fireOnce");
EditorGUILayout.PropertyField(fireOnceProperty);
} }
protected virtual void DrawConditions() protected virtual void DrawConditions()

View File

@@ -29,7 +29,7 @@ namespace PixelCrushers.DialogueSystem
[Tooltip("The trigger that this component listens for.")] [Tooltip("The trigger that this component listens for.")]
[DialogueSystemTriggerEvent] [DialogueSystemTriggerEvent]
public DialogueSystemTriggerEvent trigger = DialogueSystemTriggerEvent.OnUse; public DialogueSystemTriggerEvent trigger = DialogueSystemTriggerEvent.OnUse;
public bool fireOnce = true;
/// <summary> /// <summary>
/// The conditions under which the trigger will fire. /// The conditions under which the trigger will fire.
/// </summary> /// </summary>
@@ -363,7 +363,7 @@ namespace PixelCrushers.DialogueSystem
protected bool didIPause = false; protected bool didIPause = false;
protected float preConversationTimeScale = 1; protected float preConversationTimeScale = 1;
protected bool tryingToStart = false; protected bool tryingToStart = false;
protected bool hasFired = false;
#endregion #endregion
#region Trigger Checks #region Trigger Checks
@@ -609,6 +609,8 @@ namespace PixelCrushers.DialogueSystem
public void TryStart(Transform actor, Transform interactor) public void TryStart(Transform actor, Transform interactor)
{ {
if (tryingToStart) return; if (tryingToStart) return;
if (fireOnce && hasFired)
return;
tryingToStart = true; tryingToStart = true;
try try
{ {
@@ -626,6 +628,7 @@ namespace PixelCrushers.DialogueSystem
public void Fire(Transform actor) public void Fire(Transform actor)
{ {
if (DialogueDebug.logInfo) Debug.Log("Dialogue System: Dialogue System Trigger is firing " + trigger + ".", this); if (DialogueDebug.logInfo) Debug.Log("Dialogue System: Dialogue System Trigger is firing " + trigger + ".", this);
hasFired = true;
DoQuestAction(); DoQuestAction();
DoLuaAction(); DoLuaAction();
DoSequenceAction(actor); DoSequenceAction(actor);