Пример #1
0
        public static void Deserialize(ZPackage package)
        {
            ZoneT.Clear();
            int tnum = package.ReadInt();

            for (int i = 0; i < tnum; i++)
            {
                ZoneT.Add(new ZoneTypes
                {
                    Name            = package.ReadString(),
                    PVP             = package.ReadBool(),
                    PVPEnforce      = package.ReadBool(),
                    ShowPosition    = package.ReadBool(),
                    PositionEnforce = package.ReadBool(),
                    Admins          = package.ReadString(),
                    Configurations  = package.ReadString()
                });
            }
            Zones.Clear();
            int num = package.ReadInt();

            for (int i = 0; i < num; i++)
            {
                Zones.Add(new Zone
                {
                    ID       = package.ReadInt(),
                    Name     = package.ReadString(),
                    Type     = package.ReadString(),
                    Priority = package.ReadInt(),
                    Shape    = package.ReadString(),
                    Position = new Vector2(package.ReadSingle(), package.ReadSingle()),
                    Radius   = package.ReadSingle(),
                });
            }
        }
Пример #2
0
        public void Load(ZPackage pkg)
        {
            int propertyCount = pkg.ReadInt();

            for (int i = 0; i < propertyCount; i++)
            {
                var key      = pkg.ReadString();
                var dataType = (TyrDataType)Enum.ToObject(typeof(TyrDataType), pkg.ReadInt());
                if (dataType == TyrDataType.FLOAT)
                {
                    var val = pkg.ReadSingle();
                    m_properties[key] = new TyrProperty(key, val, true);
                }
                else if (dataType == TyrDataType.INT)
                {
                    var val = pkg.ReadInt();
                    m_properties[key] = new TyrProperty(key, val, true);
                }
                else if (dataType == TyrDataType.LONG)
                {
                    var val = pkg.ReadLong();
                    m_properties[key] = new TyrProperty(key, val, true);
                }
                else if (dataType == TyrDataType.STRING)
                {
                    var val = pkg.ReadString();
                    m_properties[key] = new TyrProperty(key, val, true);
                }
            }
        }
Пример #3
0
 // Token: 0x06000DBC RID: 3516 RVA: 0x00062418 File Offset: 0x00060618
 public void Deserialize(ref ZPackage pkg)
 {
     this.m_damage.m_damage    = pkg.ReadSingle();
     this.m_damage.m_blunt     = pkg.ReadSingle();
     this.m_damage.m_slash     = pkg.ReadSingle();
     this.m_damage.m_pierce    = pkg.ReadSingle();
     this.m_damage.m_chop      = pkg.ReadSingle();
     this.m_damage.m_pickaxe   = pkg.ReadSingle();
     this.m_damage.m_fire      = pkg.ReadSingle();
     this.m_damage.m_frost     = pkg.ReadSingle();
     this.m_damage.m_lightning = pkg.ReadSingle();
     this.m_damage.m_poison    = pkg.ReadSingle();
     this.m_damage.m_spirit    = pkg.ReadSingle();
     this.m_toolTier           = pkg.ReadInt();
     this.m_pushForce          = pkg.ReadSingle();
     this.m_backstabBonus      = pkg.ReadSingle();
     this.m_staggerMultiplier  = pkg.ReadSingle();
     this.m_dodgeable          = pkg.ReadBool();
     this.m_blockable          = pkg.ReadBool();
     this.m_point        = pkg.ReadVector3();
     this.m_dir          = pkg.ReadVector3();
     this.m_statusEffect = pkg.ReadString();
     this.m_attacker     = pkg.ReadZDOID();
     this.m_skill        = (Skills.SkillType)pkg.ReadInt();
 }
