Exemple #1
0
        public void SaveProperties(LevelscriptCommand Command)
        {
            // Acts
            var acts = new[] { false, false, false, false, false, false, false, false };

            acts[7] = Act1;
            acts[6] = Act2;
            acts[5] = Act3;
            acts[4] = Act4;
            acts[3] = Act5;
            acts[2] = Act6;
            clNormal3DObject.SetActs(Command, Bits.ArrayToByte(acts));

            // Position
            clNormal3DObject.SetPosition(Command, Position);

            // Rotation
            clNormal3DObject.SetRotation(Command, Rotation);

            // Model-ID
            clNormal3DObject.SetModelID(Command, ModelID);

            // Behavior-ID
            clNormal3DObject.SetSegBehaviorAddr(Command, BehaviorID);

            // B. Params
            var bParams = new ObjBParams();

            bParams.BParam1 = BParam1;
            bParams.BParam2 = BParam2;
            bParams.BParam3 = BParam3;
            bParams.BParam4 = BParam4;
            clNormal3DObject.SetParams(Command, bParams);
        }
            public static uint GetVertexPointer(LevelscriptCommand cmd)
            {
                cmd.Position = 0x10;
                int value = cmd.ReadInt32();

                return(Conversions.ToUInteger(value));
            }
Exemple #3
0
        protected LevelArea(byte AreaID, byte LevelID, bool AddWarps, bool AddObjects)
        {
            Geolayout   = new Geolayout.Geolayout(SM64Lib.Geolayout.Geolayout.NewScriptCreationMode.Level);
            this.AreaID = AreaID;
            {
                var withBlock = Levelscript;
                withBlock.Add(new LevelscriptCommand(new byte[] { 0x1F, 0x8, AreaID, 0x0, 0x0, 0x0, 0x0, 0x0 }));
                withBlock.Add(new LevelscriptCommand(new byte[] { 0x2E, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
                withBlock.Add(new LevelscriptCommand(new byte[] { 0x36, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }));
                withBlock.Add(new LevelscriptCommand(new byte[] { 0x31, 0x4, 0x0, 0x2 }));
                withBlock.Add(new LevelscriptCommand(new byte[] { 0x20, 0x4, 0x0, 0x0 }));
            }

            if (AddWarps)
            {
                Objects.Add(new LevelscriptCommand(new byte[] { 0x24, 0x18, 0x1F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x13, 0x0, 0x2F, 0x74 }));
                Warps.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xA, LevelID, AreaID, 0x0, 0x0, 0x0 }));
                WarpsForGame.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xF0, 0x6, 0x1, 0x32, 0x0, 0x0 }));
                WarpsForGame.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xF1, 0x6, 0x1, 0x64, 0x0, 0x0 }));
            }

            if (AddObjects)
            {
                for (int i = 1; i <= 15; i++)
                {
                    var newObj = new LevelscriptCommand(DefaultNormal3DObject);
                    Objects.Add(newObj);
                }
            }
        }
