biography-of-lijie/Assets/GameMain/Scripts/CustomComponent/StoryDirective/StoryDirectiveAsset.cs

42 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
namespace CustomComponent
{
public abstract class StoryDirectiveAsset : ScriptableObject
{
[SerializeField] private bool _enabled = true;
[SerializeField] private StoryTriggerType _triggerType = StoryTriggerType.DialogCompleted;
[SerializeField] [Tooltip("DialogCompleted 时为对话 Id<=0 表示该触发类型下的任意 Id。")]
private int _triggerId = 0;
public bool IsEnabled => _enabled;
public StoryTriggerType TriggerType => _triggerType;
public int TriggerId => _triggerId;
public virtual string ActionName => GetType().Name;
public virtual bool RequiresCompletion => false;
public bool IsMatch(StoryTriggerType triggerType, int triggerId)
{
if (!_enabled || _triggerType != triggerType)
{
return false;
}
if (triggerType == StoryTriggerType.DialogCompleted && _triggerId > 0 && _triggerId != triggerId)
{
return false;
}
return true;
}
public abstract void Execute(StoryDirectorComponent director);
}
}