Example #1
0
        public static SpawnedEntity FromStream(IStarboundStream stream)
        {
            SpawnedEntity se;
            EntityType    et = (EntityType)stream.ReadUInt8();

            byte[] storeData = stream.ReadUInt8Array((int)(stream.Length - stream.Position));


            using (StarboundStream ss = new StarboundStream(storeData))
            {
                if (et == EntityType.Projectile)
                {
                    var sp = new SpawnedProjectile();
                    sp.ProjectileKey = ss.ReadString();
                    sp.Parameters    = ss.ReadVariant();

                    se = sp;
                }
                else
                {
                    se = new SpawnedEntity();
                }
            }

            se.EntityType = et;
            se.StoreData  = storeData;

            return(se);
        }
Example #2
0
        public static TileDamage FromStream(IStarboundStream stream)
        {
            TileDamage dmg = new TileDamage();

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

            return(dmg);
        }
Example #3
0
        public static InteractAction FromStream(IStarboundStream stream)
        {
            InteractAction action = new InteractAction();

            action.ActionType = (InteractActionType)stream.ReadUInt8();
            action.EntityId   = stream.ReadInt32();
            action.Data       = stream.ReadVariant();

            return(action);
        }
Example #4
0
        public override void Read(IStarboundStream stream)
        {
            cm          = (ChatMode)stream.ReadUInt8();
            ChannelName = stream.ReadString();
            ClientId    = stream.ReadUInt32();
            Name        = stream.ReadString();
            Message     = stream.ReadString();

            /*
             * World = stream.ReadString();
             */
        }
Example #5
0
        public static Variant FromStream(IStarboundStream stream)
        {
            var  variant = new Variant();
            byte type    = stream.ReadUInt8();

            switch (type)
            {
            case 1:
                variant.Value = null;
                break;

            case 2:
                variant.Value = stream.ReadDouble();
                break;

            case 3:
                variant.Value = stream.ReadBoolean();
                break;

            case 4:
                variant.Value = stream.ReadVLQ();
                break;

            case 5:
                variant.Value = stream.ReadString();
                break;

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

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

                variant.Value = dict;
                break;

            default:
                throw new InvalidOperationException(string.Format("Unknown Variant type: 0x{0:X2}", type));
            }
            return(variant);
        }
Example #6
0
        public static Document FromStream(IStarboundStream stream)
        {
            Document doc = new Document();

            doc.Name = stream.ReadString();

            stream.ReadUInt8();

            doc.Version = DataConverter.BigEndian.GetInt32(stream.ReadUInt8Array(4), 0);

            doc.Data = stream.ReadVariant();

            return(doc);
        }
Example #7
0
        public static NetTile FromStream(IStarboundStream stream)
        {
            var netT = new NetTile();

            netT.background             = stream.ReadUInt16();
            netT.backgroundHueShift     = stream.ReadUInt8();
            netT.backgroundColorVariant = stream.ReadUInt8();
            netT.backgroundMod          = stream.ReadUInt16();
            netT.backgroundModHueShift  = stream.ReadUInt8();
            netT.foreground             = stream.ReadUInt16();
            netT.foregroundHueShift     = stream.ReadUInt8();
            netT.foregroundColorVariant = stream.ReadUInt8();
            netT.foregroundMod          = stream.ReadUInt16();
            netT.foregroundModHueShift  = stream.ReadUInt8();
            netT.collision             = stream.ReadUInt8();
            netT.blockBiomeIndex       = stream.ReadUInt8();
            netT.environmentBiomeIndex = stream.ReadUInt8();
            netT.LiquidLevel           = stream.ReadUInt8();
            netT.Gravity   = stream.ReadFloat();
            netT.DungeonID = stream.ReadUInt16();

            return(netT);
        }
Example #8
0
        public override void Read(IStarboundStream stream)
        {
            ulong vlq = stream.ReadVLQ();

            Position = new List <Vec2I>();

            for (int i = 0; i < (int)vlq; i++)
            {
                Vec2I vec = Vec2I.FromStream(stream);

                Position.Add(vec);
            }

            Layer      = (TileLayer)stream.ReadUInt8();
            SourcePos  = Vec2F.FromStream(stream);
            TileDamage = TileDamage.FromStream(stream);
        }
Example #9
0
 public override void Read(IStarboundStream stream)
 {
     Text = stream.ReadString();
     cm   = (ChatSendMode)stream.ReadUInt8();
 }
 public override void Read(IStarboundStream stream)
 {
     NumPairs      = stream.ReadUInt8();
     PropertyName  = stream.ReadString();
     PropertyValue = stream.ReadVariant();
 }
 public override void Read(IStarboundStream stream)
 {
     Position   = Vec2I.FromStream(stream);
     Layer      = (TileLayer)stream.ReadUInt8();
     TileDamage = TileDamageStatus.FromStream(stream);
 }
Example #12
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);
        }
Example #13
0
 public override void Read(IStarboundStream stream)
 {
     Message = stream.ReadString();
     Channel = stream.ReadUInt8();
 }
Example #14
0
        public static Entity FromStream(IStarboundStream stream)
        {
            EntityType et = (EntityType)stream.ReadUInt8();

            byte[] storeData = stream.ReadUInt8Array();

            Entity ent;

            if (et == EntityType.Projectile)
            {
                ProjectileEntity pent = new ProjectileEntity();

                using (StarboundStream s = new StarboundStream(storeData))
                {
                    pent.Projectile      = s.ReadString();
                    pent.Information     = s.ReadVariant().Value as VariantDict;
                    pent.Unknown1        = s.ReadUInt8Array(17);
                    pent.ThrowerEntityId = s.ReadSignedVLQ();
                    pent.Unknown2        = s.ReadUInt8Array((int)(s.Length - s.Position));
                }

                ent = pent;
            }
            else if (et == EntityType.Player)
            {
                PlayerEntity pent = new PlayerEntity();

                using (StarboundStream s = new StarboundStream(storeData))
                {
                    /*
                     * bool uuid = s.ReadBoolean();
                     *
                     * if (uuid)
                     * {
                     */
                    byte[] uuidDat = s.ReadUInt8Array(16);

                    pent.UUID = BitConverter.ToString(uuidDat, 0).Replace("-", "").ToLower();

                    //}
                }

                ent = pent;
            }
            else if (et == EntityType.Object)
            {
                ObjectEntity oent = new ObjectEntity();

                using (StarboundStream s = new StarboundStream(storeData))
                {
                    oent.Object      = s.ReadString();
                    oent.Information = s.ReadVariant();
                    oent.Unknown     = s.ReadUInt8Array((int)(s.Length - s.Position));
                }

                ent = oent;
            }
            else
            {
                ent = new Entity();
            }

            ent.EntityType = et;
            ent.StoreData  = storeData;
            ent.EntityId   = stream.ReadSignedVLQ();

            return(ent);
        }
 public override void Read(IStarboundStream stream)
 {
     Unknown = stream.ReadUInt8();
 }
 public override void Read(IStarboundStream stream)
 {
     Position = Vec2I.FromStream(stream);
     LiquidId = stream.ReadUInt8();
     Level    = stream.ReadUInt8();
 }