Пример #4
0
    // Token: 0x0600072F RID: 1839 RVA: 0x0003A2D0 File Offset: 0x000384D0
    private void RPC_ServerList(ZRpc rpc, ZPackage pkg)
    {
        this.m_haveServerlist = true;
        this.m_serverListRevision++;
        pkg.ReadInt();
        int num = pkg.ReadInt();

        this.m_servers.Clear();
        for (int i = 0; i < num; i++)
        {
            ServerData serverData = new ServerData();
            serverData.m_name     = pkg.ReadString();
            serverData.m_host     = pkg.ReadString();
            serverData.m_port     = pkg.ReadInt();
            serverData.m_password = pkg.ReadBool();
            serverData.m_upnp     = pkg.ReadBool();
            pkg.ReadLong();
            serverData.m_version = pkg.ReadString();
            serverData.m_players = pkg.ReadInt();
            if (this.m_nameFilter.Length <= 0 || serverData.m_name.Contains(this.m_nameFilter))
            {
                this.m_servers.Add(serverData);
            }
        }
        if (this.m_onServerList != null)
        {
            this.m_onServerList(this.m_servers);
        }
    }
Пример #5
0
        /// <summary>
        ///     Create a <see cref="Portal" /> list from a <see cref="ZPackage" />
        /// </summary>
        /// <param name="zpkg"></param>
        /// <returns></returns>
        public static PortalList FromZPackage(ZPackage zpkg)
        {
            Logger.LogDebug("Deserializing portal list from ZPackage");

            var ret = new PortalList();

            var numConnectedPortals = zpkg.ReadInt();

            while (numConnectedPortals > 0)
            {
                var portalPosition = zpkg.ReadVector3();
                var portalName     = zpkg.ReadString();

                Logger.LogDebug($"{portalName}@{portalPosition}");
                ret.Add(new Portal(portalPosition, portalName, true));

                numConnectedPortals--;
            }

            var numUnconnectedPortals = zpkg.ReadInt();

            while (numUnconnectedPortals > 0)
            {
                var portalPosition = zpkg.ReadVector3();
                var portalName     = zpkg.ReadString();

                Logger.LogDebug($"{portalName}@{portalPosition}");
                ret.Add(new Portal(portalPosition, portalName, false));

                numUnconnectedPortals--;
            }

            return(ret);
        }
Пример #6
0
        public static void SetMapData(ZPackage mapData)
        {
            ServerPins.Clear();

            var version = mapData.ReadInt();
            var mapSize = mapData.ReadInt();

            var explored = new bool[mapSize * mapSize];

            for (var i = 0; i < mapSize * mapSize; i++)
            {
                explored[i] = mapData.ReadBool();
            }

            var pinCount = mapData.ReadInt();

            for (var i = 0; i < pinCount; i++)
            {
                var pin = new PinData
                {
                    Name    = mapData.ReadString(),
                    Pos     = mapData.ReadVector3(),
                    Type    = (Minimap.PinType)mapData.ReadInt(),
                    Checked = mapData.ReadBool()
                };
                ServerPins.Add(pin);
            }

            Explored = explored;
        }
Пример #7
0
    // Token: 0x06000C0A RID: 3082 RVA: 0x000559B8 File Offset: 0x00053BB8
    public static World LoadWorld(string name)
    {
        FileStream fileStream = null;

        try
        {
            fileStream = File.OpenRead(World.GetMetaPath(name));
        }
        catch
        {
            if (fileStream != null)
            {
                fileStream.Dispose();
            }
            ZLog.Log("  failed to load " + name);
            return(new World(name, true, false));
        }
        World result;

        try
        {
            BinaryReader binaryReader = new BinaryReader(fileStream);
            int          count        = binaryReader.ReadInt32();
            ZPackage     zpackage     = new ZPackage(binaryReader.ReadBytes(count));
            int          num          = zpackage.ReadInt();
            if (!global::Version.IsWorldVersionCompatible(num))
            {
                ZLog.Log("incompatible world version " + num);
                result = new World(name, false, true);
            }
            else
            {
                World world = new World();
                world.m_name     = zpackage.ReadString();
                world.m_seedName = zpackage.ReadString();
                world.m_seed     = zpackage.ReadInt();
                world.m_uid      = zpackage.ReadLong();
                if (num >= 26)
                {
                    world.m_worldGenVersion = zpackage.ReadInt();
                }
                result = world;
            }
        }
        catch
        {
            ZLog.LogWarning("  error loading world " + name);
            result = new World(name, true, false);
        }
        finally
        {
            if (fileStream != null)
            {
                fileStream.Dispose();
            }
        }
        return(result);
    }
