Exemplo n.º 1
0
        public bool RenderObject(MKDS_Course_Modifier.MKDS.NKM.OBJIEntry Item)
        {
            this.texoffset = 0;
            ushort objectId = Item.ObjectID;

            ObjectDb.Object @object = MKDS_Const.ObjectDatabase.GetObject(objectId);
            if (@object != null)
            {
                List <string> stringList = new List <string>();
                foreach (ObjectDb.Object.File requiredFile in @object.RequiredFiles)
                {
                    if (requiredFile.FileName.EndsWith(".nsbmd"))
                    {
                        stringList.Add(requiredFile.FileName);
                    }
                }
                foreach (string str in stringList)
                {
                    if (!str.StartsWith("sh_") && !str.EndsWith("_shadow.nsbmd"))
                    {
                        NARC.FileEntry fileByPath1 = this.Root1.GetFileByPath("\\MapObj\\" + str);
                        if (fileByPath1 != null)
                        {
                            this.RenderObject(objectId, new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBMD(fileByPath1.Content), (NSBTP)null, 0, stringList.IndexOf(str) == stringList.Count - 1);
                        }
                        else
                        {
                            NARC.FileEntry fileByPath2 = this.Main.GetFileByPath("\\" + str);
                            if (fileByPath2 != null)
                            {
                                this.RenderObject(objectId, new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBMD(fileByPath2.Content), (NSBTP)null, 0, stringList.IndexOf(str) == stringList.Count - 1);
                            }
                            else
                            {
                                NARC.FileEntry fileByPath3 = this.RomRoot.GetFileByPath("\\data\\MissionRun\\" + str);
                                if (fileByPath3 != null)
                                {
                                    this.RenderObject(objectId, new MKDS_Course_Modifier.G3D_Binary_File_Format.NSBMD(fileByPath3.Content), (NSBTP)null, 0, stringList.IndexOf(str) == stringList.Count - 1);
                                }
                                else
                                {
                                    this.CreateCube(Color.Red, Color.SkyBlue, true);
                                    return(false);
                                }
                            }
                        }
                    }
                }
                return(true);
            }
            this.CreateCube(Color.Blue, Color.SkyBlue, true);
            return(false);
        }
