| | 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 | |
|
| 661 | 11 | | public PhysicsSyncController() |
| | 12 | | { |
| 661 | 13 | | Physics.autoSimulation = false; |
| 661 | 14 | | Physics.autoSyncTransforms = false; |
| | 15 | |
|
| 661 | 16 | | PoolManager.i.OnGet -= MarkDirty; |
| 661 | 17 | | PoolManager.i.OnGet += MarkDirty; |
| 661 | 18 | | } |
| | 19 | |
|
| | 20 | | public void MarkDirty() |
| | 21 | | { |
| 6196 | 22 | | isDirty = true; |
| 6196 | 23 | | } |
| | 24 | |
|
| | 25 | | public void Sync() |
| | 26 | | { |
| 11824 | 27 | | if (!isDirty) |
| 6120 | 28 | | return; |
| | 29 | |
|
| 5704 | 30 | | isDirty = false; |
| 5704 | 31 | | Physics.SyncTransforms(); |
| 5704 | 32 | | } |
| | 33 | |
|
| | 34 | | public void Dispose() |
| | 35 | | { |
| 661 | 36 | | PoolManager.i.OnGet -= MarkDirty; |
| 661 | 37 | | } |
| | 38 | |
|
| | 39 | | public void Initialize() |
| | 40 | | { |
| 661 | 41 | | } |
| | 42 | | } |
| | 43 | | } |