コード例 #1
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.username     = ByteSerializer.DeserializeString(bytes, ref offset);
     this.position     = ByteSerializer.DeserializeVector3(bytes, ref offset);
     this.pointerMode  = (PointerMode)ByteSerializer.DeserializeInt(bytes, ref offset);
     this.pointerColor = ByteSerializer.DeserializeColor(bytes, ref offset);
 }
コード例 #2
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.action  = (ConfigAction)ByteSerializer.DeserializeInt(bytes, ref offset);
     this.userCap = ByteSerializer.DeserializeInt(bytes, ref offset);
     this.acceptingConnections = ByteSerializer.DeserializeBool(bytes, ref offset);
     this.newPassword          = ByteSerializer.DeserializeString(bytes, ref offset);
     this.lobbyMode            = (LobbyMode)ByteSerializer.DeserializeInt(bytes, ref offset);
 }
コード例 #3
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.action    = (actionType)ByteSerializer.DeserializeInt(bytes, ref offset);
     this.content   = ByteSerializer.DeserializeByteArray(bytes, ref offset);
     this.username  = ByteSerializer.DeserializeString(bytes, ref offset);
     this.metadata  = ByteSerializer.DeserializeString(bytes, ref offset);
     this.playSound = ByteSerializer.DeserializeBool(bytes, ref offset);
 }
コード例 #4
0
        public void ImportCampaignCommand()
        {
            if (!instance.CheckForCheating())
            {
                uConsole.Log("Campaign Mod is not enabled!");
                return;
            }
            int Args = uConsole.GetNumParameters();

            if (Args != 1)
            {
                uConsole.Log("Usage: import_campaign <campaign>");
            }
            else
            {
                string Name  = uConsole.GetString();
                string cPath = MainPath + "Campaigns/" + Name;

                if (!File.Exists(MainPath + "Exports/" + Name + ".campaign"))
                {
                    uConsole.Log("That campaign doesn't exist!");
                    return;
                }

                byte[] cBytes = Utils.UnZipPayload(File.ReadAllBytes(MainPath + "Exports/" + Name + ".campaign"));
                int    offset = 0;

                string             cDataJson = ByteSerializer.DeserializeString(cBytes, ref offset);
                CampaignLayoutData cData     = JsonUtility.FromJson <CampaignLayoutData>(cDataJson);
                List <KeyValuePair <string, byte[]> > LevelBytes = new List <KeyValuePair <string, byte[]> >();

                for (int i = 0; i < cData.m_ItemIds.Count; i++)
                {
                    string lName = ByteSerializer.DeserializeString(cBytes, ref offset);
                    byte[] lData = ByteSerializer.DeserializeByteArray(cBytes, ref offset);
                    LevelBytes.Add(new KeyValuePair <string, byte[]>(lName, lData));
                }

                if (Directory.Exists(cPath))
                {
                    PopUpMessage.Display("Campaign already exists!\nOverwite it?", delegate {
                        Directory.Delete(cPath, true);
                        ImportCampaign(cPath, cDataJson, LevelBytes);
                    });
                }
                else
                {
                    ImportCampaign(cPath, cDataJson, LevelBytes);
                }
            }
        }
コード例 #5
0
        public static LevelData Deserialize(byte[] bytes, ref int offset)
        {
            LevelData levelData = new LevelData();

            levelData.LayoutBytes    = ByteSerializer.DeserializeByteArray(bytes, ref offset);
            levelData.PreviewData    = ByteSerializer.DeserializeByteArray(bytes, ref offset);
            levelData.PreviewTexture = new Texture2D(WorkshopPreview.PREVIEW_IMAGE_WIDTH, WorkshopPreview.PREVIEW_IMAGE_HEIGHT, TextureFormat.RGBA32, false);
            levelData.PreviewTexture.LoadImage(levelData.PreviewData);
            levelData.Name = ByteSerializer.DeserializeString(bytes, ref offset);

            int num = 0;

            levelData.LayoutData = DeserializeLayoutBytes(levelData.LayoutBytes, ref num);

            return(levelData);
        }
