Skip to content

Commit a735cd0

Browse files
committed
genius optimisation
1 parent 4ae2e9a commit a735cd0

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

FixTurrets/FixTurretsPatch.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@ namespace FixTurrets
1414
[PatchShim]
1515
public static class FixTurretsPatch
1616
{
17+
18+
private static int _counter = 0;
19+
private static readonly int skipConst = 100;
1720

1821
[ReflectedMethod(Name = "RotateModels")]
1922
private static Action<MyLargeTurretBase> RotateModels;
2023

21-
24+
private static void OnPositionChanged(MyPositionComponentBase myPositionComponentBase, MyLargeTurretBase __instance)
25+
{
26+
_counter++;
27+
if (_counter % skipConst == 0)
28+
{
29+
RotateModels.Invoke(__instance);
30+
_counter = 0;
31+
}
32+
33+
}
2234

2335
public static readonly Logger Log = LogManager.GetCurrentClassLogger();
2436

@@ -40,9 +52,6 @@ private static void TurretInitPatch(MyLargeTurretBase __instance, MyObjectBuilde
4052
OnPositionChanged(pos, __instance);
4153
}
4254

43-
private static void OnPositionChanged(MyPositionComponentBase myPositionComponentBase, MyLargeTurretBase __instance)
44-
{
45-
RotateModels.Invoke(__instance);
46-
}
55+
4756
}
4857
}

0 commit comments

Comments
 (0)