Skip to content

Commit

Permalink
memorize tests and optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Priscillalala committed Dec 29, 2023
1 parent f0a65f7 commit b37d4f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R2API.ProcType/ProcTypeAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public static void AddModdedProc(ref this ProcChainMask procChainMask, ModdedPro
bool[] value;
if (mask != null)
{
if (ArrayUtils.GetSafe(mask, (int)procType))
{
return;
}
value = new bool[Math.Max(mask.Length, (int)procType + 1)];
Array.Copy(mask, value, mask.Length);
}
Expand All @@ -89,7 +93,7 @@ public static void RemoveModdedProc(ref this ProcChainMask procChainMask, Modded
}
SetHooks();
bool[] mask = ProcTypeInterop.GetModdedMask(procChainMask);
if (mask != null && ArrayUtils.IsInBounds(mask, (int)procType))
if (mask != null && ArrayUtils.GetSafe(mask, (int)procType))
{
mask = ArrayUtils.Clone(mask);
mask[(int)procType] = false;
Expand Down
28 changes: 28 additions & 0 deletions R2API.ProcType/ProcTypePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@ public sealed class ProcTypePlugin : BaseUnityPlugin
private void Awake()
{
Logger = base.Logger;
ModdedProcType a = ProcTypeAPI.ReserveProcType();
ModdedProcType b = ProcTypeAPI.ReserveProcType();
ModdedProcType c = ProcTypeAPI.ReserveProcType();
ProcTypeAPI.ReserveProcType();
ProcTypeAPI.ReserveProcType();
ProcTypeAPI.ReserveProcType();
RoR2.ProcChainMask procChainMask = default;
Logger.LogInfo(procChainMask);
procChainMask.AddProc(RoR2.ProcType.HealNova);
procChainMask.AddProc(RoR2.ProcType.Backstab);
Logger.LogInfo(procChainMask);
procChainMask.RemoveModdedProc(a);
procChainMask.AddModdedProc(a);
Logger.LogInfo(procChainMask);
procChainMask.AddModdedProc(c);
Logger.LogInfo(procChainMask);
procChainMask.AddModdedProc(b);
Logger.LogInfo(procChainMask);
procChainMask.RemoveModdedProc(b);
Logger.LogInfo(procChainMask);
Logger.LogInfo(procChainMask.HasModdedProc(a));
Logger.LogInfo(procChainMask.HasModdedProc(b));
Logger.LogInfo(procChainMask.HasModdedProc(c));
System.Collections.BitArray moddedMask = ProcTypeAPI.GetModdedMask(procChainMask);
Logger.LogInfo(moddedMask.Length);
moddedMask[5] = true;
ProcTypeAPI.SetModdedMask(ref procChainMask, moddedMask);
Logger.LogInfo(procChainMask);
}

private void OnDestroy()
Expand Down

0 comments on commit b37d4f8

Please sign in to comment.