diff --git a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplebookpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplebookpoi.json index b03b1837..661c08d7 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplebookpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplebookpoi.json @@ -5,5 +5,9 @@ "z": -290.0 }, "harvestableParticlePrefab" : "MessageItem", - "items": ["exampleitems.book"] + "items": ["exampleitems.book"], + "intermittentSFX": [ + "POI - Message in Bottle 1", + "POI - Message in Bottle 2" + ] } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplejournalpoi.json b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplejournalpoi.json index fdf7881b..b7318837 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplejournalpoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplejournalpoi.json @@ -5,5 +5,9 @@ "z": -290.0 }, "harvestableParticlePrefab" : "MessageItem", - "items": ["exampleitems.journal"] + "items": ["exampleitems.journal"], + "intermittentSFX": [ + "POI - Message in Bottle 1", + "POI - Message in Bottle 2" + ] } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplemessagepoi.json b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplemessagepoi.json index a03b7a74..8e1c90f6 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplemessagepoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplemessagepoi.json @@ -5,5 +5,9 @@ "z": -285.0 }, "harvestableParticlePrefab" : "MessageItem", - "items": ["exampleitems.message"] + "items": ["exampleitems.message"], + "intermittentSFX": [ + "POI - Message in Bottle 1", + "POI - Message in Bottle 2" + ] } \ No newline at end of file diff --git a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplenotepoi.json b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplenotepoi.json index 687529cd..38494941 100644 --- a/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplenotepoi.json +++ b/Winch.Examples/ExampleItems/Assets/POI/Item/exampleitems.examplenotepoi.json @@ -5,5 +5,9 @@ "z": -300.0 }, "harvestableParticlePrefab" : "MessageItem", - "items": ["exampleitems.note"] + "items": ["exampleitems.note"], + "intermittentSFX": [ + "POI - Message in Bottle 1", + "POI - Message in Bottle 2" + ] } \ No newline at end of file diff --git a/Winch/Data/POI/Item/CustomItemPOI.cs b/Winch/Data/POI/Item/CustomItemPOI.cs index eb3a9d39..2e6f0eb5 100644 --- a/Winch/Data/POI/Item/CustomItemPOI.cs +++ b/Winch/Data/POI/Item/CustomItemPOI.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using UnityEngine; +using UnityEngine.AddressableAssets; using Winch.Util; namespace Winch.Data.POI.Item; @@ -25,6 +26,9 @@ public class CustomItemPOI : CustomPOI [SerializeField] public bool cullable = true; + [SerializeField] + public List intermittentSFX = new List(); + /// /// converted to actual items /// diff --git a/Winch/Serialization/POI/Item/CustomItemPOIConverter.cs b/Winch/Serialization/POI/Item/CustomItemPOIConverter.cs index 217d43a7..0587b038 100644 --- a/Winch/Serialization/POI/Item/CustomItemPOIConverter.cs +++ b/Winch/Serialization/POI/Item/CustomItemPOIConverter.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Newtonsoft.Json.Linq; +using UnityEngine.AddressableAssets; // ReSharper disable HeapView.BoxingAllocation @@ -11,7 +12,8 @@ public class CustomItemPOIConverter : CustomPOIConverter { { "harvestableParticlePrefab", new( null, null) }, { "items", new( new List(), o => DredgeTypeHelpers.ParseStringList((JArray)o)) }, - { "cullable", new( true, o => bool.Parse(o.ToString())) } + { "cullable", new( true, o => bool.Parse(o.ToString())) }, + { "intermittentSFX", new( new List(), o => DredgeTypeHelpers.ParseAudioReferences((JArray)o) ) } }; public CustomItemPOIConverter() diff --git a/Winch/Util/PoiUtil.cs b/Winch/Util/PoiUtil.cs index ea031f21..f3f8db63 100644 --- a/Winch/Util/PoiUtil.cs +++ b/Winch/Util/PoiUtil.cs @@ -340,7 +340,7 @@ internal static GameObject CreateGameObjectFromCustomItemPoi(CustomItemPOI custo } var sfx = customPoi.AddComponent(); - sfx.assetReferences = new List(); + sfx.assetReferences = customItemPoi.intermittentSFX; sfx.audioMixerGroup = Resources.FindObjectsOfTypeAll().FirstOrDefault(amg => amg.name == "WorldSFX"); sfx.audioRolloffMode = AudioRolloffMode.Linear; sfx.volumeScale = 1;