Пример #8
0
        public static BountyTargetInfo FromPackage(ZPackage pkg)
        {
            var result = new BountyTargetInfo();

            result.MonsterID = pkg.ReadString();
            result.Count     = pkg.ReadInt();
            result.Level     = pkg.ReadInt();
            return(result);
        }
Пример #9
0
        /// <summary>
        ///     Receive and handle an incoming package
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="package"></param>
        internal void ReceivePackage(long sender, ZPackage package)
        {
            if (package == null || package.Size() <= 0)
            {
                return;
            }

            Logger.LogDebug($"[{ID}] Received package");
            try
            {
                CacheExpirations.RemoveAll(kv =>
                {
                    if (kv.Key < DateTimeOffset.Now.Ticks)
                    {
                        PackageCache.Remove(kv.Value);
                        return(true);
                    }

                    return(false);
                });

                byte packageFlags = package.ReadByte();

                if ((packageFlags & FRAGMENTED_PACKAGE) != 0)
                {
                    long   uniqueIdentifier = package.ReadLong();
                    string cacheKey         = sender.ToString() + uniqueIdentifier;
                    int    fragment         = package.ReadInt();
                    int    fragments        = package.ReadInt();

                    if (!PackageCache.TryGetValue(cacheKey, out SortedDictionary <int, byte[]> dataFragments))
                    {
                        dataFragments          = new SortedDictionary <int, byte[]>();
                        PackageCache[cacheKey] = dataFragments;
                        CacheExpirations.Add(new KeyValuePair <long, string>(DateTimeOffset.Now.AddSeconds(60).Ticks, cacheKey));
                    }

                    dataFragments.Add(fragment, package.ReadByteArray());

                    if (dataFragments.Count < fragments)
                    {
                        return;
                    }

                    PackageCache.Remove(cacheKey);

                    package      = new ZPackage(dataFragments.Values.SelectMany(a => a).ToArray());
                    packageFlags = package.ReadByte();
                }

                ZNet.instance.StartCoroutine(HandlePackageRoutine(sender, package, packageFlags));
            }
            catch (Exception e)
            {
                Logger.LogWarning($"[{ID}] Error caught while applying package: {e}");
            }
        }
Пример #10
0
        private static void onReceiveMapData(ZRpc client, ZPackage mapData)
        {
            int x = mapData.ReadInt();
            int y = mapData.ReadInt();

            var  m    = Traverse.Create(typeof(Minimap)).Field("m_instance").GetValue() as Minimap;
            bool flag = _Minimap.Explore(m, x, y);

            dirty = flag || dirty;
        }
Пример #11
0
        // TODO: Move to ExplorationMapSync.cs
        public static void OnReceiveMapData(ZRpc client, ZPackage mapData)
        {
            mapData.SetPos(0);

            var x = mapData.ReadInt();
            var y = mapData.ReadInt();

            var m    = Traverse.Create(typeof(Minimap)).Field("m_instance").GetValue() as Minimap;
            var flag = _Minimap.Explore(m, x, y);

            _dirty = flag || _dirty;
        }
        // Token: 0x060006B0 RID: 1712 RVA: 0x000377B4 File Offset: 0x000359B4
        public static Inventory Load(ZPackage pkg)
        {
            var inventory = new Inventory();

            int num  = pkg.ReadInt();
            int num2 = pkg.ReadInt();

            inventory.m_inventory.Clear();
            for (int i = 0; i < num2; i++)
            {
                string   text       = pkg.ReadString();
                int      stack      = pkg.ReadInt();
                float    durability = pkg.ReadSingle();
                Vector2i pos        = pkg.ReadVector2i();
                bool     equiped    = pkg.ReadBool();
                int      quality    = 1;
                if (num >= 101)
                {
                    quality = pkg.ReadInt();
                }
                int variant = 0;
                if (num >= 102)
                {
                    variant = pkg.ReadInt();
                }
                long   crafterID   = 0L;
                string crafterName = "";
                if (num >= 103)
                {
                    crafterID   = pkg.ReadLong();
                    crafterName = pkg.ReadString();
                }
                if (text != "")
                {
                    var item = new InventoryItem()
                    {
                        prefabName    = text,
                        m_stack       = stack,
                        m_durability  = durability,
                        m_gridPos     = pos,
                        m_equiped     = equiped,
                        m_quality     = quality,
                        m_variant     = variant,
                        m_crafterID   = crafterID,
                        m_crafterName = crafterName
                    };
                    inventory.m_inventory.Add(item);
                }
            }

            return(inventory);
        }
