From ff52e832f60d325883daa7e8c587225994e1e69b Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Mon, 2 Sep 2024 03:51:31 -0400 Subject: [PATCH] more POIs --- .../AutoMove/exampleitems.automove.json | 20 ++ .../Explosive/exampleitems.explosive.json | 14 ++ .../Inspect/exampleitems.inspect.json | 9 + .../Assets/POI/Dock/exampleitems.dock.json | 7 + .../exampleitems.exampledredgeharvestpoi.json | 10 +- .../exampleitems.exampleharvestpoi.json | 6 +- .../exampleitems.examplenightharvestpoi.json | 6 +- .../Harvest/exampleitems.mcpufferfishpoi.json | 6 +- .../Harvest/exampleitems.mctropicalpoi.json | 6 +- .../exampleitems.rainbowfiddlercrabpoi.json | 6 +- Winch.Examples/ExampleItems/Loader.cs | 2 + Winch/Components/ModdedAutoMovePOI.cs | 32 ++++ Winch/Core/AssetLoader.cs | 11 +- Winch/Patches/API/PlayerPatcher.cs | 1 + .../Conversation/ConversationPOIConverter.cs | 26 --- .../POI/Conversation/CustomAutoMovePOI.cs | 35 ++++ .../CustomAutoMovePOIConverter.cs | 20 ++ .../POI/Conversation/CustomConversationPOI.cs | 36 ++++ .../CustomConversationPOIConverter.cs | 25 +++ .../POI/Conversation/CustomExplosivePOI.cs | 15 ++ ...rter.cs => CustomExplosivePOIConverter.cs} | 13 +- .../POI/Conversation/CustomInspectPOI.cs | 11 ++ .../Conversation/CustomInspectPOIConverter.cs | 5 + .../POI/Conversation/ExplosivePOIConverter.cs | 21 -- .../POI/Conversation/InspectPOIConverter.cs | 5 - Winch/Serialization/POI/CustomPOI.cs | 12 ++ Winch/Serialization/POI/CustomPOIConverter.cs | 2 + Winch/Serialization/POI/Dock/CustomDockPOI.cs | 15 ++ .../POI/Dock/CustomDockPOIConverter.cs | 19 ++ Winch/Serialization/POI/DockPOIConverter.cs | 19 -- Winch/Util/PoiUtil.cs | 181 ++++++++++++++++-- 31 files changed, 462 insertions(+), 134 deletions(-) create mode 100644 Winch.Examples/ExampleItems/Assets/POI/Conversation/AutoMove/exampleitems.automove.json create mode 100644 Winch.Examples/ExampleItems/Assets/POI/Conversation/Explosive/exampleitems.explosive.json create mode 100644 Winch.Examples/ExampleItems/Assets/POI/Conversation/Inspect/exampleitems.inspect.json create mode 100644 Winch.Examples/ExampleItems/Assets/POI/Dock/exampleitems.dock.json create mode 100644 Winch/Components/ModdedAutoMovePOI.cs delete mode 100644 Winch/Serialization/POI/Conversation/ConversationPOIConverter.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomAutoMovePOI.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomAutoMovePOIConverter.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomConversationPOI.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomConversationPOIConverter.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomExplosivePOI.cs rename Winch/Serialization/POI/Conversation/{AutoMovePOIConverter.cs => CustomExplosivePOIConverter.cs} (50%) create mode 100644 Winch/Serialization/POI/Conversation/CustomInspectPOI.cs create mode 100644 Winch/Serialization/POI/Conversation/CustomInspectPOIConverter.cs delete mode 100644 Winch/Serialization/POI/Conversation/ExplosivePOIConverter.cs delete mode 100644 Winch/Serialization/POI/Conversation/InspectPOIConverter.cs create mode 100644 Winch/Serialization/POI/Dock/CustomDockPOI.cs create mode 100644 Winch/Serialization/POI/Dock/CustomDockPOIConverter.cs delete mode 100644 Winch/Serialization/POI/DockPOIConverter.cs diff --git a/Winch.Examples/ExampleItems/Assets/POI/Conversation/AutoMove/exampleitems.automove.json b/Winch.Examples/ExampleItems/Assets/POI/Conversation/AutoMove/exampleitems.automove.json new file mode 100644 index 00000000..f5232197 --- /dev/null +++ b/Winch.Examples/ExampleItems/Assets/POI/Conversation/AutoMove/exampleitems.automove.json @@ -0,0 +1,20 @@ +{ + "location": { + "x": 375, + "y": 0, + "z": -344 + }, + "conversationNodeName": "ExampleItems_Alex_Root", + "isOneTimeOnly": "false", + "autoMovePosition": { + "x": 0, + "y": 0, + "z": 0 + }, + "autoMoveRotation": { + "x": 0, + "y": 45, + "z": 0 + }, + "includeRotation": "true" +} \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Conversation/Explosive/exampleitems.explosive.json b/Winch.Examples/ExampleItems/Assets/POI/Conversation/Explosive/exampleitems.explosive.json new file mode 100644 index 00000000..0f74ea26 --- /dev/null +++ b/Winch.Examples/ExampleItems/Assets/POI/Conversation/Explosive/exampleitems.explosive.json @@ -0,0 +1,14 @@ +{ + "location": { + "x": 370.0, + "y": 0.0, + "z": -334.0 + }, + "conversationNodeName": "Explosives_Root", + "isOneTimeOnly": "false", + "vCam": { + "x": -4.5, + "y": 7.5, + "z": 10 + } +} \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Conversation/Inspect/exampleitems.inspect.json b/Winch.Examples/ExampleItems/Assets/POI/Conversation/Inspect/exampleitems.inspect.json new file mode 100644 index 00000000..969a232b --- /dev/null +++ b/Winch.Examples/ExampleItems/Assets/POI/Conversation/Inspect/exampleitems.inspect.json @@ -0,0 +1,9 @@ +{ + "location": { + "x": 366.0, + "y": 0.0, + "z": -344.0 + }, + "conversationNodeName": "ExampleItems_Steve_Root", + "isOneTimeOnly": "false" +} \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Dock/exampleitems.dock.json b/Winch.Examples/ExampleItems/Assets/POI/Dock/exampleitems.dock.json new file mode 100644 index 00000000..20099b61 --- /dev/null +++ b/Winch.Examples/ExampleItems/Assets/POI/Dock/exampleitems.dock.json @@ -0,0 +1,7 @@ +{ + "location": { + "x": 362.0, + "y": 0.0, + "z": -344.0 + } +} \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampledredgeharvestpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampledredgeharvestpoi.json index cfc1adcf..5ae609e3 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampledredgeharvestpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampledredgeharvestpoi.json @@ -7,12 +7,8 @@ "harvestableParticlePrefab": "TrinketParticles", "items": [ "exampleitems.diamond" ], "nightItems": [ "exampleitems.musicdisc" ], - "startStock": 3, - "maxStock": 5, + "startStock": 1, + "maxStock": 2, "doesRestock": true, - "usesTimeSpecificStock": true, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": true } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampleharvestpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampleharvestpoi.json index ffca64a5..cbc61765 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampleharvestpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.exampleharvestpoi.json @@ -9,9 +9,5 @@ "startStock": 5, "maxStock": 10, "doesRestock": true, - "usesTimeSpecificStock": false, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": false } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.examplenightharvestpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.examplenightharvestpoi.json index 88222135..510726f2 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.examplenightharvestpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.examplenightharvestpoi.json @@ -10,9 +10,5 @@ "startStock": 3, "maxStock": 5, "doesRestock": true, - "usesTimeSpecificStock": true, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": true } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mcpufferfishpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mcpufferfishpoi.json index 2a8b7ec6..0118c302 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mcpufferfishpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mcpufferfishpoi.json @@ -10,9 +10,5 @@ "startStock": 5, "maxStock": 10, "doesRestock": true, - "usesTimeSpecificStock": true, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": true } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mctropicalpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mctropicalpoi.json index 8241cfc7..1a9326a2 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mctropicalpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.mctropicalpoi.json @@ -10,9 +10,5 @@ "startStock": 5, "maxStock": 10, "doesRestock": true, - "usesTimeSpecificStock": true, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": true } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.rainbowfiddlercrabpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.rainbowfiddlercrabpoi.json index 634fe48d..b79c61f0 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.rainbowfiddlercrabpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Harvest/exampleitems.rainbowfiddlercrabpoi.json @@ -9,9 +9,5 @@ "startStock": 1, "maxStock": 3, "doesRestock": true, - "usesTimeSpecificStock": false, - "overrideDefaultDaySpecialChance": true, - "overriddenDaytimeSpecialChance": 0.5, - "overrideDefaultNightSpecialChance": true, - "overriddenNighttimeSpecialChance": 0.5 + "usesTimeSpecificStock": false } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Loader.cs b/Winch.Examples/ExampleItems/Loader.cs index 0a3f2693..e6ce4f57 100644 --- a/Winch.Examples/ExampleItems/Loader.cs +++ b/Winch.Examples/ExampleItems/Loader.cs @@ -96,6 +96,8 @@ private static GameObject CreateCube() private static void OnGameStarted() { + GameManager.Instance.SaveData.SetBoolVariable("exampleitems.explosive-detonated", val: false); // for testing + GameEvents.Instance.OnSpecialItemHandlerRequested += OnSpecialItemHandlerRequested; try diff --git a/Winch/Components/ModdedAutoMovePOI.cs b/Winch/Components/ModdedAutoMovePOI.cs new file mode 100644 index 00000000..ad101e47 --- /dev/null +++ b/Winch/Components/ModdedAutoMovePOI.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Winch.Core; + +namespace Winch.Components +{ + public class ModdedAutoMovePOI : AutoMovePOI + { + [SerializeField] + public bool unlockPlayerMovementAfterConversationCompleted = true; + + public override void OnConversationCompleted() + { + base.OnConversationCompleted(); + if (unlockPlayerMovementAfterConversationCompleted) + { + UnlockPlayerMovement(); + } + } + + public void UnlockPlayerMovement() + { + WinchCore.Log.Debug("[ModdedAutoMovePOI] UnlockPlayerMovement()"); + GameManager.Instance.Player.Controller.ClearAutoMoveTarget(); + GameManager.Instance.Player.Controller.ClearAutoRotateTarget(); + } + } +} diff --git a/Winch/Core/AssetLoader.cs b/Winch/Core/AssetLoader.cs index 21637fdb..2c831f29 100644 --- a/Winch/Core/AssetLoader.cs +++ b/Winch/Core/AssetLoader.cs @@ -8,6 +8,8 @@ using Winch.Serialization.POI.Item; using Winch.Serialization.HarvestZone; using Winch.Data.Item; +using Winch.Serialization.POI.Conversation; +using Winch.Serialization.POI.Dock; namespace Winch.Core { @@ -97,11 +99,10 @@ private static void LoadAssetBundleFiles(string bundlesFolderpath) { { typeof(CustomHarvestPOI), "Harvest"}, { typeof(CustomItemPOI), "Item"}, - //{ typeof(BaitHarvestPOI), "Bait"}, - //{ typeof(PlacedHarvestPOI), "Placed"}, - //{ typeof(AutoMovePOI), "Conversation/AutoMove"}, - //{ typeof(ExplosivePOI), "Conversation/Explosive"}, - //{ typeof(InspectPOI), "Conversation/Inspect"} + { typeof(CustomDockPOI), "Dock"}, + { typeof(CustomAutoMovePOI), "Conversation/AutoMove"}, + { typeof(CustomExplosivePOI), "Conversation/Explosive"}, + { typeof(CustomInspectPOI), "Conversation/Inspect"} }; private static void LoadPoiFiles(string poiFolderPath) diff --git a/Winch/Patches/API/PlayerPatcher.cs b/Winch/Patches/API/PlayerPatcher.cs index 7e27768b..70badfd7 100644 --- a/Winch/Patches/API/PlayerPatcher.cs +++ b/Winch/Patches/API/PlayerPatcher.cs @@ -16,6 +16,7 @@ public static void Postfix(Player __instance) { AbilityUtil.AddModdedAbilitiesToPlayer(__instance.transform.Find("Abilities")); PoiUtil.PopulateHarvestablesAndHarvestParticlePrefabs(); + PoiUtil.PopulateConversationPois(); PoiUtil.CreateModdedPois(); HarvestZoneUtil.CreateModdedHarvestZones(); ItemUtil.Encyclopedia(); diff --git a/Winch/Serialization/POI/Conversation/ConversationPOIConverter.cs b/Winch/Serialization/POI/Conversation/ConversationPOIConverter.cs deleted file mode 100644 index 86304f55..00000000 --- a/Winch/Serialization/POI/Conversation/ConversationPOIConverter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -// ReSharper disable HeapView.BoxingAllocation - -namespace Winch.Serialization.POI.Conversation; - -public class ConversationPoiConverter : PoiConverter -{ - private readonly Dictionary _definitions = new() - { - { "conversationNodeName", new( null, null) }, - { "enabledByOtherNodeVisit", new( false, null) }, - { "enableNodeNames", new( null, null) }, - { "interactCollider", new( null, null) }, - { "isDueRefresh", new( false, null) }, - { "isOneTimeOnly", new( false, null) }, - { "otherNodeNames", new( null, null) }, - { "releaseCameraOnComplete", new( true, null) }, - { "shouldDisableOnOtherNodeVisit", new( false, null) }, - { "vCam", new( null, null) }, - }; - - public ConversationPoiConverter() - { - AddDefinitions(_definitions); - } -} diff --git a/Winch/Serialization/POI/Conversation/CustomAutoMovePOI.cs b/Winch/Serialization/POI/Conversation/CustomAutoMovePOI.cs new file mode 100644 index 00000000..935d91ee --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomAutoMovePOI.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomAutoMovePOI : CustomConversationPOI +{ + /// + /// Position to move the player's boat to, relative to this point of interest. + /// + [SerializeField] + public Vector3 autoMovePosition = Vector3.zero; + + /// + /// Whether to use + /// + [SerializeField] + public bool includeRotation = false; + + /// + /// Rotation to move the player's boat to, relative to this point of interest. + /// + [SerializeField] + public Vector3 autoMoveRotation = Vector3.zero; + + /// + /// Whether to unlock player movement after the dialogue ends + /// + [SerializeField] + public bool unlockPlayerMovementAfterConversationCompleted = true; +} diff --git a/Winch/Serialization/POI/Conversation/CustomAutoMovePOIConverter.cs b/Winch/Serialization/POI/Conversation/CustomAutoMovePOIConverter.cs new file mode 100644 index 00000000..95bb157f --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomAutoMovePOIConverter.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomAutoMovePOIConverter : CustomConversationPOIConverter +{ + private readonly Dictionary _definitions = new() + { + { "autoMovePosition", new(Vector3.zero, o=>DredgeTypeHelpers.ParseVector3(o)) }, + { "includeRotation", new(false, o=> bool.Parse(o.ToString())) }, + { "autoMoveRotation", new(Vector3.zero, o=>DredgeTypeHelpers.ParseVector3(o)) }, + { "unlockPlayerMovementAfterConversationCompleted", new(true, o=> bool.Parse(o.ToString())) }, + }; + + public CustomAutoMovePOIConverter() + { + AddDefinitions(_definitions); + } +} diff --git a/Winch/Serialization/POI/Conversation/CustomConversationPOI.cs b/Winch/Serialization/POI/Conversation/CustomConversationPOI.cs new file mode 100644 index 00000000..f33fee19 --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomConversationPOI.cs @@ -0,0 +1,36 @@ +using Cinemachine; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomConversationPOI : CustomPOI +{ + [SerializeField] + public bool isOneTimeOnly = true; + + [SerializeField] + public bool releaseCameraOnComplete = true; + + [SerializeField] + public string conversationNodeName = string.Empty; + + [SerializeField] + public bool enabledByOtherNodeVisit; + + [SerializeField] + public List enableNodeNames = new List(); + + [SerializeField] + public bool shouldDisableOnOtherNodeVisit; + + [SerializeField] + public List otherNodeNames = new List(); + + [SerializeField] + public Vector3 vCam; +} diff --git a/Winch/Serialization/POI/Conversation/CustomConversationPOIConverter.cs b/Winch/Serialization/POI/Conversation/CustomConversationPOIConverter.cs new file mode 100644 index 00000000..f41ccf30 --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomConversationPOIConverter.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using UnityEngine; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomConversationPOIConverter : CustomPOIConverter +{ + private readonly Dictionary _definitions = new() + { + { "conversationNodeName", new( string.Empty, null) }, + { "enabledByOtherNodeVisit", new( false, o=>bool.Parse(o.ToString())) }, + { "enableNodeNames", new( new List(), o=>DredgeTypeHelpers.ParseStringList((JArray)o)) }, + { "isOneTimeOnly", new( true, o=>bool.Parse(o.ToString())) }, + { "otherNodeNames", new( new List(), o=>DredgeTypeHelpers.ParseStringList((JArray)o)) }, + { "releaseCameraOnComplete", new( true, o=>bool.Parse(o.ToString())) }, + { "shouldDisableOnOtherNodeVisit", new( false, o=>bool.Parse(o.ToString())) }, + { "vCam", new( Vector3.one, o=>DredgeTypeHelpers.ParseVector3(o)) }, + }; + + public CustomConversationPOIConverter() + { + AddDefinitions(_definitions); + } +} diff --git a/Winch/Serialization/POI/Conversation/CustomExplosivePOI.cs b/Winch/Serialization/POI/Conversation/CustomExplosivePOI.cs new file mode 100644 index 00000000..1ce8118c --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomExplosivePOI.cs @@ -0,0 +1,15 @@ +using Cinemachine; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomExplosivePOI : CustomConversationPOI +{ + [SerializeField] + public string explodeVibration; +} diff --git a/Winch/Serialization/POI/Conversation/AutoMovePOIConverter.cs b/Winch/Serialization/POI/Conversation/CustomExplosivePOIConverter.cs similarity index 50% rename from Winch/Serialization/POI/Conversation/AutoMovePOIConverter.cs rename to Winch/Serialization/POI/Conversation/CustomExplosivePOIConverter.cs index 0dd2b022..6b199371 100644 --- a/Winch/Serialization/POI/Conversation/AutoMovePOIConverter.cs +++ b/Winch/Serialization/POI/Conversation/CustomExplosivePOIConverter.cs @@ -1,18 +1,19 @@ using System.Collections.Generic; -// ReSharper disable HeapView.BoxingAllocation - namespace Winch.Serialization.POI.Conversation; -public class AutoMovePoiConverter : ConversationPoiConverter +// ReSharper disable HeapView.BoxingAllocation + +public class CustomExplosivePOIConverter : CustomConversationPOIConverter { private readonly Dictionary _definitions = new() { - { "autoMoveDestination", new( null, null) }, - { "includeRotation", new( false, null) }, + { "conversationNodeName", new("Explosives_Root", null) }, + { "isOneTimeOnly", new(false, null) }, + { "explodeVibration", new(string.Empty, null) }, }; - public AutoMovePoiConverter() + public CustomExplosivePOIConverter() { AddDefinitions(_definitions); } diff --git a/Winch/Serialization/POI/Conversation/CustomInspectPOI.cs b/Winch/Serialization/POI/Conversation/CustomInspectPOI.cs new file mode 100644 index 00000000..232b9ad7 --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomInspectPOI.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Winch.Serialization.POI.Conversation; + +public class CustomInspectPOI : CustomConversationPOI +{ +} diff --git a/Winch/Serialization/POI/Conversation/CustomInspectPOIConverter.cs b/Winch/Serialization/POI/Conversation/CustomInspectPOIConverter.cs new file mode 100644 index 00000000..f8d221c6 --- /dev/null +++ b/Winch/Serialization/POI/Conversation/CustomInspectPOIConverter.cs @@ -0,0 +1,5 @@ +namespace Winch.Serialization.POI.Conversation; + +public class CustomInspectPOIConverter : CustomConversationPOIConverter +{ +} diff --git a/Winch/Serialization/POI/Conversation/ExplosivePOIConverter.cs b/Winch/Serialization/POI/Conversation/ExplosivePOIConverter.cs deleted file mode 100644 index 147bf3f6..00000000 --- a/Winch/Serialization/POI/Conversation/ExplosivePOIConverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace Winch.Serialization.POI.Conversation; - -// ReSharper disable HeapView.BoxingAllocation - -public class ExplosivePoiConverter : ConversationPoiConverter -{ - private readonly Dictionary _definitions = new() - { - { "animator", new( null, null) }, - { "ExplodeVibration", new( null, null) }, - { "id", new( null, null) }, - { "impulseSource", new( null, null) }, - }; - - public ExplosivePoiConverter() - { - AddDefinitions(_definitions); - } -} diff --git a/Winch/Serialization/POI/Conversation/InspectPOIConverter.cs b/Winch/Serialization/POI/Conversation/InspectPOIConverter.cs deleted file mode 100644 index 8980fade..00000000 --- a/Winch/Serialization/POI/Conversation/InspectPOIConverter.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Winch.Serialization.POI.Conversation; - -public class InspectPoiConverter : ConversationPoiConverter -{ -} diff --git a/Winch/Serialization/POI/CustomPOI.cs b/Winch/Serialization/POI/CustomPOI.cs index 2c0e0639..86f9bbf0 100644 --- a/Winch/Serialization/POI/CustomPOI.cs +++ b/Winch/Serialization/POI/CustomPOI.cs @@ -26,6 +26,18 @@ public class CustomPOI : SerializedScriptableObject /// [SerializeField] public bool canBeGhostWindTarget; + + /// + /// Ghost wind target relative position + /// + [SerializeField] + public Vector3 ghostWindTarget = Vector3.zero; + + /// + /// Interact point UI relative position + /// + [SerializeField] + public Vector3 interactPointTarget = Vector3.zero; } diff --git a/Winch/Serialization/POI/CustomPOIConverter.cs b/Winch/Serialization/POI/CustomPOIConverter.cs index 78615bb7..6dddd289 100644 --- a/Winch/Serialization/POI/CustomPOIConverter.cs +++ b/Winch/Serialization/POI/CustomPOIConverter.cs @@ -12,6 +12,8 @@ public class CustomPOIConverter : DredgeTypeConverter { "id", new( string.Empty, null) }, { "location", new( Vector3.zero, o=> DredgeTypeHelpers.ParseVector3(o)) }, { "canBeGhostWindTarget", new( false, o=> bool.Parse(o.ToString())) }, + { "ghostWindTarget", new( Vector3.zero, o=> DredgeTypeHelpers.ParseVector3(o)) }, + { "interactPointTarget", new( Vector3.zero, o=> DredgeTypeHelpers.ParseVector3(o)) } }; public CustomPOIConverter() diff --git a/Winch/Serialization/POI/Dock/CustomDockPOI.cs b/Winch/Serialization/POI/Dock/CustomDockPOI.cs new file mode 100644 index 00000000..bc4f5b5a --- /dev/null +++ b/Winch/Serialization/POI/Dock/CustomDockPOI.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace Winch.Serialization.POI.Dock; + +// TODO: actually implement this +public class CustomDockPOI : CustomPOI +{ + [SerializeField] + public List dockSlots = new List(); +} diff --git a/Winch/Serialization/POI/Dock/CustomDockPOIConverter.cs b/Winch/Serialization/POI/Dock/CustomDockPOIConverter.cs new file mode 100644 index 00000000..2fa0b374 --- /dev/null +++ b/Winch/Serialization/POI/Dock/CustomDockPOIConverter.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Winch.Serialization.POI.Dock; + +public class CustomDockPOIConverter : CustomPOIConverter +{ + private readonly Dictionary _definitions = new() + { + { "dockSlots", new( new List(), o=>DredgeTypeHelpers.ParseVector3Array((JArray)o) ) }, + }; + + public CustomDockPOIConverter() + { + AddDefinitions(_definitions); + } +} diff --git a/Winch/Serialization/POI/DockPOIConverter.cs b/Winch/Serialization/POI/DockPOIConverter.cs deleted file mode 100644 index 62e640f7..00000000 --- a/Winch/Serialization/POI/DockPOIConverter.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace Winch.Serialization.POI; - -public class DockPoiConverter : PoiConverter -{ - private readonly Dictionary _definitions = new() - { - { "dock", new( null, null) }, - { "dockSlots", new( Array.Empty(), null) }, - }; - - public DockPoiConverter() - { - AddDefinitions(_definitions); - } -} diff --git a/Winch/Util/PoiUtil.cs b/Winch/Util/PoiUtil.cs index df35c2ae..50896f8b 100644 --- a/Winch/Util/PoiUtil.cs +++ b/Winch/Util/PoiUtil.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.IO; using System.Linq; +using Cinemachine; using HarmonyLib; using UnityEngine; using UnityEngine.AddressableAssets; @@ -13,6 +14,7 @@ using Winch.Serialization.POI; using Winch.Serialization.POI.Conversation; +using Winch.Serialization.POI.Dock; using Winch.Serialization.POI.Harvest; using Winch.Serialization.POI.Item; @@ -22,11 +24,10 @@ public static class PoiUtil { private static Dictionary Converters = new() { - //{ typeof(DockPOI), new DockPoiConverter() }, - //{ typeof(ConversationPOI), new ConversationPoiConverter() }, - //{ typeof(AutoMovePOI), new AutoMovePoiConverter() }, - //{ typeof(ConversationPOI), new ConversationPoiConverter() }, - //{ typeof(ExplosivePOI), new ExplosivePoiConverter() }, + { typeof(CustomDockPOI), new CustomDockPOIConverter() }, + { typeof(CustomAutoMovePOI), new CustomAutoMovePOIConverter() }, + { typeof(CustomInspectPOI), new CustomInspectPOIConverter() }, + { typeof(CustomExplosivePOI), new CustomExplosivePOIConverter() }, { typeof(CustomHarvestPOI), new CustomHarvestPOIConverter()}, { typeof(CustomItemPOI), new CustomItemPOIConverter()} }; @@ -167,16 +168,35 @@ internal static void CreateModdedPois() { return CreateGameObjectFromCustomItemPoi(customItemPoi); } + else if (customPoi is CustomConversationPOI customConversationPoi) + { + return CreateGameObjectFromCustomConversationPoi(customConversationPoi); + } + + return null; + } + + internal static GameObject? CreateGameObjectFromCustomConversationPoi(CustomConversationPOI customConversationPoi) + { + if (customConversationPoi is CustomInspectPOI customInspectPoi) + { + return CreateGameObjectFromCustomInspectPoi(customInspectPoi); + } + else if (customConversationPoi is CustomAutoMovePOI customAutoMovePoi) + { + return CreateGameObjectFromCustomAutoMovePoi(customAutoMovePoi); + } + else if (customConversationPoi is CustomExplosivePOI customExplosivePoi) + { + return CreateGameObjectFromCustomExplosivePoi(customExplosivePoi); + } return null; } internal static GameObject CreateGameObjectFromCustomHarvestPoi(CustomHarvestPOI customHarvestPoi) { - GameObject customPoi = new GameObject(customHarvestPoi.id); - customPoi.transform.SetParent(GameSceneInitializer.Instance.HarvestPoiContainer.transform); - customPoi.transform.position = customHarvestPoi.location; - var harvestPoi = customPoi.AddComponent(); + (GameObject customPoi, HarvestPOI harvestPoi) = CreateGenericPoiFromCustomPoi(customHarvestPoi, GameSceneInitializer.Instance.HarvestPoiContainer.transform); var harvestPoiDataModel = new HarvestPOIDataModel(); harvestPoiDataModel.doesRestock = customHarvestPoi.doesRestock; @@ -199,8 +219,6 @@ internal static GameObject CreateGameObjectFromCustomHarvestPoi(CustomHarvestPOI harvestPoi.harvestParticlePrefab = customHarvestPoi.HarvestableParticlePrefab; - harvestPoi.canBeGhostWindTarget = customHarvestPoi.canBeGhostWindTarget; - // Default Harvest POI Sphere Collider var sphereCollider = customPoi.AddComponent(); sphereCollider.radius = 2; @@ -218,17 +236,12 @@ internal static GameObject CreateGameObjectFromCustomHarvestPoi(CustomHarvestPOI customPoi.AddComponent(); GameManager.Instance.HarvestPOIManager.allHarvestPOIs.Add(harvestPoi); - - customPoi.layer = Layer.POI; return customPoi; } internal static GameObject CreateGameObjectFromCustomItemPoi(CustomItemPOI customItemPoi) { - GameObject customPoi = new GameObject(customItemPoi.id); - customPoi.transform.SetParent(GameSceneInitializer.Instance.HarvestPoiContainer.transform); - customPoi.transform.position = customItemPoi.location; - var itemPoi = customPoi.AddComponent(); + (GameObject customPoi, ParticledItemPOI itemPoi) = CreateGenericPoiFromCustomPoi(customItemPoi, GameSceneInitializer.Instance.HarvestPoiContainer.transform); var itemPoiDataModel = new ItemPOIDataModel(); @@ -241,8 +254,6 @@ internal static GameObject CreateGameObjectFromCustomItemPoi(CustomItemPOI custo itemPoi.harvestParticlePrefab = customItemPoi.HarvestableParticlePrefab; - itemPoi.canBeGhostWindTarget = customItemPoi.canBeGhostWindTarget; - // Default Harvest POI Sphere Collider var sphereCollider = customPoi.AddComponent(); sphereCollider.radius = 2; @@ -272,11 +283,129 @@ internal static GameObject CreateGameObjectFromCustomItemPoi(CustomItemPOI custo itemPoi.intermittentSFXPlayer = sfx; GameManager.Instance.HarvestPOIManager.allItemPOIs.Add(itemPoi); + return customPoi; + } + + internal static GameObject CreateGameObjectFromCustomInspectPoi(CustomInspectPOI customInspectPoi) + { + (GameObject customPoi, InspectPOI inspectPoi) = CreateGenericPoiFromCustomConversationPoi(customInspectPoi); - customPoi.layer = Layer.POI; return customPoi; } + internal static GameObject CreateGameObjectFromCustomAutoMovePoi(CustomAutoMovePOI customAutoMovePoi) + { + (GameObject customPoi, ModdedAutoMovePOI autoMovePoi) = CreateGenericPoiFromCustomConversationPoi(customAutoMovePoi); + + var autoMoveDestination = new GameObject("AutoMoveDestination"); + autoMoveDestination.transform.SetParent(customPoi.transform); + autoMoveDestination.transform.localPosition = customAutoMovePoi.autoMovePosition; + autoMoveDestination.transform.localEulerAngles = customAutoMovePoi.autoMoveRotation; + + autoMovePoi.autoMoveDestination = autoMoveDestination.transform; + autoMovePoi.includeRotation = customAutoMovePoi.includeRotation; + autoMovePoi.unlockPlayerMovementAfterConversationCompleted = customAutoMovePoi.unlockPlayerMovementAfterConversationCompleted; + + return customPoi; + } + + internal static GameObject CreateGameObjectFromCustomExplosivePoi(CustomExplosivePOI customExplosivePoi) + { + (GameObject customPoi, ExplosivePOI explosivePoi) = CreateGenericPoiFromCustomConversationPoi(customExplosivePoi, false, 2); + + explosivePoi.id = customExplosivePoi.id; + explosivePoi.animator = customPoi.AddComponent(); + explosivePoi.impulseSource = customPoi.AddComponent(); + explosivePoi.impulseSource.m_ImpulseDefinition = new CinemachineImpulseDefinition(); + explosivePoi.impulseSource.m_ImpulseDefinition.m_AmplitudeGain = 5; + explosivePoi.impulseSource.m_ImpulseDefinition.m_FrequencyGain = 5; + explosivePoi.impulseSource.m_ImpulseDefinition.m_RawSignal = _6DShake; + explosivePoi.ExplodeVibration = ExplodingWalls; + + var collider = (SphereCollider)explosivePoi.interactCollider; + collider.radius = 7; + explosivePoi.interactCollider = null; + explosivePoi.canBeGhostWindTarget = false; + + return customPoi; + } + + internal static (GameObject, T) CreateGenericPoiFromCustomConversationPoi(CustomConversationPOI customConversationPoi, bool isCullable = true, float glintHeight = 1) where T : ConversationPOI + { + (GameObject customPoi, T poi) = CreateGenericPoiFromCustomPoi(customConversationPoi, InspectPoiContainer.transform); + + poi.isOneTimeOnly = customConversationPoi.isOneTimeOnly; + poi.releaseCameraOnComplete = customConversationPoi.releaseCameraOnComplete; + poi.conversationNodeName = customConversationPoi.conversationNodeName; + poi.enabledByOtherNodeVisit = customConversationPoi.enabledByOtherNodeVisit; + poi.enableNodeNames = customConversationPoi.enableNodeNames; + poi.shouldDisableOnOtherNodeVisit = customConversationPoi.shouldDisableOnOtherNodeVisit; + poi.otherNodeNames = customConversationPoi.otherNodeNames; + + var glint = InspectionGlint.Instantiate(customPoi.transform, false); + glint.transform.localPosition = new Vector3(0, glintHeight, 0); + + var vcamObject = new GameObject("InspectPOI_VCam"); + vcamObject.transform.SetParent(customPoi.transform); + vcamObject.transform.localPosition = customConversationPoi.vCam; + vcamObject.SetActive(false); + var vcam = vcamObject.AddComponent(); + vcam.LookAt = customPoi.transform; + vcam.AddExtension(vcamObject.AddComponent()); + vcam.AddExtension(vcamObject.AddComponent()); + vcam.AddCinemachineComponent(); + vcamObject.AddComponent(); + poi.vCam = vcam; + + // Default Harvest POI Sphere Collider + var sphereCollider = customPoi.AddComponent(); + sphereCollider.radius = 5; + sphereCollider.enabled = true; + sphereCollider.contactOffset = 0.01f; + + poi.interactCollider = sphereCollider; + + if (isCullable) + { + // This needs to be added to the GameManager.Instance.CullingBrain + var cullable = customPoi.AddComponent(); + cullable.cullingGroupType = CullingGroupType.STATIC_SHORT_RANGE; + cullable.sphereRadius = 15; + GameManager.Instance.CullingBrain.AddCullable(cullable); + } + + return (customPoi, poi); + } + + internal static (GameObject, T) CreateGenericPoiFromCustomPoi(CustomPOI customPoi, Transform parent) where T : POI + { + GameObject customPoiObject = new GameObject(customPoi.id); + customPoiObject.transform.SetParent(parent); + customPoiObject.transform.position = customPoi.location; + var poi = customPoiObject.AddComponent(); + + poi.canBeGhostWindTarget = customPoi.canBeGhostWindTarget; + + if (customPoi.ghostWindTarget != Vector3.zero) + { + GameObject ghostWindTarget = new GameObject("GhostWindTarget"); + ghostWindTarget.transform.SetParent(customPoiObject.transform); + ghostWindTarget.transform.localPosition = customPoi.ghostWindTarget; + poi.ghostWindTargetTransform = ghostWindTarget.transform; + } + + if (customPoi.interactPointTarget != Vector3.zero) + { + GameObject interactPointTarget = new GameObject("InteractionUITransform"); + interactPointTarget.transform.SetParent(customPoiObject.transform); + interactPointTarget.transform.localPosition = customPoi.interactPointTarget; + poi.interactPointTargetTransform = interactPointTarget.transform; + } + + customPoiObject.layer = Layer.POI; + return (customPoiObject, poi); + } + internal static void AddCustomPoiFromMeta(string metaPath) where T : CustomPOI { var meta = UtilHelpers.ParseMeta(metaPath); @@ -307,4 +436,16 @@ internal static void AddCustomPoiFromMeta(string metaPath) where T : CustomPO } } + internal static GameObject InspectPoiContainer; + internal static GameObject InspectionGlint; + internal static VibrationData ExplodingWalls; + internal static NoiseSettings _6DShake; + + internal static void PopulateConversationPois() + { + InspectPoiContainer = GameObject.FindObjectOfType().gameObject; + if (InspectionGlint == null) InspectionGlint = Resources.FindObjectsOfTypeAll().FirstOrDefault(psr => psr.name == "InspectionGlint").gameObject.CopyPrefab(); + if (ExplodingWalls == null) ExplodingWalls = Resources.FindObjectsOfTypeAll().FirstOrDefault(vd => vd.name == "ExplodingWalls").DontDestroyOnLoad(); + if (_6DShake == null) _6DShake = Resources.FindObjectsOfTypeAll().FirstOrDefault(vd => vd.name == "6D Shake").DontDestroyOnLoad(); + } }