|
1 |
| -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.ComponentModel;
|
4 | 4 | using MLAPI.Exceptions;
|
@@ -28,22 +28,33 @@ public static class LagCompensationManager
|
28 | 28 | /// <param name="secondsAgo">The amount of seconds</param>
|
29 | 29 | /// <param name="action">The action to invoke when time is turned back</param>
|
30 | 30 | public static void Simulate(float secondsAgo, Action action)
|
| 31 | + { |
| 32 | + Simulate(secondsAgo, SimulationObjects, action); |
| 33 | + } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Turns time back a given amount of second on the given objects, invokes an action and turns it back |
| 37 | + /// </summary> |
| 38 | + /// <param name="secondsAgo">The amount of seconds</param> |
| 39 | + /// <param name="simulatedObjects">The object to simulate back in time</param> |
| 40 | + /// <param name="action">The action to invoke when time is turned back</param> |
| 41 | + public static void Simulate(float secondsAgo, IList<TrackedObject> simulatedObjects, Action action) |
31 | 42 | {
|
32 | 43 | if (!NetworkingManager.Singleton.IsServer)
|
33 | 44 | {
|
34 | 45 | throw new NotServerException("Only the server can perform lag compensation");
|
35 | 46 | }
|
36 |
| - |
37 |
| - for (int i = 0; i < SimulationObjects.Count; i++) |
| 47 | + |
| 48 | + for (int i = 0; i < simulatedObjects.Count; i++) |
38 | 49 | {
|
39 |
| - SimulationObjects[i].ReverseTransform(secondsAgo); |
| 50 | + simulatedObjects[i].ReverseTransform(secondsAgo); |
40 | 51 | }
|
41 | 52 |
|
42 | 53 | action.Invoke();
|
43 | 54 |
|
44 |
| - for (int i = 0; i < SimulationObjects.Count; i++) |
| 55 | + for (int i = 0; i < simulatedObjects.Count; i++) |
45 | 56 | {
|
46 |
| - SimulationObjects[i].ResetStateTransform(); |
| 57 | + simulatedObjects[i].ResetStateTransform(); |
47 | 58 | }
|
48 | 59 | }
|
49 | 60 |
|
|
0 commit comments