private void ParseSelectionJSON(WebJSON.Selection msg) { MapLoader l = MapLoader.Loader; if (msg.Perso != null && msg.Perso.Offset != null) { BasePersoBehaviour bpb = GetPersoFromOffset(msg.Perso.Offset); if (bpb != null) { selector.Select(bpb, view: msg.View); } } else if (msg.SuperObject != null && msg.SuperObject != null && msg.SuperObject.Offset != null) { SuperObjectComponent so = controller.superObjects.FirstOrDefault(s => s.Offset == msg.SuperObject.Offset); if (so != null) { selector.Select(so); } } else { selector.Deselect(); } }
private void ParseSuperObjectJSON(WebJSON.SuperObject msg) { MapLoader l = MapLoader.Loader; SuperObjectComponent so = null; if (msg.Offset != null) { so = controller.superObjects.FirstOrDefault(s => s.Offset == msg.Offset); } if (so != null) { if (msg.Position.HasValue) { so.transform.localPosition = msg.Position.Value; } if (msg.Rotation.HasValue) { so.transform.localEulerAngles = msg.Rotation.Value; } if (msg.Scale.HasValue) { so.transform.localScale = msg.Scale.Value; } } }
public void Select(SuperObjectComponent so) { if (controller.CinematicSwitcher == null || !controller.CinematicSwitcher.HasControlOfCamera) { cam.JumpTo(so.gameObject); } }
private WebJSON.SuperObject GetSuperObjectJSON(SuperObjectComponent so, bool includeChildren = true) { if (so == null) { return(null); } WebJSON.SuperObject soJSON = new WebJSON.SuperObject() { Type = so.Type, Offset = so.Offset }; soJSON.Name = so.gameObject.name; soJSON.Position = so.gameObject.transform.localPosition; soJSON.Rotation = so.gameObject.transform.localEulerAngles; soJSON.Scale = so.gameObject.transform.localScale; if (soJSON.Type == SuperObject.Type.Perso) { BasePersoBehaviour pb = GetPersoFromSuperObjectOffset(soJSON.Offset); if (pb != null) { soJSON.Perso = GetPersoJSON(pb); } } if (includeChildren) { soJSON.Children = so.Children.Select(s => GetSuperObjectJSON(s, includeChildren: includeChildren)).ToArray(); } return(soJSON); }
private JSONObject GetDsgVarValueJSON(DsgVarComponent.DsgVarEditableEntry.Value value) { if (value == null) { return(null); } JSONObject dsgObj = new JSONObject(); dsgObj["string"] = value.ToString(); switch (value.type) { case DsgVarInfoEntry.DsgVarType.Perso: PersoBehaviour pb = value.AsPerso; if (pb != null) { Perso p = pb.perso; if (p != null) { JSONObject persoJSON = new JSONObject(); persoJSON["offset"] = p.offset.ToString(); persoJSON["nameFamily"] = p.nameFamily; persoJSON["nameModel"] = p.nameModel; persoJSON["nameInstance"] = p.namePerso; dsgObj["perso"] = persoJSON; } } break; case DsgVarInfoEntry.DsgVarType.SuperObject: SuperObjectComponent soc = value.AsSuperObject; if (soc != null) { SuperObject spo = soc.so; JSONObject soJSON = new JSONObject(); soJSON["offset"] = spo.offset.ToString(); soJSON["type"] = spo.type.ToString(); soJSON["offset"] = spo.offset.ToString(); if (spo.type == SuperObject.Type.Perso && spo.data != null) { Perso p = spo.data as Perso; if (p != null) { JSONObject persoJSON = new JSONObject(); persoJSON["offset"] = p.offset.ToString(); persoJSON["nameFamily"] = p.nameFamily; persoJSON["nameModel"] = p.nameModel; persoJSON["nameInstance"] = p.namePerso; soJSON["perso"] = persoJSON; } } dsgObj["value"] = soJSON; } break; } return(dsgObj); }
public GameObject GetGameObject() { if (perso.Value != null) { GameObject gao = new GameObject("SOD_" + IndexString + " @ " + Offset); SuperObjectComponent soc = gao.AddComponent <SuperObjectComponent>(); gao.layer = LayerMask.NameToLayer("SuperObject"); soc.soROMDynamic = this; MapLoader.Loader.controller.superObjects.Add(soc); ROMPersoBehaviour rpb = perso.Value.GetGameObject(gao); rpb.superObject = this; return(gao); } return(null); }
public GameObject GetGameObject() { GameObject gao = new GameObject("SO @ " + Offset + " - " + type); SuperObjectComponent soc = gao.AddComponent <SuperObjectComponent>(); gao.layer = LayerMask.NameToLayer("SuperObject"); soc.soROM = this; MapLoader.Loader.controller.superObjects.Add(soc); if (data.Value != null) { if (data.Value is PhysicalObject) { PhysicalObjectComponent poc = ((PhysicalObject)data.Value).GetGameObject(gao); } else if (data.Value is Sector) { SectorComponent sc = ((Sector)data.Value).GetGameObject(gao); } } if (children.Value != null) { foreach (Reference <SuperObject> so in children.Value.superObjects) { if (so.Value != null) { GameObject soGao = so.Value.GetGameObject(); if (soGao != null) { soc.Children.Add(soGao.GetComponent <SuperObjectComponent>()); soGao.transform.SetParent(gao.transform); ROMTransform.Apply(so.Value.transform, soGao); } } } } return(gao); }
public void JumpTo(GameObject gao) { Vector3? center = null, size = null; PersoBehaviour pb = gao.GetComponent <PersoBehaviour>(); if (pb != null) { //print(pb.perso.SuperObject.boundingVolume.Center + " - " + pb.perso.SuperObject.boundingVolume.Size); center = (pb.perso.SuperObject != null && pb.perso.SuperObject.boundingVolume != null) ? (pb.transform.position + pb.perso.SuperObject.boundingVolume.Center) : pb.transform.position; size = (pb.perso.SuperObject != null && pb.perso.SuperObject.boundingVolume != null) ? Vector3.Scale(pb.perso.SuperObject.boundingVolume.Size, pb.transform.lossyScale) : pb.transform.lossyScale; } else { SuperObjectComponent sc = gao.GetComponent <SuperObjectComponent>(); if (sc != null) { center = (gao.transform.position + sc.so.boundingVolume.Center); size = Vector3.Scale(sc.so.boundingVolume.Size, gao.transform.lossyScale); } } if (center.HasValue) { float cameraDistance = 4.0f; // Constant factor float objectSize = Mathf.Min(5f, Mathf.Max(size.Value.x, size.Value.y, size.Value.z)); float cameraView = 2.0f * Mathf.Tan(0.5f * Mathf.Deg2Rad * cam.fieldOfView); // Visible height 1 meter in front float distance = cameraDistance * objectSize / cameraView; // Combined wanted distance from the object distance += objectSize; // Estimated offset from the center to the outside of the object * 2 /*transform.position = center.Value + -transform.right * distance; * transform.LookAt(center.Value, Vector3.up);*/ //transform.LookAt(center.Value, Vector3.up); //transform.position = center.Value + Vector3.Normalize(transform.position - center.Value) * distance; targetPos = center.Value + Vector3.Normalize(transform.position - center.Value) * distance; if (center.Value - transform.position != Vector3.zero) { targetRot = Quaternion.LookRotation(center.Value - transform.position, Vector3.up); } } }
public static void DrawDsgVarValue(Rect rect, DsgVarComponent.DsgVarEditableEntry dsgVarEntry, DsgVarComponent.DsgVarEditableEntry.Value value, int?arrayIndex) { string stringVal; switch (value.type) { case DsgVarInfoEntry.DsgVarType.Boolean: value.AsBoolean = EditorGUI.Toggle(rect, value.AsBoolean); break; case DsgVarInfoEntry.DsgVarType.Int: value.AsInt = EditorGUI.IntField(rect, value.AsInt); break; case DsgVarInfoEntry.DsgVarType.UInt: stringVal = EditorGUI.TextField(rect, value.AsUInt.ToString()); if (UInt32.TryParse(stringVal, out uint r_uint)) { value.AsUInt = r_uint; } break; case DsgVarInfoEntry.DsgVarType.Caps: stringVal = EditorGUI.TextField(rect, value.AsCaps.ToString()); if (UInt32.TryParse(stringVal, out uint r_caps)) { value.AsCaps = r_caps; } break; case DsgVarInfoEntry.DsgVarType.Short: stringVal = EditorGUI.TextField(rect, value.AsShort.ToString()); if (Int16.TryParse(stringVal, out short r_short)) { value.AsShort = r_short; } break; case DsgVarInfoEntry.DsgVarType.UShort: stringVal = EditorGUI.TextField(rect, value.AsUShort.ToString()); if (UInt16.TryParse(stringVal, out ushort r_ushort)) { value.AsUShort = r_ushort; } break; case DsgVarInfoEntry.DsgVarType.Byte: stringVal = EditorGUI.TextField(rect, value.AsByte.ToString()); if (SByte.TryParse(stringVal, out sbyte r_sbyte)) { value.AsByte = r_sbyte; } break; case DsgVarInfoEntry.DsgVarType.UByte: stringVal = EditorGUI.TextField(rect, value.AsUByte.ToString()); if (Byte.TryParse(stringVal, out byte r_byte)) { value.AsUByte = r_byte; } break; case DsgVarInfoEntry.DsgVarType.Float: value.AsFloat = EditorGUI.FloatField(rect, value.AsFloat); break; case DsgVarInfoEntry.DsgVarType.Text: int?newTextID = DrawText(rect, value.AsText); if (newTextID.HasValue) { value.AsText = newTextID.Value; } //GUILayout.Label(MapLoader.Loader.localization.GetTextForHandleAndLanguageID((int)value.AsUInt, 0)); break; case DsgVarInfoEntry.DsgVarType.Vector: value.AsVector = EditorGUI.Vector3Field(rect, "", value.AsVector); break; case DsgVarInfoEntry.DsgVarType.Perso: if (MapLoader.Loader is OpenSpace.Loader.R2ROMLoader) { ROMPersoBehaviour currentPersoBehaviour = value.AsPersoROM != null ? value.AsPersoROM : null; ROMPersoBehaviour selectedPersoBehaviour = ((ROMPersoBehaviour)EditorGUI.ObjectField(rect, currentPersoBehaviour, typeof(ROMPersoBehaviour), true)); if (selectedPersoBehaviour != null && selectedPersoBehaviour.gameObject != null) { value.AsPersoROM = selectedPersoBehaviour; } } else { PersoBehaviour currentPersoBehaviour = value.AsPerso != null ? value.AsPerso : null; PersoBehaviour selectedPersoBehaviour = ((PersoBehaviour)EditorGUI.ObjectField(rect, currentPersoBehaviour, typeof(PersoBehaviour), true)); if (selectedPersoBehaviour != null && selectedPersoBehaviour.gameObject != null) { value.AsPerso = selectedPersoBehaviour; } } break; case DsgVarInfoEntry.DsgVarType.SuperObject: SuperObjectComponent currentGao = value.AsSuperObject != null ? value.AsSuperObject : null; SuperObjectComponent selectedGao = ((SuperObjectComponent)EditorGUI.ObjectField(rect, currentGao, typeof(SuperObjectComponent), true)); if (selectedGao != null && selectedGao.gameObject != null) { value.AsSuperObject = selectedGao; } break; case DsgVarInfoEntry.DsgVarType.WayPoint: WayPointBehaviour currentWaypointGao = value.AsWayPoint != null ? value.AsWayPoint : null; WayPointBehaviour selectedWaypointGao = ((WayPointBehaviour)EditorGUI.ObjectField(rect, currentWaypointGao, typeof(WayPointBehaviour), true)); if (selectedWaypointGao != null && selectedWaypointGao.gameObject != null) { value.AsWayPoint = selectedWaypointGao; } break; case DsgVarInfoEntry.DsgVarType.Graph: GraphBehaviour currentGraphGao = value.AsGraph != null ? value.AsGraph : null; GraphBehaviour selectedGraphGao = ((GraphBehaviour)EditorGUI.ObjectField(rect, currentGraphGao, typeof(GraphBehaviour), true)); if (selectedGraphGao != null && selectedGraphGao.gameObject != null) { value.AsGraph = selectedGraphGao; } break; case DsgVarInfoEntry.DsgVarType.ActionArray: case DsgVarInfoEntry.DsgVarType.FloatArray: case DsgVarInfoEntry.DsgVarType.Array11: case DsgVarInfoEntry.DsgVarType.GraphArray: case DsgVarInfoEntry.DsgVarType.Array9: case DsgVarInfoEntry.DsgVarType.IntegerArray: case DsgVarInfoEntry.DsgVarType.PersoArray: case DsgVarInfoEntry.DsgVarType.SoundEventArray: case DsgVarInfoEntry.DsgVarType.SuperObjectArray: case DsgVarInfoEntry.DsgVarType.TextArray: case DsgVarInfoEntry.DsgVarType.TextRefArray: case DsgVarInfoEntry.DsgVarType.VectorArray: case DsgVarInfoEntry.DsgVarType.WayPointArray: if (value.AsArray != null) { if (arrayIndex.HasValue) { if (value.AsArray[arrayIndex.Value] != null) { DrawDsgVarValue(rect, dsgVarEntry, value.AsArray[arrayIndex.Value], arrayIndex); } } else { EditorGUI.LabelField(rect, "Length: " + value.AsArray.Length); } } break; } }
public async UniTask InitGameObject() { if (isGameObjectInitialized) { return; } isGameObjectInitialized = true; GameObject gao = data?.Gao; if (gao != null) { //SuperObjectComponent soc = so.Gao.GetComponent<SuperObjectComponent>(); foreach (SuperObject ch in children) { if (ch != null) { await ch.InitGameObject(); } } string previousLoadingState = MapLoader.Loader.loadingState; MapLoader.Loader.loadingState = previousLoadingState + "\nInitializing SuperObject: " + gao.name; await MapLoader.WaitIfNecessary(); //await MapLoader.WaitFrame(); Vector3 pos = Vector3.zero; Vector3 scale = Vector3.one; Quaternion rot = Quaternion.identity; if (matrix != null) { pos = matrix.GetPosition(convertAxes: true); rot = matrix.GetRotation(convertAxes: true); scale = matrix.GetScale(convertAxes: true); } if (parent != null && parent.Gao != null) { Gao.transform.parent = parent.Gao.transform; } Gao.transform.localPosition = pos; Gao.transform.localRotation = rot; Gao.transform.localScale = scale; if (boundingVolumeTT != null) { boundingVolumeTT.Gao.transform.SetParent(Gao.transform); boundingVolumeTT.Gao.transform.localPosition = Vector3.zero; boundingVolumeTT.Gao.transform.localRotation = Quaternion.identity; boundingVolumeTT.Gao.transform.localScale = Vector3.one; } SuperObjectComponent soc = Gao.AddComponent <SuperObjectComponent>(); Gao.layer = LayerMask.NameToLayer("SuperObject"); soc.so = this; MapLoader.Loader.controller.superObjects.Add(soc); if (boundingVolume != null) { if (boundingVolume.type == BoundingVolume.Type.Box) { BoxCollider collider = Gao.AddComponent <BoxCollider>(); collider.center = boundingVolume.Center; collider.center -= Gao.transform.position; collider.size = boundingVolume.Size; } else { SphereCollider collider = Gao.AddComponent <SphereCollider>(); collider.center = boundingVolume.Center; collider.radius = boundingVolume.sphereRadius; } } MapLoader.Loader.loadingState = previousLoadingState; await MapLoader.WaitIfNecessary(); //SuperObjectComponent soc = so.Gao.GetComponent<SuperObjectComponent>(); foreach (SuperObject ch in children) { //if (ch != null) await ch.InitGameObject(); if (soc != null && ch != null && ch.Gao != null) { SuperObjectComponent soc_ch = ch.Gao.GetComponent <SuperObjectComponent>(); if (soc_ch == null) { continue; } soc.Children.Add(soc_ch); } } } }
public static SuperObject Read(Reader reader, Pointer off_so, SuperObject parent = null) { MapLoader l = MapLoader.Loader; if (IsParsed(off_so)) { return(null); } bool isValidNode = true; SuperObject so = new SuperObject(off_so); l.superObjects.Add(so); // Global list of superobjects (all) if (parent != null) { so.parent = parent; } so.typeCode = reader.ReadUInt32(); // 0 - 4 so.off_data = Pointer.Read(reader); // 4 - 8 so.children = LinkedList <SuperObject> .ReadHeader(reader, Pointer.Current(reader), LinkedList.Type.Double); // 8 - 14 so.off_brother_next = Pointer.Read(reader); // 14 - 18 so.off_brother_prev = Pointer.Read(reader); // 18 - 1C so.off_parent = Pointer.Read(reader); // 1C - 20 so.off_matrix = Pointer.Read(reader); // 0x20->0x24 so.off_staticMatrix = Pointer.Read(reader); // other matrix so.globalMatrix = reader.ReadInt32(); // 0x28 -> 0x2C so.drawFlags = SuperObjectDrawFlags.Read(reader); so.flags = SuperObjectFlags.Read(reader); // 0x30->0x34 if (Settings.s.engineVersion == Settings.EngineVersion.R3) { reader.ReadUInt32(); } Pointer off_boundingVolume = Pointer.Read(reader); //l.print("SuperObject T" + so.typeCode + ": " + off_so + " - " + so.off_matrix); //R3Pointer.Read(reader); // a copy of the matrix right after, at least in R3GC Vector3 pos = Vector3.zero; Vector3 scale = Vector3.one; Quaternion rot = Quaternion.identity; Pointer.DoAt(ref reader, so.off_matrix, () => { so.matrix = Matrix.Read(reader, so.off_matrix); pos = so.matrix.GetPosition(convertAxes: true); rot = so.matrix.GetRotation(convertAxes: true); scale = so.matrix.GetScale(convertAxes: true); }); /*Pointer.DoAt(ref reader, so.off_matrix2, () => { * so.matrix2 = Matrix.Read(reader, so.off_matrix2); * if (so.matrix == null) { * pos = so.matrix2.GetPosition(convertAxes: true); * rot = so.matrix2.GetRotation(convertAxes: true); * scale = so.matrix2.GetScale(convertAxes: true); * } * });*/ so.type = GetSOType(so.typeCode); switch (so.type) { case Type.IPO: Pointer.DoAt(ref reader, so.off_data, () => { so.data = IPO.Read(reader, so.off_data, so); }); break; case Type.IPO_2: Pointer.DoAt(ref reader, so.off_data, () => { l.print("IPO with code 0x40 at offset " + so.off_data); so.data = IPO.Read(reader, so.off_data, so); }); break; case Type.PhysicalObject: if (!Settings.s.loadFromMemory) { Pointer.DoAt(ref reader, so.off_data, () => { so.data = PhysicalObject.Read(reader, so.off_data, so); }); } break; case Type.Perso: Pointer.DoAt(ref reader, so.off_data, () => { so.data = Perso.Read(reader, so.off_data, so); }); break; case Type.World: so.data = World.New(so); //print("parsing world superobject with " + num_children + " children"); break; case Type.Sector: Pointer.DoAt(ref reader, so.off_data, () => { so.data = Sector.Read(reader, so.off_data, so); }); break; case Type.GeometricObject: Pointer.DoAt(ref reader, so.off_data, () => { so.data = Visual.GeometricObject.Read(reader, so.off_data); }); break; case Type.GeometricShadowObject: Pointer.DoAt(ref reader, so.off_data, () => { so.data = Visual.GeometricShadowObject.Read(reader, so.off_data, so); }); break; default: l.print("Unknown SO type " + so.typeCode + " at " + so.offset + " - " + so.off_data); //isValidNode = false; break; } Pointer.DoAt(ref reader, off_boundingVolume, () => { //l.print(off_boundingVolume); so.boundingVolume = BoundingVolume.Read(reader, off_boundingVolume, so.flags.HasFlag(SuperObjectFlags.Flags.BoundingBoxInsteadOfSphere) ? BoundingVolume.Type.Box : BoundingVolume.Type.Sphere); }); if (so.Gao != null) { if (parent != null && parent.Gao != null) { so.Gao.transform.parent = parent.Gao.transform; } so.Gao.transform.localPosition = pos; so.Gao.transform.localRotation = rot; so.Gao.transform.localScale = scale; SuperObjectComponent soc = so.Gao.AddComponent <SuperObjectComponent>(); so.Gao.layer = LayerMask.NameToLayer("SuperObject"); soc.so = so; if (so.boundingVolume != null) { if (so.boundingVolume.type == BoundingVolume.Type.Box) { BoxCollider collider = so.Gao.AddComponent <BoxCollider>(); collider.center = so.boundingVolume.Center; collider.center -= so.Gao.transform.position; collider.size = so.boundingVolume.Size; } else { SphereCollider collider = so.Gao.AddComponent <SphereCollider>(); collider.center = so.boundingVolume.Center; collider.radius = so.boundingVolume.sphereRadius; } } } if (isValidNode) { so.children.ReadEntries(ref reader, (off_child) => { SuperObject child = SuperObject.Read(reader, off_child, so); child.parent = so; return(child); }, LinkedList.Flags.HasHeaderPointers); } return(so); }
public void JumpTo(GameObject gao) { if (UnitySettings.IsRaymapGame) { return; } Vector3? center = null, size = null; BasePersoBehaviour bpb = gao.GetComponent <BasePersoBehaviour>(); if (bpb != null) { switch (bpb) { case PersoBehaviour pb: //print(pb.perso.SuperObject.boundingVolume.Center + " - " + pb.perso.SuperObject.boundingVolume.Size); center = (pb.perso.SuperObject != null && pb.perso.SuperObject.boundingVolume != null) ? (pb.transform.position + pb.perso.SuperObject.boundingVolume.Center) : pb.transform.position; size = (pb.perso.SuperObject != null && pb.perso.SuperObject.boundingVolume != null) ? Vector3.Scale(pb.perso.SuperObject.boundingVolume.Size, pb.transform.lossyScale) : pb.transform.lossyScale; break; case ROMPersoBehaviour rpb: center = rpb.transform.position; size = rpb.transform.lossyScale; break; case PS1PersoBehaviour ppb: center = ppb.transform.position; size = ppb.transform.lossyScale; break; } } else { SuperObjectComponent sc = gao.GetComponent <SuperObjectComponent>(); if (sc != null) { if (sc.so != null) { center = (gao.transform.position + sc.so.boundingVolume.Center); size = Vector3.Scale(sc.so.boundingVolume.Size, gao.transform.lossyScale); } else { center = gao.transform.position; size = gao.transform.lossyScale; } } } if (center.HasValue) { float objectSize = Mathf.Min(5f, Mathf.Max(size.Value.x, size.Value.y, size.Value.z)); bool orthographic = cam.orthographic; if (orthographic) { targetOrthoSize = objectSize * 2f * 1.5f; Vector3 target = cam.transform.InverseTransformPoint(center.Value); targetPos = cam.transform.TransformPoint(new Vector3(target.x, target.y, 0f)); } else { float cameraDistance = 4.0f; // Constant factor float cameraView = 2.0f * Mathf.Tan(0.5f * Mathf.Deg2Rad * cam.fieldOfView); // Visible height 1 meter in front float distance = cameraDistance * objectSize / cameraView; // Combined wanted distance from the object distance += objectSize; // Estimated offset from the center to the outside of the object * 2 /*transform.position = center.Value + -transform.right * distance; * transform.LookAt(center.Value, Vector3.up);*/ //transform.LookAt(center.Value, Vector3.up); //transform.position = center.Value + Vector3.Normalize(transform.position - center.Value) * distance; targetPos = center.Value + Vector3.Normalize(transform.position - center.Value) * distance; if (center.Value - transform.position != Vector3.zero) { targetRot = Quaternion.LookRotation(center.Value - transform.position, Vector3.up); } } } }
public GameObject GetGameObject() { GameObject gao = new GameObject(type + " @ " + Offset); if (FileSystem.mode == FileSystem.Mode.Web) { gao.name = type.ToString(); } SuperObjectComponent soc = gao.AddComponent <SuperObjectComponent>(); gao.layer = LayerMask.NameToLayer("SuperObject"); soc.soPS1 = this; MapLoader.Loader.controller.superObjects.Add(soc); if (type != Type.IPO) { matrix1?.Apply(gao); } /*if (.Value != null) { * if (data.Value is PhysicalObject) { * PhysicalObjectComponent poc = ((PhysicalObject)data.Value).GetGameObject(gao); * } else if (data.Value is Sector) { * SectorComponent sc = ((Sector)data.Value).GetGameObject(gao); * } * }*/ if (type == Type.IPO) { PhysicalObjectComponent poc = gao.AddComponent <PhysicalObjectComponent>(); LevelHeader h = (Load as R2PS1Loader).levelHeader; int ind = (dataIndex >> 1); if (ind >= h.geometricObjectsStatic.entries.Length) { throw new Exception("IPO SO data index was too high! " + h.geometricObjectsStatic.entries.Length + " - " + dataIndex); } gao.name = gao.name + " - " + ind; GameObject g = h.geometricObjectsStatic.GetGameObject(ind, null, out _); if (g != null) { poc.visual = g; g.transform.SetParent(gao.transform); g.transform.localPosition = Vector3.zero; g.transform.localRotation = Quaternion.identity; } if (h.ipoCollision != null && h.ipoCollision.Length > ind) { GameObject c = h.ipoCollision[ind].GetGameObject(); if (c != null) { poc.collide = c; c.transform.SetParent(gao.transform); c.transform.localPosition = Vector3.zero; c.transform.localRotation = Quaternion.identity; } } poc.Init(MapLoader.Loader.controller); } else if (type == Type.Perso) { LevelHeader h = (Load as R2PS1Loader).levelHeader; if (dataIndex >= h.persos.Length) { throw new Exception("Perso SO data index was too high! " + h.persos.Length + " - " + dataIndex); } gao.name = gao.name + " - " + dataIndex; PS1PersoBehaviour ps1Perso = h.persos[dataIndex].GetGameObject(gao); ps1Perso.superObject = this; } else if (type == Type.Sector) { LevelHeader h = (Load as R2PS1Loader).levelHeader; if (dataIndex >= h.sectors.Length) { throw new Exception("Sector SO data index was too high! " + h.sectors.Length + " - " + dataIndex); } gao.name = gao.name + " - " + dataIndex; SectorComponent sect = h.sectors[dataIndex].GetGameObject(gao); } if (children != null) { foreach (SuperObject so in children) { if (so != null) { GameObject soGao = so.GetGameObject(); if (soGao != null) { soc.Children.Add(soGao.GetComponent <SuperObjectComponent>()); soGao.transform.SetParent(gao.transform); if (so.type != Type.IPO) { so.matrix1?.Apply(soGao); } else { soGao.transform.localPosition = Vector3.zero; soGao.transform.localRotation = Quaternion.identity; } } } } } return(gao); }