diff --git a/SCHIZO/Items/Components/DestroyOnStoryGoal.cs b/SCHIZO/Items/Components/DestroyOnStoryGoal.cs new file mode 100644 index 00000000..7ae112bd --- /dev/null +++ b/SCHIZO/Items/Components/DestroyOnStoryGoal.cs @@ -0,0 +1,34 @@ +using SCHIZO.Helpers; +using Story; + +namespace SCHIZO.Items.Components; +partial class DestroyOnStoryGoal : IStoryGoalListener +{ + private string storyGoal; + public void Start() + { + storyGoal = RetargetHelpers.Pick(storyGoalSN, storyGoalBZ); + StoryGoalManager.main.AddListener(this); + UpdateActive(); + } + + private void OnDestroy() + { + StoryGoalManager.main.RemoveListener(this); + } + + public void NotifyGoalComplete(string key) => UpdateActive(key); + + public void NotifyGoalReset(string key) => UpdateActive(key); + + public void NotifyGoalsDeserialized() => UpdateActive(); + + private void UpdateActive(string key = null) + { + if (key is { } && !StoryGoalHelpers.Matches(key, storyGoal)) + return; + + if (StoryGoalHelpers.IsCompleted(storyGoal)) + Destroy(GetComponentInParent().gameObject); + } +} diff --git a/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs b/SCHIZO/Items/Components/DisableUntilStoryGoal.cs similarity index 96% rename from SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs rename to SCHIZO/Items/Components/DisableUntilStoryGoal.cs index 5c1ae5be..f1724b56 100644 --- a/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs +++ b/SCHIZO/Items/Components/DisableUntilStoryGoal.cs @@ -1,7 +1,7 @@ using SCHIZO.Helpers; using Story; -namespace SCHIZO.Creatures.Components; +namespace SCHIZO.Items.Components; partial class DisableUntilStoryGoal : IStoryGoalListener { private string storyGoal; diff --git a/SCHIZO/Items/PDAJournal.cs b/SCHIZO/Items/PDAJournal.cs index 317ef912..0ce67edf 100644 --- a/SCHIZO/Items/PDAJournal.cs +++ b/SCHIZO/Items/PDAJournal.cs @@ -3,6 +3,7 @@ using Nautilus.Assets.Gadgets; using Nautilus.Assets.PrefabTemplates; using SCHIZO.Helpers; +using SCHIZO.Items.Components; namespace SCHIZO.Items; @@ -52,6 +53,12 @@ private PDAJournalPrefab(PDAJournal journal) if (!string.IsNullOrEmpty(journal.pdaHandTargetSubtext)) handTarget.secondaryTooltip = journal.pdaHandTargetSubtext; handTarget.goal.key = journal.key; + + DestroyOnStoryGoal preventDupes = prefab.EnsureComponent(); + preventDupes.storyGoalSN = preventDupes.storyGoalBZ = journal.key; + + DestroyInCreativeMode storyOnly = prefab.EnsureComponent(); + prefab.SetActive(false); } }); diff --git a/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs b/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs new file mode 100644 index 00000000..659469b3 --- /dev/null +++ b/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs @@ -0,0 +1,13 @@ +using TriInspector; +using UnityEngine; + +namespace SCHIZO.Items.Components +{ + public sealed partial class DestroyOnStoryGoal : MonoBehaviour + { + [LabelText("Story Goal (SN)")] + public string storyGoalSN; + [LabelText("Story Goal (BZ)")] + public string storyGoalBZ; + } +} diff --git a/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs.meta b/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs.meta new file mode 100644 index 00000000..c02b08ca --- /dev/null +++ b/Unity/Assets/Scripts/SCHIZO/Items/Components/DestroyOnStoryGoal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 102eeab305a13b445a135e87c9d3e2da +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Scripts/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs b/Unity/Assets/Scripts/SCHIZO/Items/Components/DisableUntilStoryGoal.cs similarity index 87% rename from Unity/Assets/Scripts/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs rename to Unity/Assets/Scripts/SCHIZO/Items/Components/DisableUntilStoryGoal.cs index f8b964e6..08f32bba 100644 --- a/Unity/Assets/Scripts/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs +++ b/Unity/Assets/Scripts/SCHIZO/Items/Components/DisableUntilStoryGoal.cs @@ -1,7 +1,7 @@ using TriInspector; using UnityEngine; -namespace SCHIZO.Creatures.Components +namespace SCHIZO.Items.Components { public sealed partial class DisableUntilStoryGoal : MonoBehaviour { @@ -10,4 +10,4 @@ public sealed partial class DisableUntilStoryGoal : MonoBehaviour [LabelText("Story Goal (BZ)")] public string storyGoalBZ; } -} \ No newline at end of file +} diff --git a/Unity/Assets/Scripts/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs.meta b/Unity/Assets/Scripts/SCHIZO/Items/Components/DisableUntilStoryGoal.cs.meta similarity index 100% rename from Unity/Assets/Scripts/SCHIZO/Creatures/Components/DisableUntilStoryGoal.cs.meta rename to Unity/Assets/Scripts/SCHIZO/Items/Components/DisableUntilStoryGoal.cs.meta diff --git a/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs b/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs new file mode 100644 index 00000000..83c501a2 --- /dev/null +++ b/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs @@ -0,0 +1,9 @@ +using SCHIZO.TriInspector.Attributes; +using TriInspector; +using UnityEngine; + +[DeclareComponentReferencesGroup] +public class DestroyDuplicates : MonoBehaviour +{ + [ComponentReferencesGroup, Required] public PrefabIdentifier identifier; +} diff --git a/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs.meta b/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs.meta new file mode 100644 index 00000000..f0356571 --- /dev/null +++ b/Unity/Assets/Scripts/Subnautica/DestroyDuplicates.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f662b06ddd69e43409fffd67db201120 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: