Skip to content

Commit

Permalink
add intermittent sfx to item poi
Browse files Browse the repository at this point in the history
almost forgot
  • Loading branch information
MegaPiggy committed Sep 27, 2024
1 parent 8ec33c4 commit faf3b68
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
4 changes: 4 additions & 0 deletions Winch/Data/POI/Item/CustomItemPOI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.AddressableAssets;
using Winch.Util;

namespace Winch.Data.POI.Item;
Expand All @@ -25,6 +26,9 @@ public class CustomItemPOI : CustomPOI
[SerializeField]
public bool cullable = true;

[SerializeField]
public List<AssetReference> intermittentSFX = new List<AssetReference>();

/// <summary>
/// <see cref="items"/> converted to actual items
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion Winch/Serialization/POI/Item/CustomItemPOIConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using UnityEngine.AddressableAssets;

// ReSharper disable HeapView.BoxingAllocation

Expand All @@ -11,7 +12,8 @@ public class CustomItemPOIConverter : CustomPOIConverter
{
{ "harvestableParticlePrefab", new( null, null) },
{ "items", new( new List<string>(), 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<AssetReference>(), o => DredgeTypeHelpers.ParseAudioReferences((JArray)o) ) }
};

public CustomItemPOIConverter()
Expand Down
2 changes: 1 addition & 1 deletion Winch/Util/PoiUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ internal static GameObject CreateGameObjectFromCustomItemPoi(CustomItemPOI custo
}

var sfx = customPoi.AddComponent<IntermittentSFXPlayer>();
sfx.assetReferences = new List<AssetReference>();
sfx.assetReferences = customItemPoi.intermittentSFX;
sfx.audioMixerGroup = Resources.FindObjectsOfTypeAll<AudioMixerGroup>().FirstOrDefault(amg => amg.name == "WorldSFX");
sfx.audioRolloffMode = AudioRolloffMode.Linear;
sfx.volumeScale = 1;
Expand Down

0 comments on commit faf3b68

Please sign in to comment.