| | 1 | | using DCL.Controllers; |
| | 2 | | using DCL.Models; |
| | 3 | |
|
| | 4 | | public static class ECSTransformUtils |
| | 5 | | { |
| | 6 | | public readonly struct OrphanEntity |
| | 7 | | { |
| | 8 | | public readonly IParcelScene scene; |
| | 9 | | public readonly IDCLEntity entity; |
| | 10 | | public readonly long parentId; |
| | 11 | |
|
| | 12 | | public OrphanEntity(IParcelScene scene, IDCLEntity entity, long parentId) |
| | 13 | | { |
| 4 | 14 | | this.scene = scene; |
| 4 | 15 | | this.entity = entity; |
| 4 | 16 | | this.parentId = parentId; |
| 4 | 17 | | } |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public static KeyValueSet<IDCLEntity, OrphanEntity> orphanEntities = null; |
| | 21 | |
|
| | 22 | | public static bool SetParent(IParcelScene scene, IDCLEntity child, long parentId) |
| | 23 | | { |
| 8 | 24 | | if (parentId == (long)SpecialEntityId.SCENE_ROOT_ENTITY) |
| | 25 | | { |
| 1 | 26 | | child.SetParent(null); |
| 1 | 27 | | child.gameObject.transform.SetParent(scene.GetSceneTransform(), false); |
| 1 | 28 | | return true; |
| | 29 | | } |
| | 30 | |
|
| 7 | 31 | | IDCLEntity parent = scene.GetEntityById(parentId); |
| 7 | 32 | | if (parent != null) |
| | 33 | | { |
| 3 | 34 | | child.SetParent(parent); |
| 3 | 35 | | return true; |
| | 36 | | } |
| | 37 | |
|
| 4 | 38 | | return false; |
| | 39 | | } |
| | 40 | | } |