Пример #13
0
        public static BountyInfo FromPackage(ZPackage pkg)
        {
            var result  = new BountyInfo();
            var version = pkg.ReadInt();

            result.Interval            = pkg.ReadInt();
            result.PlayerID            = pkg.ReadLong();
            result.Biome               = (Heightmap.Biome)pkg.ReadInt();
            result.State               = (BountyState)pkg.ReadInt();
            result.Target              = BountyTargetInfo.FromPackage(pkg);
            result.TargetName          = pkg.ReadString();
            result.RewardIron          = pkg.ReadInt();
            result.RewardGold          = pkg.ReadInt();
            result.RewardCoins         = pkg.ReadInt();
            result.Position            = SerializableVector3.FromPackage(pkg);
            result.MinimapCircleOffset = SerializableVector3.FromPackage(pkg);

            var addsCount = pkg.ReadInt();

            result.Adds = new List <BountyTargetInfo>();
            for (var index = 0; index < addsCount; index++)
            {
                result.Adds.Add(BountyTargetInfo.FromPackage(pkg));
            }

            result.Slain = pkg.ReadBool();

            return(result);
        }
Пример #14
0
        public static void RPC_UpdateInventory(ZRpc rpc, ZPackage pkg)
        {
            String characterName = pkg.ReadString();
            int    itemsCount    = pkg.ReadInt();

            String steamId = rpc.GetSocket().GetEndPointString();

            List <Server_ItemData> playerItems = new List <Server_ItemData>();

            for (int i = 0; i < itemsCount; i++)
            {
                Server_ItemData data = new Server_ItemData
                {
                    Name    = pkg.ReadString(),
                    Stack   = pkg.ReadInt(),
                    Quality = pkg.ReadInt(),
                    Variant = pkg.ReadInt()
                };

                playerItems.Add(data);
            }

            String dbId     = $"{steamId}_{characterName}";
            var    dbPlayer = Instance.DB.GetPlayerById(dbId);

            if (dbPlayer == null)
            {
                dbPlayer = new DBClasses.DBPlayer()
                {
                    DBPlayerId    = dbId,
                    SteamId       = steamId,
                    CharacterName = characterName,
                    Items         = new List <DBClasses.DBItem>()
                };

                foreach (var item in playerItems)
                {
                    dbPlayer.Items.Add(new DBClasses.DBItem()
                    {
                        ItemName = item.Name, PlayerId = dbPlayer.DBPlayerId, StackCount = item.Stack, Quality = item.Quality, Variant = item.Variant
                    });
                }

                Instance.DB.InsertPlayer(dbPlayer);
            }
            else
            {
                Instance.DB.UpdatePlayer(dbPlayer);
            }
        }