Exemple #4
0
        protected void ChangeObjectBank(ObjectBankData oldObd, ObjectBankData newObd)
        {
            // Remove old commands
            if (oldObd is object)
            {
                foreach (ObjectBankDataCommand obdCmd in oldObd.Commands)
                {
                    foreach (var cmd in Levelscript.Where(n => General.CompareTwoByteArrays(n.ToArray(), obdCmd.Command)).ToArray())
                    {
                        cmd.Close();
                        Levelscript.Remove(cmd);
                    }
                }
            }

            // Add new commands
            if (newObd is object)
            {
                foreach (ObjectBankDataCommand obdCmd in newObd.Commands)
                {
                    int startIndex = Levelscript.IndexOfFirst(LevelscriptCommandTypes.x1D);
                    if (!(obdCmd.CommandType == 0x1A || obdCmd.CommandType == 0x17))
                    {
                        startIndex += 1;
                    }

                    var cmd = new LevelscriptCommand(obdCmd.Command);
                    Levelscript.Insert(startIndex, cmd);
                    startIndex += 1;
                }
            }
        }
            public static byte GetAreaID(LevelscriptCommand Command)
            {
                Command.Position = 2;
                byte value = Command.ReadByte();

                Command.Position = 0;
                return(value);
            }
            public static int GetSegmentedAddressToJump(LevelscriptCommand Command)
            {
                Command.Position = 12;
                uint value = Command.ReadUInt32();

                Command.Position = 0;
                return(Conversions.ToInteger(value));
            }
            public static short GetGroupID(LevelscriptCommand Command)
            {
                Command.Position = 14;
                short id = Command.ReadInt16();

                Command.Position = 0;
                return(id);
            }
            public static ushort GetCountOfFaces(LevelscriptCommand cmd)
            {
                cmd.Position = 4;
                ushort val = cmd.ReadUInt16();

                cmd.Position = 0;
                return(val);
            }
            public static byte GetDestinationWarpID(LevelscriptCommand Command)
            {
                Command.Position = 5;
                byte ID = Command.ReadByte();

                Command.Position = 0;
                return(ID);
            }
            public static int GetSegJumpAddr(LevelscriptCommand Command)
            {
                Command.Position = 4;
                int jumpaddr = Command.ReadInt32();

                Command.Position = 0;
                return(jumpaddr);
            }
            public static byte GetModelID(LevelscriptCommand Command)
            {
                Command.Position = 3;
                int areaid = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(areaid));
            }
            public static uint GetAreaCollision(LevelscriptCommand Command)
            {
                Command.Position = 4;
                uint AreaCollision = Command.ReadUInt32();

                Command.Position = 0;
                return(AreaCollision);
            }
            public static byte GetTerrainType(LevelscriptCommand Command)
            {
                Command.Position = 3;
                int Type = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(Type));
            }
 public static void SetLocation(LevelscriptCommand cmd, Vector3 loc)
 {
     cmd.Position = 4;
     cmd.Write(Conversions.ToShort(loc.X));
     cmd.Write(Conversions.ToShort(loc.Y));
     cmd.Write(Conversions.ToShort(loc.Z));
     cmd.Position = 0;
 }
            public static byte GetAreaID(LevelscriptCommand cmd)
            {
                cmd.Position = 3;
                byte value = cmd.ReadByte();

                cmd.Position = 0;
                return(value);
            }
            public static byte GetCollisionType(LevelscriptCommand cmd)
            {
                cmd.Position = 2;
                byte value = cmd.ReadByte();

                cmd.Position = 0;
                return(value);
            }
 public static void SetPosition(LevelscriptCommand Command, Vector3 value)
 {
     Command.Position = 6;
     Command.Write(Conversions.ToShort(value.X));
     Command.Write(Conversions.ToShort(value.Y));
     Command.Write(Conversions.ToShort(value.Z));
     Command.Position = 0;
 }
            public static byte GetMusicID(LevelscriptCommand Command)
            {
                Command.Position = 3;
                int MusicID = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(MusicID));
            }
            public static byte GetDrawingLayer(LevelscriptCommand Command)
            {
                Command.Position = 3;
                int areaid = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(areaid >> 4));
            }
            public static byte GetCycleDuration(LevelscriptCommand cmd)
            {
                cmd.Position = 7;
                byte val = cmd.ReadByte();

                cmd.Position = 0;
                return(val);
            }
            public static byte GetDialogID(LevelscriptCommand cmd)
            {
                cmd.Position = 3;
                byte dialogID = cmd.ReadByte();

                cmd.Position = 0;
                return(dialogID);
            }
            public static short GetScrollSpeed(LevelscriptCommand cmd)
            {
                cmd.Position = 8;
                short val = cmd.ReadInt16();

                cmd.Position = 0;
                return(val);
            }
            public static byte GetParam1(LevelscriptCommand Command)
            {
                Command.Position = 2;
                int value = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(value));
            }
            public static Levels GetDestinationLevelID(LevelscriptCommand Command)
            {
                Command.Position = 3;
                Levels LevelID = (Levels)Command.ReadByte();

                Command.Position = 0;
                return(LevelID);
            }
            public static byte GetScrollType(LevelscriptCommand cmd)
            {
                cmd.Position = 6;
                byte val = Conversions.ToByte(cmd.ReadByte() & 0x1F);

                cmd.Position = 0;
                return(val);
            }
            public static byte GetSegmentedID(LevelscriptCommand Command)
            {
                Command.Position = 3;
                int value = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(value));
            }
            public static uint GetSegGeolayoutAddr(LevelscriptCommand Command)
            {
                Command.Position = 4;
                uint SegGeolayoutAddr = Command.ReadUInt32();

                Command.Position = 0;
                return(SegGeolayoutAddr);
            }
            public static int GetRomStart(LevelscriptCommand Command)
            {
                Command.Position = 4;
                int value = Command.ReadInt32();

                Command.Position = 0;
                return(value);
            }
            public static byte GetActs(LevelscriptCommand Command)
            {
                Command.Position = 2;
                int Acts = Command.ReadByte();

                Command.Position = 0;
                return(Conversions.ToByte(Acts));
            }
            public static int GetRomEnd(LevelscriptCommand Command)
            {
                Command.Position = 8;
                uint value = Command.ReadUInt32();

                Command.Position = 0;
                return(Conversions.ToInteger(value));
            }