Skip to content

Commit

Permalink
Reduce FindObjects (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
takahiro0327 authored Aug 27, 2024
1 parent 3e1dab8 commit c6e0ff2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 60 deletions.
18 changes: 3 additions & 15 deletions AI_Studio_BetterPenetration/AI_Studio_BetterPenetration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@ internal static void ChaControl_UpdateSiru(ChaControl __instance, bool forceChan

internal static void BeforeCharacterReload()
{
var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down Expand Up @@ -308,11 +304,7 @@ internal static void ReinitializeControllers()
if (nodeConstraintPlugin == null)
return;

var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand All @@ -335,11 +327,7 @@ internal void Update()

updateCount = 0;

var bpControllers = BetterPenetrationController.controllers;
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down
18 changes: 3 additions & 15 deletions HS2_Studio_BetterPenetration/HS2_Studio_BetterPenetration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@ internal static void ChaControl_UpdateSiru(ChaControl __instance, bool forceChan

internal static void BeforeCharacterReload()
{
var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down Expand Up @@ -308,11 +304,7 @@ internal static void ReinitializeControllers()
if (nodeConstraintPlugin == null)
return;

var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand All @@ -335,11 +327,7 @@ internal void Update()

updateCount = 0;

var bpControllers = BetterPenetrationController.controllers;
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down
18 changes: 3 additions & 15 deletions KKS_Studio_BetterPenetration/KKS_Studio_BetterPenetration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ internal static void ChaControl_UpdateSiru(ChaControl __instance, bool forceChan

internal static void BeforeCharacterReload()
{
var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down Expand Up @@ -307,11 +303,7 @@ internal static void ReinitializeControllers()
if (nodeConstraintPlugin == null)
return;

var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand All @@ -334,11 +326,7 @@ internal void Update()

updateCount = 0;

var bpControllers = BetterPenetrationController.controllers;
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down
18 changes: 3 additions & 15 deletions KK_Studio_BetterPenetration/KK_Studio_BetterPenetration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ internal static void ChaControl_UpdateSiru(ChaControl __instance, bool forceChan

internal static void BeforeCharacterReload()
{
var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down Expand Up @@ -307,11 +303,7 @@ internal static void ReinitializeControllers()
if (nodeConstraintPlugin == null)
return;

var bpControllers = FindObjectsOfType<BetterPenetrationController>();
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand All @@ -334,11 +326,7 @@ internal void Update()

updateCount = 0;

var bpControllers = BetterPenetrationController.controllers;
if (bpControllers == null)
return;

foreach (var controller in bpControllers)
foreach (var controller in BetterPenetrationController.controllers)
{
if (controller == null)
continue;
Expand Down

0 comments on commit c6e0ff2

Please sign in to comment.