Пример #15
0
    public void ReadBiomeData(ref ZPackage package)
    {
        // mountain
        minMountainHeight = package.ReadSingle();

        // ashlands/deepnorth
        minAshlandsDist  = package.ReadSingle();
        minDeepNorthDist = package.ReadSingle();

        // swamp
        swampBiomeScaleX = package.ReadSingle();
        swampBiomeScaleY = package.ReadSingle();
        minSwampNoise    = package.ReadSingle();
        minSwampDist     = package.ReadSingle();
        maxSwampDist     = package.ReadSingle();
        minSwampHeight   = package.ReadSingle();
        maxSwampHeight   = package.ReadSingle();

        // mistlands
        mistlandsBiomeScaleX = package.ReadSingle();
        mistlandsBiomeScaleY = package.ReadSingle();
        minMistlandsNoise    = package.ReadSingle();
        minMistlandsDist     = package.ReadSingle();
        maxMistlandsDist     = package.ReadSingle();

        // plains
        plainsBiomeScaleX = package.ReadSingle();
        plainsBiomeScaleY = package.ReadSingle();
        minPlainsNoise    = package.ReadSingle();
        minPlainsDist     = package.ReadSingle();
        maxPlainsDist     = package.ReadSingle();

        // black forest
        blackForestBiomeScaleX = package.ReadSingle();
        blackForestBiomeScaleY = package.ReadSingle();
        minBlackForestNoise    = package.ReadSingle();
        minBlackForestDist     = package.ReadSingle();
        maxBlackForestDist     = package.ReadSingle();

        // switches
        meadowsSwitch     = (Heightmap.Biome)package.ReadInt();
        blackForestSwitch = (Heightmap.Biome)package.ReadInt();
        swampSwitch       = (Heightmap.Biome)package.ReadInt();
        mountainSwitch    = (Heightmap.Biome)package.ReadInt();
        plainsSwitch      = (Heightmap.Biome)package.ReadInt();
        mistlandsSwitch   = (Heightmap.Biome)package.ReadInt();
        ashlandsSwitch    = (Heightmap.Biome)package.ReadInt();
        deepNorthSwitch   = (Heightmap.Biome)package.ReadInt();

        // river
        riverMultipleMaxDistance = package.ReadSingle();
        riverExtremeMaxDistance  = package.ReadSingle();
        riverMaxHeight           = package.ReadSingle();
        riverWidthMaxLowerRange  = package.ReadSingle();
        riverWidthMaxUpperRange  = package.ReadSingle();
        riverWidthMinLowerRange  = package.ReadSingle();
        riverCurveWidth          = package.ReadSingle();
        riverWavelength          = package.ReadSingle();
    }
