Exemple #1
0
        public PS1PersoBehaviour GetGameObject(GameObject gao)
        {
            LevelHeader h = (Load as R2PS1Loader).levelHeader;

            if (FileSystem.mode == FileSystem.Mode.Web)
            {
                gao.name = name;
            }
            else
            {
                gao.name = name + " | " + gao.name;
            }
            if (p3dData?.family?.name != null)
            {
                gao.name = $"[{p3dData?.family?.name}] {gao.name}";
            }
            PS1PersoBehaviour romPerso = gao.AddComponent <PS1PersoBehaviour>();

            romPerso.perso      = this;
            romPerso.controller = MapLoader.Loader.controller;
            romPerso.controller.ps1Persos.Add(romPerso);
            return(romPerso);
        }
Exemple #2
0
        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);
        }