Exemple #1
0
        public static Vec2F FromStream(IStarboundStream stream)
        {
            Vec2F vec = new Vec2F();

            vec.X = stream.ReadSingle();
            vec.Y = stream.ReadSingle();

            return(vec);
        }
Exemple #2
0
        public static TileDamageParameters FromStream(IStarboundStream stream)
        {
            TileDamageParameters parameters = new TileDamageParameters();

            parameters.DamageFactors = stream.ReadVariant();
            parameters.TotalHealth   = stream.ReadSingle();

            return(parameters);
        }
Exemple #3
0
        public static TileDamage FromStream(IStarboundStream stream)
        {
            TileDamage dmg = new TileDamage();

            dmg.DamageType = (TileDamageType)stream.ReadUInt8();
            dmg.Amount     = stream.ReadSingle();

            return(dmg);
        }
Exemple #4
0
        public static Json FromStream(IStarboundStream stream)
        {
            var json = new Json();
            var type = stream.ReadUInt8();

            switch (type)
            {
            case 0:
                json.Value = null;
                break;

            case 1:
                json.Value = stream.ReadSingle();
                break;

            case 2:
                json.Value = stream.ReadBoolean();
                break;

            case 3:
                json.Value = stream.ReadInt32();
                break;

            case 4:
                json.Value = stream.ReadString();
                break;

            case 5:
                var array = new Json[stream.ReadVLQ()];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = FromStream(stream);
                }
                json.Value = array;
                break;

            case 6:
                var dict   = new JsonDict();
                var length = stream.ReadVLQ();
                while (length-- > 0)
                {
                    dict[stream.ReadString()] = FromStream(stream);
                }

                json.Value = dict;
                break;

            case 7:
                var dict1   = new JsonDict();
                var length2 = stream.ReadVLQ();
                while (length2-- > 0)
                {
                    dict1[stream.ReadString()] = FromStream(stream);
                }

                json.Value = dict1;
                break;

            default:
                throw new InvalidOperationException(string.Format("Unknown Json type: 0x{0:X2}", type));
            }
            return(json);
        }