Exemplo n.º 2
0
        public MKDS_Course_Modifier.MKDS.NKM ToNKM()
        {
            MKDS_Course_Modifier.MKDS.NKM nkm = new MKDS_Course_Modifier.MKDS.NKM(false);
            foreach (BOL.Object @object in this.Objects)
            {
                MKDS_Course_Modifier.MKDS.NKM.OBJIEntry objiEntry = new MKDS_Course_Modifier.MKDS.NKM.OBJIEntry();
                objiEntry.Position   = new Vector3(@object.Position.X / 4f, @object.Position.Y / 4f, @object.Position.Z / 4f);
                objiEntry.Scale      = @object.Scale;
                objiEntry.TimeTrails = true;
                switch (@object.ObjectID)
                {
                case 1:
                    objiEntry.ObjectID = @object.RouteID != (short)-1 ? (ushort)201 : (ushort)101;
                    break;

                case 3401:
                    objiEntry.ObjectID = (ushort)1;
                    break;

                case 3405:
                    objiEntry.ObjectID = (ushort)302;
                    break;

                case 3503:
                    objiEntry.ObjectID = (ushort)5;
                    break;

                case 4203:
                    objiEntry.ObjectID = (ushort)431;
                    uint num = (@object.Unknown4 & (uint)ushort.MaxValue) / 10U;
                    objiEntry.Setting1 = (uint)(((int)(num >> 8) & (int)byte.MaxValue) << 24 | ((int)num & (int)byte.MaxValue) << 16 | ((int)(@object.Unknown3 >> 24) & (int)byte.MaxValue) << 8 | (int)(@object.Unknown3 >> 16) & (int)byte.MaxValue);
                    objiEntry.Setting2 = 55U;
                    break;

                case 4222:
                    objiEntry.ObjectID = (ushort)14;
                    break;

                case 4701:
                    objiEntry.ObjectID = (ushort)403;
                    break;

                case 4702:
                    objiEntry.ObjectID = (ushort)408;
                    break;

                default:
                    objiEntry.ObjectID = @object.ObjectID;
                    break;
                }
                if (@object.ObjectID == (ushort)1)
                {
                    objiEntry.TimeTrails = false;
                }
                objiEntry.RouteID = @object.RouteID;
                if (@object.RouteID != (short)-1)
                {
                    objiEntry.Setting1 = 32U;
                }
                if ((int)objiEntry.ObjectID != (int)@object.ObjectID)
                {
                    nkm.OBJI.Add(objiEntry);
                }
            }
            int num1 = 0;

            foreach (BOL.Route route in this.Routes)
            {
                MKDS_Course_Modifier.MKDS.NKM.PATHEntry pathEntry = new MKDS_Course_Modifier.MKDS.NKM.PATHEntry();
                pathEntry.Index  = (byte)num1++;
                pathEntry.Loop   = false;
                pathEntry.NrPoit = (short)route.NrPoints;
                for (int index = 0; index < (int)route.NrPoints; ++index)
                {
                    BOL.RoutePoint routePoint = this.RoutePoints[(int)route.FirstPointIndex + index];
                    nkm.POIT.Add(new MKDS_Course_Modifier.MKDS.NKM.POITEntry()
                    {
                        Position = new Vector3(routePoint.Position.X / 4f, routePoint.Position.Y / 4f, routePoint.Position.Z / 4f),
                        Index    = (short)(byte)index
                    });
                }
                nkm.PATH.Add(pathEntry);
            }
            foreach (BOL.StartPosition startPosition in this.StartPositions)
            {
                nkm.KTPS.Add(new MKDS_Course_Modifier.MKDS.NKM.KTPSEntry()
                {
                    Position = new Vector3(startPosition.Position.X / 4f, startPosition.Position.Y / 4f, startPosition.Position.Z / 4f),
                    Index    = (short)startPosition.PlayerID,
                    Padding  = ushort.MaxValue
                });
                nkm.KTP2.Add(new MKDS_Course_Modifier.MKDS.NKM.KTP2Entry()
                {
                    Position = new Vector3(startPosition.Position.X / 4f, startPosition.Position.Y / 4f, startPosition.Position.Z / 4f),
                    Index    = (short)startPosition.PlayerID,
                    Padding  = ushort.MaxValue
                });
            }
            int num2 = 0;
            int num3 = 0;

            foreach (BOL.Checkpoint checkpoint in this.Checkpoints)
            {
                NKMProperties.CPOI cpoi = (NKMProperties.CPOI) new MKDS_Course_Modifier.MKDS.NKM.CPOIEntry()
                {
                    Position1 = new Vector2(checkpoint.Position1.X / 4f, checkpoint.Position1.Z / 4f),
                    Position2 = new Vector2(checkpoint.Position2.X / 4f, checkpoint.Position2.Z / 4f)
                };
                int num4 = num2 % 4 != 0 || num2 == 0 ? 1 : (num2 == this.Checkpoints.Length - 1 ? 1 : 0);
                cpoi.KeyPoint  = num4 != 0 ? (short)-1 : (short)num3++;
                cpoi.RespawnID = (short)checkpoint.Unknown1[0];
                if (num2 == 0)
                {
                    cpoi.SectionData = 4294901760U;
                    cpoi.Distance    = -1f;
                }
                else if (num2 == this.Checkpoints.Length - 1)
                {
                    cpoi.SectionData = (uint)ushort.MaxValue;
                    cpoi.Distance    = -1f;
                }
                else
                {
                    cpoi.SectionData = uint.MaxValue;
                }
                ++num2;
                nkm.CPOI.Add((MKDS_Course_Modifier.MKDS.NKM.CPOIEntry)cpoi);
            }
            int num5 = 0;

            foreach (BOL.CheckpointGroup checkpointGroup in this.CheckpointGroups)
            {
                MKDS_Course_Modifier.MKDS.NKM.CPATEntry cpatEntry = new MKDS_Course_Modifier.MKDS.NKM.CPATEntry();
                cpatEntry.ComesFrom1 = (sbyte)checkpointGroup.ComesFrom1;
                cpatEntry.ComesFrom2 = (sbyte)checkpointGroup.ComesFrom2;
                cpatEntry.ComesFrom3 = (sbyte)checkpointGroup.ComesFrom3;
                cpatEntry.GoesTo1    = (sbyte)checkpointGroup.GoesTo1;
                cpatEntry.GoesTo2    = (sbyte)checkpointGroup.GoesTo2;
                cpatEntry.GoesTo3    = (sbyte)checkpointGroup.GoesTo3;
                cpatEntry.Length     = (short)checkpointGroup.NrPoints;
                cpatEntry.StartIdx   = (short)num5;
                num5 += (int)checkpointGroup.NrPoints;
                cpatEntry.SectionOrder = (short)0;
                nkm.CPAT.Add(cpatEntry);
            }
            MKDS_Course_Modifier.MKDS.NKM.IPATEntry ipatEntry = new MKDS_Course_Modifier.MKDS.NKM.IPATEntry();
            MKDS_Course_Modifier.MKDS.NKM.EPATEntry epatEntry = new MKDS_Course_Modifier.MKDS.NKM.EPATEntry();
            ipatEntry.ComesFrom1 = epatEntry.ComesFrom1 = (sbyte)0;
            ipatEntry.ComesFrom2 = epatEntry.ComesFrom2 = (sbyte)-1;
            ipatEntry.ComesFrom3 = epatEntry.ComesFrom3 = (sbyte)-1;
            ipatEntry.GoesTo1    = epatEntry.GoesTo1 = (sbyte)0;
            ipatEntry.GoesTo2    = epatEntry.GoesTo2 = (sbyte)-1;
            ipatEntry.GoesTo3    = epatEntry.GoesTo3 = (sbyte)-1;
            ipatEntry.StartIdx   = epatEntry.StartIdx = (short)0;
            ipatEntry.Length     = epatEntry.Length = (short)this.ItemEnemyPoints.Length;
            nkm.IPAT.Add(ipatEntry);
            nkm.EPAT.Add(epatEntry);
            List <int>[] intListArray = new List <int> [this.ItemEnemyPoints.Length];
            for (int index = 0; index < this.ItemEnemyPoints.Length; ++index)
            {
                intListArray[index] = new List <int>();
            }
            int num6 = 0;

            foreach (BOL.ItemEnemyPoint itemEnemyPoint in this.ItemEnemyPoints)
            {
                if (itemEnemyPoint.GroupLink != ushort.MaxValue)
                {
                    intListArray[(int)itemEnemyPoint.GroupID].Add((int)itemEnemyPoint.GroupLink);
                }
                nkm.IPOI.Add(new MKDS_Course_Modifier.MKDS.NKM.IPOIEntry()
                {
                    Position = new Vector3(itemEnemyPoint.Position.X / 4f, itemEnemyPoint.Position.Y / 4f, itemEnemyPoint.Position.Z / 4f)
                });
                nkm.EPOI.Add(new MKDS_Course_Modifier.MKDS.NKM.EPOIEntry()
                {
                    Position = new Vector3(itemEnemyPoint.Position.X / 4f, itemEnemyPoint.Position.Y / 4f, itemEnemyPoint.Position.Z / 4f)
                });
                ++num6;
            }
            int num7 = 0;

            foreach (BOL.Respawn respawn in this.Respawns)
            {
                nkm.KTPJ.Add(new MKDS_Course_Modifier.MKDS.NKM.KTPJEntry()
                {
                    Position = new Vector3(respawn.Position.X / 4f, respawn.Position.Y / 4f, respawn.Position.Z / 4f),
                    Index    = num7++
                });
            }
            foreach (BOL.Camera camera in this.Cameras)
            {
                MKDS_Course_Modifier.MKDS.NKM.CAMEEntry cameEntry = new MKDS_Course_Modifier.MKDS.NKM.CAMEEntry();
                if (camera.CameraType == (byte)5 || camera.CameraType == (byte)6)
                {
                    cameEntry.Position1   = new Vector3(camera.Position1.X / 4f, camera.Position1.Y / 4f, camera.Position1.Z / 4f);
                    cameEntry.Position2   = new Vector3(camera.Position3.X / 4f, camera.Position3.Y / 4f, camera.Position3.Z / 4f);
                    cameEntry.Position3   = new Vector3(camera.Position2.X / 4f, camera.Position2.Y / 4f, camera.Position2.Z / 4f);
                    cameEntry.LinkedRoute = camera.LinkedRoute;
                    cameEntry.NextCame    = camera.NextCamera;
                    cameEntry.TotalLength = camera.TotalTime;
                    cameEntry.Unknown1    = 113442841U;
                    cameEntry.Unknown2    = 986752U;
                    cameEntry.PointSpeed  = (short)((double)camera.Unknown7 / 60.0 * 100.0);
                    cameEntry.RouteSpeed  = (short)((double)camera.Unknown6 / 60.0 * 100.0);
                    cameEntry.CameraType  = (short)3;
                    nkm.CAME.Add(cameEntry);
                }
            }
            return(nkm);
        }