Esempio n. 1
0
        public static TechController LoadFromBin(BinaryReader reader)
        {
            TechController result = new TechController();

            PackedInt sizeOfData = PackedInt.LoadFromBin(reader);
            long      endPos     = reader.BaseStream.Position + (long)sizeOfData.Value;

            PackedInt numTechs = PackedInt.LoadFromBin(reader);

            for (ulong i = 0; i < numTechs.Value; i++)
            {
                result.Tech.Add(StringIO.LoadFromBin(reader));
            }

            long numUnkBytes = endPos - reader.BaseStream.Position;

            result.UNK_ARR_1 = new byte[(int)numUnkBytes];

            for (long i = 0; i < numUnkBytes; i++)
            {
                result.UNK_ARR_1[i] = reader.ReadByte();
            }

            return(result);
        }
        public static void SaveToBin(Player item, BinaryWriter writer)
        {
            PackedInt.SaveToBin(item.GetSizeOfData(), writer);
            writer.Write(item.HasUUID);
            if (item.HasUUID)
            {
                for (int i = 0; i < UUID_LENGTH; i++)
                {
                    if (i >= 0 && i < item.UUID.Length)
                    {
                        writer.Write(item.UUID[i]);
                    }
                    else
                    {
                        writer.Write((byte)30);
                    }
                }
            }

            Humanoid.SaveToBin(item.HumanoidEntity, writer);
            EntityStatus.SaveToBin(item.DefaultStatus, writer);
            Status.SaveToBin(item.CurrentStatus, writer);
            StringIO.SaveToBin(item.Description, writer);
            writer.Write(item.PlayingTime);
            PlayerInventory.SaveToBin(item.Inventory, writer);
            BlueprintData.SaveToBin(item.Blueprints, writer);
            TechController.SaveToBin(item.Tech, writer);
            Armor.SaveToBin(item.EquippedArmor, writer);
            Item.SaveToBin(item.LeftHandItem, writer);
            Item.SaveToBin(item.RightHandItem, writer);
        }
        public static Player LoadFromBin(BinaryReader reader)
        {
            Player result = new Player();

            PackedInt lengthOfData = PackedInt.LoadFromBin(reader);

            result.HasUUID = reader.ReadBoolean();
            if (result.HasUUID)
            {
                result.UUID = new byte[UUID_LENGTH];

                for (int i = 0; i < UUID_LENGTH; i++)
                {
                    result.UUID[i] = reader.ReadByte();
                }
            }

            result.HumanoidEntity = Humanoid.LoadFromBin(reader);
            result.DefaultStatus  = EntityStatus.LoadFromBin(reader);
            result.CurrentStatus  = Status.LoadFromBin(reader);
            result.Description    = StringIO.LoadFromBin(reader);
            result.PlayingTime    = reader.ReadDouble();
            result.Inventory      = PlayerInventory.LoadFromBin(reader);
            result.Blueprints     = BlueprintData.LoadFromBin(reader);
            result.Tech           = TechController.LoadFromBin(reader);
            result.EquippedArmor  = Armor.LoadFromBin(reader);
            result.LeftHandItem   = Item.LoadFromBin(reader);
            result.RightHandItem  = Item.LoadFromBin(reader);

            return(result);
        }
Esempio n. 4
0
        public static void SaveToBin(TechController item, BinaryWriter writer)
        {
            PackedInt.SaveToBin(item.GetSizeOfData(), writer);
            PackedInt.SaveToBin(new PackedInt()
            {
                Value = (ulong)item.Tech.Count
            }, writer);

            for (int i = 0; i < item.Tech.Count; i++)
            {
                StringIO.SaveToBin(item.Tech[i], writer);
            }

            for (int i = 0; i < item.Tech.Count; i++)
            {
                writer.Write(item.UNK_ARR_1[i]);
            }
        }