Skip to content

Commit

Permalink
feat(quests and tasks): default quest and task definition can now be …
Browse files Browse the repository at this point in the history
…excluded from inspectors

Two new settings options have been added to hide the defulat quest and or task definition when
adding new items.
  • Loading branch information
ashblue committed Mar 26, 2024
1 parent cc23082 commit 359ba7b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using CleverCrow.Fluid.QuestJournals.Quests;
using CleverCrow.Fluid.QuestJournals.Tasks;
using UnityEngine;

namespace CleverCrow.Fluid.QuestJournals.Editors.Utilities {
public class TypesToMenu<T> {
Expand All @@ -18,12 +21,19 @@ public TypesToMenu () {
}

private static List<TypeEntry> GetTypeEntries () {
var settings = Resources.Load<QuestJournalSettings>("QuestJournalSettings");
var hideQuestDefault = settings == null ? false : settings.HideDefaultQuestDefinition;
var hideTaskDefault = settings == null ? false : settings.HideDefaultTaskDefinition;

var list = new List<TypeEntry>();
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) {
foreach (var type in assembly.GetTypes()) {
if (!type.IsSubclassOf(typeof(T)) || type.IsAbstract) continue;
var attr = type.GetCustomAttribute<CreateMenuAttribute>();

if (hideQuestDefault && type == typeof(QuestDefinition)) continue;
if (hideTaskDefault && type == typeof(TaskDefinition)) continue;

list.Add(new TypeEntry {
type = type,
path = attr?.Path ?? type.FullName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"rootNamespace": "",
"references": [
"com.fluid.quest-journal",
"com.fluid.adnc-utilities.Editor"
"com.fluid.adnc-utilities.Editor",
"com.fluid.simple-settings"
],
"includePlatforms": [
"Editor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@
namespace CleverCrow.Fluid.QuestJournals {
[CreateAssetMenu(fileName = "QuestJournalSettings", menuName = "Fluid/Quest Journal/Settings")]
public class QuestJournalSettings : SettingsBase<QuestJournalSettings> {
[Tooltip("Link your database here so the journal assets can be globally accessed")]
[SerializeField]
private QuestDatabase _database;

[Tooltip("Quests that will be automatically injected when the game begins. Overwritten on save and load")]
[SerializeField]
private List<QuestDefinitionBase> _startingQuests;

[Tooltip("Hide the default quest definition. Useful if you have your own custom quest definition class and don't want to see the default one in the inspector")]
[SerializeField]
bool _hideDefaultQuestDefinition;

[Tooltip("Hide the default task definition. Useful if you have your own custom task definition class and don't want to see the default one in the inspector")]
[SerializeField]
bool _hideDefaultTaskDefinition;

[Header("Debug")]

[Tooltip("Quests started automatically while using the Unity editor mode (excluded from runtime)")]
Expand All @@ -27,5 +37,7 @@ public class QuestJournalSettings : SettingsBase<QuestJournalSettings> {
public List<QuestDefinitionBase> StartingQuests => _startingQuests;
public List<QuestDebugEntry> DebugQuests => _debugQuests;
public List<TaskDefinition> DebugTasks => _debugTasks;
public bool HideDefaultQuestDefinition => _hideDefaultQuestDefinition;
public bool HideDefaultTaskDefinition => _hideDefaultTaskDefinition;
}
}

0 comments on commit 359ba7b

Please sign in to comment.