public static void SaveToBin(Status item, BinaryWriter writer)
        {
            writer.Write(item.CurrentHealth);
            writer.Write(item.MaxHealth);
            writer.Write(item.CurrentEnergy);
            writer.Write(item.MaxEnergy);
            writer.Write(item.CurrentWarmth);
            writer.Write(item.MaxWarmth);
            writer.Write(item.CurrentFood);
            writer.Write(item.MaxFood);
            writer.Write(item.CurrentBreath);
            writer.Write(item.MaxBreath);
            writer.Write(item.Invulnerable);

            for (int i = 0; i < 3; i++)
            {
                writer.Write(item.GlowColor[i]);
            }

            PackedInt.SaveToBin(new PackedInt()
            {
                Value = (ulong)item.ActiveEffects.Count
            }, writer);

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

            PackedInt.SaveToBin(new PackedInt()
            {
                Value = (ulong)item.EffectSources.Count
            }, writer);

            for (int i = 0; i < item.EffectSources.Count; i++)
            {
                StringIO.SaveToBin(item.EffectSources[i], writer);
            }
        }
        public PackedInt GetSizeOfData()
        {
            ulong result = 0;

            PackedInt value = new PackedInt()
            {
                Value = this.Value
            };

            ulong position = 1;

            while (position < value.Value)
            {
                result++;
                value.Value >>= 7;
                position     *= 2;
            }

            return(new PackedInt()
            {
                Value = result
            });
        }
        public static Variant LoadFromBin(BinaryReader reader)
        {
            Variant result = new Variant();

            result.DataType = reader.ReadByte();

            switch (result.DataType)
            {
            case 2: result.Data = reader.ReadDouble(); break;

            case 3: result.Data = reader.ReadBoolean(); break;

            case 4: result.Data = PackedInt.LoadFromBin(reader); break;

            case 5: result.Data = StringIO.LoadFromBin(reader); break;

            case 6: result.Data = PackedVariant.LoadFromBin(reader); break;

            case 7: result.Data = VariantDict.LoadFromBin(reader); break;
            }

            return(result);
        }
Exemplo n.º 4
0
        public static PlayerInventory LoadFromBin(BinaryReader reader)
        {
            PlayerInventory result = new PlayerInventory();

            PackedInt dataLength = PackedInt.LoadFromBin(reader);

            result.Pixels = reader.ReadUInt64();

            result.ItemBags = new ItemBag[NUM_ITEM_BAGS];

            for (int i = 0; i < NUM_ITEM_BAGS; i++)
            {
                result.ItemBags[i] = ItemBag.LoadFromBin(reader);
            }

            result.CurrentItem        = Item.LoadFromBin(reader);
            result.PrimaryHandSlotBag = reader.ReadByte();
            result.PrimaryHandSlot    = PackedInt.LoadFromBin(reader);
            result.AltHandSlotBag     = reader.ReadByte();
            result.AltHandSlot        = PackedInt.LoadFromBin(reader);

            return(result);
        }
 public static void SaveToBin(Item item, BinaryWriter writer)
 {
     StringIO.SaveToBin(item.Name, writer);
     PackedInt.SaveToBin(item.Stack, writer);
     Variant.SaveToBin(item.ItemParams, writer);
 }