コード例 #6
0
        public static void patchDeserializerPostfix(SandboxLayoutData __instance, byte[] bytes, ref int offset, bool __state)
        {
            //ptfInstance.ptfLogger.LogMessage($"Layout version pre-load: {__instance.m_Version}");
            if (!__state)
            {
                return;
            }
            string[] strings = ByteSerializer.DeserializeStrings(bytes, ref offset);
            ptfInstance.ptfLogger.LogInfo($"Layout created with mod{(strings.Length > 1 ? "s" : "")}: ");
            foreach (string str in strings)
            {
                string[] partsOfMod = str.Split('\u058D');
                string   name       = partsOfMod.Length >= 1 ? partsOfMod[0] : null;
                string   version    = partsOfMod.Length >= 2 ? partsOfMod[1] : null;
                string   settings   = partsOfMod.Length >= 3 ? partsOfMod[2] : null;

                ptfInstance.ptfLogger.LogInfo($" -- {str.Replace("\u058D", " - v")}");

                var currMod = cheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault();
                if (currMod == null)
                {
                    currMod = noncheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault();
                }

                ptfInstance.checkMods(0, name, version, settings, currMod);
            }
            if (offset == bytes.Length)
            {
                return;
            }
            int extraSaveDataCount = ByteSerializer.DeserializeInt(bytes, ref offset);

            if (extraSaveDataCount == 0)
            {
                return;
            }

            ptfInstance.Logger.LogInfo($"Layout created with custom data from mods: ");

            for (int i = 0; i < extraSaveDataCount; i++)
            {
                string modIdentifier     = ByteSerializer.DeserializeString(bytes, ref offset);
                byte[] customModSaveData = ByteSerializer.DeserializeByteArray(bytes, ref offset);

                string[] partsOfMod = modIdentifier.Split('\u058D');
                string   name       = partsOfMod.Length >= 1 ? partsOfMod[0] : null;
                string   version    = partsOfMod.Length >= 2 ? partsOfMod[1] : null;

                ptfInstance.Logger.LogInfo($" -- {name} - v{version}");

                var currMod = cheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault();
                if (currMod == null)
                {
                    currMod = noncheatMods.Where(p => p.Info.Metadata.Name == name).FirstOrDefault();
                }

                if (currMod == null)
                {
                    return;
                }
                if (currMod.Info.Metadata.Version.ToString() != version)
                {
                    return;
                }

                currMod.loadData(customModSaveData);
            }
        }
コード例 #7
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.message   = ByteSerializer.DeserializeString(bytes, ref offset);
     this.username  = ByteSerializer.DeserializeString(bytes, ref offset);
     this.nameColor = ByteSerializer.DeserializeColor(bytes, ref offset);
 }
コード例 #8
0
        public static SandboxLayoutData DeserializeLayoutBytes(byte[] bytes, ref int offset)
        {
            SandboxLayoutData layoutData = new SandboxLayoutData();

            layoutData.m_Version = ByteSerializer.DeserializeInt(bytes, ref offset);
            if (layoutData.m_Version < 0)
            {
                layoutData.m_Version *= -1;
            }
            layoutData.m_ThemeStubKey = ByteSerializer.DeserializeString(bytes, ref offset);
            if (layoutData.m_Version >= 19)
            {
                int num1 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num1; i++)
                {
                    layoutData.m_Anchors.Add(new BridgeJointProxy(layoutData.m_Version, bytes, ref offset));
                }
            }
            if (layoutData.m_Version >= 5)
            {
                int num2 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num2; i++)
                {
                    layoutData.m_HydraulicsPhases.Add(new HydraulicsPhaseProxy(bytes, ref offset));
                }
            }
            if (layoutData.m_Version > 4)
            {
                layoutData.m_Bridge.DeserializeBinary(bytes, ref offset);
                goto LABEL;
            }
            int num3 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num3; i++)
            {
                layoutData.m_BridgeJoints.Add(new BridgeJointProxy(1, bytes, ref offset));
            }
            int num4 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num4; i++)
            {
                layoutData.m_BridgeEdges.Add(new BridgeEdgeProxy(bytes, ref offset));
            }
            int num5 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num5; i++)
            {
                layoutData.m_Pistons.Add(new PistonProxy(layoutData.m_Version, bytes, ref offset));
            }
