Files
zzz_REBIRTH__Utils/Harmony/Harmony_PlayerTracker.cs
2025-06-04 16:44:53 +09:30

54 lines
1.9 KiB
C#

using DynamicMusic;
using MusicUtils.Enums;
using System.Collections.Generic;
namespace Harmony.PlayerTrackerPatches
{
[HarmonyPatch(typeof(PlayerTracker))]
[HarmonyPatch("determineTrader")]
public class determineTraderPatch
{
public static bool Prefix(PlayerTracker __instance, ref SectionType __result,
List<Entity> ___npcs,
Vector3 ___boundingBoxRange
)
{
___npcs.Clear();
GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityTrader), new Bounds(GameManager.Instance.World.GetPrimaryPlayer().position, ___boundingBoxRange), ___npcs);
if (___npcs.Count > 0)
{
EntityTrader entityTrader = ___npcs[0] as EntityTrader;
if (entityTrader != null)
{
string npcID = entityTrader.npcID;
if (npcID == "traitorjoel")
{
__result = SectionType.TraderJoel;
}
if (npcID == "traderjen")
{
__result = SectionType.TraderJen;
}
if (npcID == "traderbob")
{
__result = SectionType.TraderBob;
}
if (npcID == "traderhugh")
{
__result = SectionType.TraderHugh;
}
if (npcID == "traderrekt")
{
__result = SectionType.TraderRekt;
}
//Log.Warning(entityTrader.npcID + " is not a known trader name to DMS");
return false;
}
}
__result = SectionType.None;
return false;
}
}
}