36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
|
|
namespace Harmony.CompanionGroupPatches
|
|
{
|
|
[HarmonyPatch(typeof(CompanionGroup))]
|
|
[HarmonyPatch("Remove")]
|
|
public class RemovePatch
|
|
{
|
|
public static bool Prefix(CompanionGroup __instance, EntityAlive entity)
|
|
{
|
|
//Log.Out("CompanionGroupPatches-Remove START, entity.entityId: " + entity.entityId);
|
|
//__instance.MemberList.Remove(entity);
|
|
|
|
for (int i = 0; i < __instance.MemberList.Count; i++)
|
|
{
|
|
//Log.Out("CompanionGroupPatches-Remove i: " + i);
|
|
//Log.Out("CompanionGroupPatches-Remove __instance.MemberList[" + i + "].entityId: " + __instance.MemberList[i].entityId);
|
|
if (__instance.MemberList[i].entityId == entity.entityId)
|
|
{
|
|
//Log.Out("CompanionGroupPatches-Remove REMOVE");
|
|
__instance.MemberList.RemoveAt(i);
|
|
break;
|
|
}
|
|
}
|
|
|
|
OnCompanionGroupChanged onGroupChanged = __instance.OnGroupChanged;
|
|
if (onGroupChanged == null)
|
|
{
|
|
return false;
|
|
}
|
|
onGroupChanged();
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|