Пример #16
0
        public bool CreateMergedWorldWithPins(out string error)
        {
            try
            {
                error = string.Empty;
                foreach (var pp in _profiles)
                {
                    ZPackage zPackage = new ZPackage(pp.m_worldData[_worldId].m_mapData);
                    _mapData.m_mapVersion = zPackage.ReadInt();
                    int textureSize = zPackage.ReadInt();

                    if (_mapData.m_textureSize != textureSize)
                    {
                        return(false);
                    }

                    for (int i = 0; i < (_mapData.m_textureSize * _mapData.m_textureSize); i++)
                    {
                        _mapData.m_mergedWorld[i] = (byte)(_mapData.m_mergedWorld[i] | Convert.ToByte(zPackage.ReadBool()));
                    }

                    if (_mapData.m_mapVersion >= 2)
                    {
                        int pinCount = zPackage.ReadInt();
                        for (int j = 0; j < pinCount; j++)
                        {
                            string  name      = zPackage.ReadString();
                            Vector3 pos       = zPackage.ReadVector3();
                            PinType type      = (PinType)zPackage.ReadInt();
                            bool    isChecked = _mapData.m_mapVersion >= 3 && zPackage.ReadBool();

                            _mapData.AddPin(name, pos, type, isChecked);
                            _mapData.AddProfilePin(pp.GetPlayerId(), name, pos, type, isChecked);
                        }
                    }
                    if (_mapData.m_mapVersion >= 4)
                    {
                        _mapData.m_isReferencePositionPublic = zPackage.ReadBool();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Пример #17
0
        /// <summary>
        /// Sync Pin with clients via the server
        /// </summary>
        public static void RPC_VPlusMapPinSync(long sender, ZPackage mapPinPkg)
        {
            if (ZNet.m_isServer) //Server
            {
                if (sender == ZRoutedRpc.instance.GetServerPeerID())
                {
                    return;
                }

                if (mapPinPkg == null)
                {
                    return;
                }

                foreach (ZNetPeer peer in ZRoutedRpc.instance.m_peers)
                {
                    if (peer.m_uid != sender)
                    {
                        ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "VPlusMapPinSync", new object[] { mapPinPkg });
                    }
                }

                ZLog.Log($"Sent map pin to all clients");
                //VPlusAck.SendAck(sender);
            }
            else //Client
            {
                if (sender != ZRoutedRpc.instance.GetServerPeerID())
                {
                    return;                                                  //Only bother if it's from the server.
                }
                if (mapPinPkg == null)
                {
                    ZLog.LogWarning("Warning: Got empty map pin package from server.");
                    return;
                }
                long   pinSender  = mapPinPkg.ReadLong();
                string senderName = mapPinPkg.ReadString();
                if (senderName != Player.m_localPlayer.GetPlayerName() && pinSender != ZRoutedRpc.instance.m_id)
                {
                    ZLog.Log("Checking sent pin");
                    Vector3 pinPos    = mapPinPkg.ReadVector3();
                    int     pinType   = mapPinPkg.ReadInt();
                    string  pinName   = mapPinPkg.ReadString();
                    bool    keepQuiet = mapPinPkg.ReadBool();
                    if (!Minimap.instance.HaveSimilarPin(pinPos, (Minimap.PinType)pinType, pinName, true))
                    {
                        Minimap.PinData addedPin = Minimap.instance.AddPin(pinPos, (Minimap.PinType)pinType, pinName, true, false);
                        if (!keepQuiet)
                        {
                            MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, $"Received map pin {pinName} from {senderName}!",
                                                            0, Minimap.instance.GetSprite((Minimap.PinType)pinType));
                        }
                        ZLog.Log($"I got pin named {pinName} from {senderName}!");
                    }
                }
                //Send Ack
                //VPlusAck.SendAck(sender);
            }
        }
Пример #18
0
        private void ZSteamSocket_Send(ZSteamSocket self, ZPackage pkg)
        {
            if (!(_isModEnabled.Value && _isOutputEnabled.Value))
            {
                return;
            }

            pkg.SetPos(0);
            int methodHash = pkg.ReadInt();

            if (methodHash == 0)
            {
                Logger.LogMessage($"Sending RPC Ping to {self.GetHostName()}");
            }
            else
            {
                try
                {
                    string method = pkg.ReadString();

                    if (method == "RoutedRPC")
                    {
                        ZPackage wrapped = pkg.ReadPackage();
                        _      = wrapped.ReadInt();
                        method = pkg.ReadString();
                    }

                    Logger.LogMessage($"Sending RPC {method} to {self.GetHostName()}");
                }
                catch (Exception) { }
            }
        }
Пример #19
0
        private void ZSteamSocket_Recv(ZSteamSocket self, ZPackage pkg)
        {
            if (!(_isModEnabled.Value && _isOutputEnabled.Value))
            {
                return;
            }

            if (pkg != null)
            {
                int methodHash = pkg.ReadInt();
                if (methodHash == 0)
                {
                    Logger.LogMessage($"Received RPC Ping");
                }
                else
                {
                    try
                    {
                        string method = pkg.ReadString();

                        if (method == "RoutedRPC")
                        {
                            ZPackage wrapped = pkg.ReadPackage();
                            _      = wrapped.ReadInt();
                            method = pkg.ReadString();
                        }

                        Logger.LogMessage($"Received RPC {method}");
                    }
                    catch (Exception) { }
                }
                pkg.SetPos(0);
            }
        }
Пример #20
0
    // Token: 0x060004DD RID: 1245 RVA: 0x00028508 File Offset: 0x00026708
    private void RPC_DamageText(long sender, ZPackage pkg)
    {
        Camera mainCamera = Utils.GetMainCamera();

        if (!mainCamera)
        {
            return;
        }
        if (Hud.IsUserHidden())
        {
            return;
        }
        DamageText.TextType type   = (DamageText.TextType)pkg.ReadInt();
        Vector3             vector = pkg.ReadVector3();
        float dmg  = pkg.ReadSingle();
        bool  flag = pkg.ReadBool();
        float num  = Vector3.Distance(mainCamera.transform.position, vector);

        if (num > this.m_maxTextDistance)
        {
            return;
        }
        bool mySelf = flag && sender == ZNet.instance.GetUID();

        this.AddInworldText(type, vector, num, dmg, mySelf);
    }
Пример #21
0
    // Token: 0x0600090D RID: 2317 RVA: 0x0004331C File Offset: 0x0004151C
    private void HandlePackage(ZPackage package)
    {
        int num = package.ReadInt();

        if (num == 0)
        {
            this.ReceivePing(package);
            return;
        }
        ZRpc.RpcMethodBase rpcMethodBase2;
        if (ZRpc.m_DEBUG)
        {
            package.ReadString();
            ZRpc.RpcMethodBase rpcMethodBase;
            if (this.m_functions.TryGetValue(num, out rpcMethodBase))
            {
                rpcMethodBase.Invoke(this, package);
                return;
            }
        }
        else if (this.m_functions.TryGetValue(num, out rpcMethodBase2))
        {
            rpcMethodBase2.Invoke(this, package);
        }
    }
        public static void OnReceiveMapDataInitial(ZRpc client, ZPackage mapData)
        {
            if (!Store.IsSharingMap())
            {
                return;
            }

            mapData.SetPos(0);

            var chunk = mapData.ReadInt();
            //Utility.Log("Client received initial map data by server chunk " + (chunk+1) + "/" + CHUNKS);

            var explored   = ExplorationDatabase.UnpackBoolArray(mapData, ExplorationDatabase.MapSizeSquared / CHUNKS);
            var startIndex = chunk * (ExplorationDatabase.MapSizeSquared / CHUNKS);

            for (var index = 0; index < explored.Length; index++)
            {
                if (explored[index])
                {
                    _Minimap.Explore(_Minimap._instance, (startIndex + index) % ExplorationDatabase.MapSize, (startIndex + index) / ExplorationDatabase.MapSize);
                }
            }

            var fogTexture = Traverse.Create((_Minimap._instance)).Field("m_fogTexture").GetValue() as Texture2D;

            fogTexture.Apply();


            _ZNet._instance.StartCoroutine(SendChunkToServer(client, chunk));


            // var explored = ExplorationDatabase.UnpackBoolArray(mapData);
            //
            // for (var index = 0; index < explored.Length; index++)
            // {
            //     if (explored[index])
            //     {
            //         _Minimap.Explore(_Minimap._instance, index % ExplorationDatabase.MapSize, index / ExplorationDatabase.MapSize);
            //     }
            // }
            //
            // var fogTexture =  Traverse.Create((_Minimap._instance)).Field("m_fogTexture").GetValue() as Texture2D;
            // fogTexture.Apply();
            //
            // explored = Traverse.Create(_Minimap._instance).Field("m_explored").GetValue() as bool[];
            // var z = ExplorationDatabase.PackBoolArray(explored);
            // if (_ZNet.IsServer(_ZNet._instance))
            // {
            //     OnClientInitialData(null, z);
            // }
            // else
            // {
            //     var znet =  Traverse.Create(typeof(ZNet)).Field("m_instance").GetValue() as ZNet;
            //     ZRpc server = _ZNet.GetServerRPC(znet);
            //     server.Invoke("OnClientInitialData", (object) z);
            // }
        }
Пример #23
0
 // Token: 0x06001161 RID: 4449 RVA: 0x00078784 File Offset: 0x00076984
 public void Deserialize(ZPackage pkg)
 {
     this.m_msgID        = pkg.ReadLong();
     this.m_senderPeerID = pkg.ReadLong();
     this.m_targetPeerID = pkg.ReadLong();
     this.m_targetZDO    = pkg.ReadZDOID();
     this.m_methodHash   = pkg.ReadInt();
     this.m_parameters   = pkg.ReadPackage();
 }
Пример #24
0
    // Token: 0x060007CF RID: 1999 RVA: 0x0003D610 File Offset: 0x0003B810
    private void RPC_DestroyZDO(long sender, ZPackage pkg)
    {
        int num = pkg.ReadInt();

        for (int i = 0; i < num; i++)
        {
            ZDOID uid = pkg.ReadZDOID();
            this.HandleDestroyedZDO(uid);
        }
    }
Пример #25
0
            public static NoiseSettings Deserialize(ZPackage pkg)
            {
                float?ReadOptionalSingle()
                {
                    float v = pkg.ReadSingle();

                    return(float.IsNegativeInfinity(v) ? (float?)null : v);
                }

                // Don't use object initializer, although it executes in lexical order, it isn't explicit in the spec
                // ReSharper disable once UseObjectOrCollectionInitializer
                var settings = new NoiseSettings();

                settings.NoiseType = (FastNoiseLite.NoiseType)pkg.ReadInt();
                settings.Frequency = pkg.ReadSingle();

                settings.FractalType             = (FastNoiseLite.FractalType)pkg.ReadInt();
                settings.FractalOctaves          = pkg.ReadInt();
                settings.FractalLacunarity       = pkg.ReadSingle();
                settings.FractalGain             = pkg.ReadSingle();
                settings.FractalWeightedStrength = pkg.ReadSingle();
                settings.FractalPingPongStrength = pkg.ReadSingle();

                settings.CellularDistanceFunction = (FastNoiseLite.CellularDistanceFunction)pkg.ReadInt();
                settings.CellularReturnType       = (FastNoiseLite.CellularReturnType)pkg.ReadInt();
                settings.CellularJitter           = pkg.ReadSingle();

                settings.DomainWarpType = (FastNoiseLite.DomainWarpType)pkg.ReadInt();
                settings.DomainWarpAmp  = pkg.ReadSingle();

                settings.Invert = pkg.ReadBool();
                settings.SmoothThresholdStart = ReadOptionalSingle();
                settings.SmoothThresholdEnd   = ReadOptionalSingle();
                settings.Threshold            = ReadOptionalSingle();
                settings.RangeStart           = ReadOptionalSingle();
                settings.RangeEnd             = ReadOptionalSingle();

                settings.Opacity   = ReadOptionalSingle();
                settings.BlendMode = (BlendOperations.BlendModeType)pkg.ReadInt();

                return(settings);
            }
Пример #26
0
        /// <summary>
        ///     RPC to receive new exploration data from client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mapData"></param>
        public static void RPC_Veilheim_ReceiveExploration_OnExplore(long sender, ZPackage mapData)
        {
            if (mapData == null)
            {
                return;
            }

            if (ZNet.instance.IsServerInstance())
            {
                var numberOfEntries = mapData.ReadInt();
                Logger.LogInfo($"Received exploration diff data from client #{sender}, {numberOfEntries} items");

                while (numberOfEntries > 0)
                {
                    var toExplore = mapData.ReadInt();
                    Minimap.instance.m_explored[toExplore] = true;
                    numberOfEntries--;
                }
            }
        }
Пример #27
0
    // Token: 0x0600026D RID: 621 RVA: 0x00013B00 File Offset: 0x00011D00
    public void Load(ZPackage pkg)
    {
        int num = pkg.ReadInt();

        this.m_skillData.Clear();
        int num2 = pkg.ReadInt();

        for (int i = 0; i < num2; i++)
        {
            Skills.SkillType skillType   = (Skills.SkillType)pkg.ReadInt();
            float            level       = pkg.ReadSingle();
            float            accumulator = (num >= 2) ? pkg.ReadSingle() : 0f;
            if (this.IsSkillValid(skillType))
            {
                Skills.Skill skill = this.GetSkill(skillType);
                skill.m_level       = level;
                skill.m_accumulator = accumulator;
            }
        }
    }
Пример #28
0
    public void Load(ZPackage pkg)
    {
        int num1 = pkg.ReadInt();

        this.m_skillData.Clear();
        int num2 = pkg.ReadInt();

        for (int index = 0; index < num2; ++index)
        {
            Skills.SkillType skillType = (Skills.SkillType)pkg.ReadInt();
            float            num3      = pkg.ReadSingle();
            float            num4      = num1 >= 2 ? pkg.ReadSingle() : 0.0f;
            if (this.IsSkillValid(skillType))
            {
                Skills.Skill skill = this.GetSkill(skillType);
                skill.m_level       = num3;
                skill.m_accumulator = num4;
            }
        }
    }
Пример #29
0
        public static void LoadServerKnownRecipes(Dictionary <long, HashSet <string> > dict, ZPackage pkg)
        {
            var numEntries = pkg.ReadInt();

            for (var i = 0; i < numEntries; i++)
            {
                var pkg2     = pkg.ReadPackage();
                var playerID = pkg2.ReadInt();
                LoadKnownRecipes(playerID, pkg2, dict);
            }
        }
Пример #30
0
        public static List <PinData> UnpackPins(ZPackage z)
        {
            var pins = new List <PinData>();

            var pinCount = z.ReadInt();

            for (var i = 0; i < pinCount; i++)
            {
                var pin = new PinData
                {
                    Name    = z.ReadString(),
                    Pos     = z.ReadVector3(),
                    Type    = (Minimap.PinType)z.ReadInt(),
                    Checked = z.ReadBool()
                };
                pins.Add(pin);
            }

            return(pins);
        }