更改文件架构
This commit is contained in:
73
Packages/Common~/Scripts/SubSystems/Quest/QuestSystem.cs
Normal file
73
Packages/Common~/Scripts/SubSystems/Quest/QuestSystem.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit.SubSystems.Quest
|
||||
{
|
||||
public class QuestSystem : SubBITSystem
|
||||
{
|
||||
public enum State
|
||||
{
|
||||
None,
|
||||
InProcess,
|
||||
Complete,
|
||||
Canceled,
|
||||
}
|
||||
public class Info
|
||||
{
|
||||
public static implicit operator Guid(Info self)
|
||||
{
|
||||
return self.id;
|
||||
}
|
||||
public static implicit operator string(Info self)
|
||||
{
|
||||
return self.name;
|
||||
}
|
||||
internal Info(string name, string description)
|
||||
{
|
||||
id = Guid.NewGuid();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
public readonly Guid id;
|
||||
public State state { get; internal set; }
|
||||
public string name { get; internal set; }
|
||||
public string description { get; internal set; }
|
||||
//public List<Func<bool>> condition = new();
|
||||
}
|
||||
public static Dictionary<Guid, Info> quests { get; private set; } = new();
|
||||
public static event Action<Info> OnQuestCreated;
|
||||
public static event Action<Info> OnQuestCompleted;
|
||||
public static event Action<Info> OnQuestCanceled;
|
||||
public static Info Create(string name = "New Quest", string description = "Quest in progress")
|
||||
{
|
||||
Info info = new(name, description);
|
||||
info.state = State.InProcess;
|
||||
quests.Add(info, info);
|
||||
OnQuestCreated?.Invoke(info);
|
||||
return info;
|
||||
}
|
||||
public static void Complete(Info quest)
|
||||
{
|
||||
quest.state = State.Complete;
|
||||
OnQuestCompleted?.Invoke(quest);
|
||||
}
|
||||
public static void Cancel(Info quest)
|
||||
{
|
||||
if (quests.ContainsKey(quest.id))
|
||||
{
|
||||
quests.Remove(quest.id);
|
||||
quest.state = State.Canceled;
|
||||
OnQuestCanceled?.Invoke(quest);
|
||||
}
|
||||
}
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
static void Reload()
|
||||
{
|
||||
quests.Clear();
|
||||
OnQuestCreated = null;
|
||||
OnQuestCompleted = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b634dd120417a3409ba123b900bec56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user