| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public class PhysicsSyncController : IPhysicsSyncController |
| | 8 | | { |
| 0 | 9 | | public bool isDirty { get; private set; } = false; |
| | 10 | |
|
| 629 | 11 | | public PhysicsSyncController() |
| | 12 | | { |
| 629 | 13 | | Physics.autoSimulation = false; |
| 629 | 14 | | Physics.autoSyncTransforms = false; |
| | 15 | |
|
| 629 | 16 | | PoolManager.i.OnGet -= MarkDirty; |
| 629 | 17 | | PoolManager.i.OnGet += MarkDirty; |
| 629 | 18 | | } |
| | 19 | |
|
| 12750 | 20 | | public void MarkDirty() { isDirty = true; } |
| | 21 | |
|
| | 22 | | public void Sync() |
| | 23 | | { |
| 12308 | 24 | | if (!isDirty) |
| 6396 | 25 | | return; |
| | 26 | |
|
| 5912 | 27 | | isDirty = false; |
| 5912 | 28 | | Physics.SyncTransforms(); |
| 5912 | 29 | | } |
| | 30 | |
|
| | 31 | | public void Dispose() |
| | 32 | | { |
| 629 | 33 | | PoolManager.i.OnGet -= MarkDirty; |
| 629 | 34 | | } |
| | 35 | |
|
| | 36 | | public void Initialize() |
| | 37 | | { |
| 629 | 38 | | } |
| | 39 | | } |
| | 40 | | } |