LABEL:
            if (layoutData.m_Version >= 7)
            {
                int num6 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num6; i++)
                {
                    layoutData.m_ZedAxisVehicles.Add(new ZedAxisVehicleProxy(layoutData.m_Version, bytes, ref offset));
                }
            }
            int num7 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num7; i++)
            {
                layoutData.m_Vehicles.Add(new VehicleProxy(bytes, ref offset));
            }
            int num8 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num8; i++)
            {
                layoutData.m_VehicleStopTriggers.Add(new VehicleStopTriggerProxy(bytes, ref offset));
            }
            if (layoutData.m_Version < 20)
            {
                int num9 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num9; i++)
                {
                    ByteSerializer.DeserializeVector2(bytes, ref offset);
                    ByteSerializer.DeserializeString(bytes, ref offset);
                    ByteSerializer.DeserializeBool(bytes, ref offset);
                }
            }
            int num10 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num10; i++)
            {
                layoutData.m_EventTimelines.Add(new EventTimelineProxy(layoutData.m_Version, bytes, ref offset));
            }
            int num11 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num11; i++)
            {
                layoutData.m_Checkpoints.Add(new CheckpointProxy(bytes, ref offset));
            }
            int num12 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num12; i++)
            {
                layoutData.m_TerrainStretches.Add(new TerrainIslandProxy(layoutData.m_Version, bytes, ref offset));
            }
            int num13 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num13; i++)
            {
                layoutData.m_Platforms.Add(new PlatformProxy(layoutData.m_Version, bytes, ref offset));
            }
            int num14 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num14; i++)
            {
                layoutData.m_Ramps.Add(new RampProxy(layoutData.m_Version, bytes, ref offset));
            }
            if (layoutData.m_Version < 5)
            {
                int num15 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num15; i++)
                {
                    layoutData.m_HydraulicsPhases.Add(new HydraulicsPhaseProxy(bytes, ref offset));
                }
            }
            int num16 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num16; i++)
            {
                layoutData.m_VehicleRestartPhases.Add(new VehicleRestartPhaseProxy(bytes, ref offset));
            }
            int num17 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num17; i++)
            {
                layoutData.m_FlyingObjects.Add(new FlyingObjectProxy(bytes, ref offset));
            }
            int num18 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num18; i++)
            {
                layoutData.m_Rocks.Add(new RockProxy(bytes, ref offset));
            }
            int num19 = ByteSerializer.DeserializeInt(bytes, ref offset);

            for (int i = 0; i < num19; i++)
            {
                layoutData.m_WaterBlocks.Add(new WaterBlockProxy(layoutData.m_Version, bytes, ref offset));
            }
            if (layoutData.m_Version < 5)
            {
                int num20 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num20; i++)
                {
                    ByteSerializer.DeserializeString(bytes, ref offset);
                    int num21 = ByteSerializer.DeserializeInt(bytes, ref offset);
                    for (int j = 0; j < num21; j++)
                    {
                        ByteSerializer.DeserializeString(bytes, ref offset);
                    }
                }
            }
            layoutData.m_Budget.DeserializeBinary(bytes, ref offset);
            layoutData.m_Settings.DeserializeBinary(bytes, ref offset);
            if (layoutData.m_Version >= 9)
            {
                int num22 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num22; i++)
                {
                    layoutData.m_CustomShapes.Add(new CustomShapeProxy(layoutData.m_Version, bytes, ref offset));
                }
            }
            if (layoutData.m_Version >= 15)
            {
                layoutData.m_Workshop.DeserializeBinary(layoutData.m_Version, bytes, ref offset);
            }
            if (layoutData.m_Version >= 17)
            {
                int num23 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num23; i++)
                {
                    layoutData.m_SupportPillars.Add(new SupportPillarProxy(bytes, ref offset));
                }
            }
            if (layoutData.m_Version >= 18)
            {
                int num24 = ByteSerializer.DeserializeInt(bytes, ref offset);
                for (int i = 0; i < num24; i++)
                {
                    layoutData.m_Pillars.Add(new PillarProxy(bytes, ref offset));
                }
            }
            return(layoutData);
        }
コード例 #9
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.username = ByteSerializer.DeserializeString(bytes, ref offset);
     this.reason   = ByteSerializer.DeserializeString(bytes, ref offset);
 }
コード例 #10
0
 public void Deserialize(byte[] bytes, ref int offset)
 {
     this.type     = ByteSerializer.DeserializeString(bytes, ref offset);
     this.content  = ByteSerializer.DeserializeByteArray(bytes, ref offset);
     this.metadata = ByteSerializer.DeserializeString(bytes, ref offset);
 }