Пример #1
0
    // Token: 0x06000B0C RID: 2828 RVA: 0x0004F9EC File Offset: 0x0004DBEC
    private void Awake()
    {
        if (MusicMan.m_instance)
        {
            return;
        }
        MusicMan.m_instance = this;
        GameObject gameObject = new GameObject("music");

        gameObject.transform.SetParent(base.transform);
        this.m_musicSource                       = gameObject.AddComponent <AudioSource>();
        this.m_musicSource.loop                  = true;
        this.m_musicSource.spatialBlend          = 0f;
        this.m_musicSource.outputAudioMixerGroup = this.m_musicMixer;
        this.m_musicSource.bypassReverbZones     = true;
        this.m_randomAmbientInterval             = UnityEngine.Random.Range(this.m_randomMusicIntervalMin, this.m_randomMusicIntervalMax);
        MusicMan.m_masterMusicVolume             = PlayerPrefs.GetFloat("MusicVolume", 1f);
        this.ApplySettings();
        foreach (MusicMan.NamedMusic namedMusic in this.m_music)
        {
            foreach (AudioClip audioClip in namedMusic.m_clips)
            {
                if (audioClip == null || !audioClip)
                {
                    namedMusic.m_enabled = false;
                    ZLog.LogWarning("Missing audio clip in music " + namedMusic.m_name);
                    break;
                }
            }
        }
    }
Пример #2
0
    // Token: 0x0600087C RID: 2172 RVA: 0x00041424 File Offset: 0x0003F624
    private GameObject CreateObject(ZDO zdo)
    {
        int prefab = zdo.GetPrefab();

        if (prefab == 0)
        {
            return(null);
        }
        GameObject prefab2 = this.GetPrefab(prefab);

        if (prefab2 == null)
        {
            return(null);
        }
        Vector3    position = zdo.GetPosition();
        Quaternion rotation = zdo.GetRotation();

        ZNetView.m_useInitZDO = true;
        ZNetView.m_initZDO    = zdo;
        GameObject result = UnityEngine.Object.Instantiate <GameObject>(prefab2, position, rotation);

        if (ZNetView.m_initZDO != null)
        {
            ZLog.LogWarning(string.Concat(new object[]
            {
                "ZDO ",
                zdo.m_uid,
                " not used when creating object ",
                prefab2.name
            }));
            ZNetView.m_initZDO = null;
        }
        ZNetView.m_useInitZDO = false;
        return(result);
    }
Пример #3
0
    // Token: 0x0600108D RID: 4237 RVA: 0x00075570 File Offset: 0x00073770
    private void Load()
    {
        if (this.m_nview == null)
        {
            return;
        }
        DateTime now = DateTime.Now;

        ZLog.Log("Loading dungeon");
        ZDO zdo  = this.m_nview.GetZDO();
        int @int = zdo.GetInt("rooms", 0);

        for (int i = 0; i < @int; i++)
        {
            string             text       = "room" + i.ToString();
            int                int2       = zdo.GetInt(text, 0);
            Vector3            vec        = zdo.GetVec3(text + "_pos", Vector3.zero);
            Quaternion         quaternion = zdo.GetQuaternion(text + "_rot", Quaternion.identity);
            DungeonDB.RoomData room       = DungeonDB.instance.GetRoom(int2);
            if (room == null)
            {
                ZLog.LogWarning("Missing room:" + int2);
            }
            else
            {
                this.PlaceRoom(room, vec, quaternion, null, ZoneSystem.SpawnMode.Client);
            }
        }
        ZLog.Log("Dungeon loaded " + @int);
        ZLog.Log("Dungeon load time " + (DateTime.Now - now).TotalMilliseconds + " ms");
    }
Пример #4
0
    // Token: 0x06000260 RID: 608 RVA: 0x00013508 File Offset: 0x00011708
    private void SpawnLoot(Vector3 center)
    {
        ZDO zdo  = this.m_nview.GetZDO();
        int @int = zdo.GetInt("drops", 0);

        if (@int <= 0)
        {
            return;
        }
        List <KeyValuePair <GameObject, int> > list = new List <KeyValuePair <GameObject, int> >();

        for (int i = 0; i < @int; i++)
        {
            int        int2   = zdo.GetInt("drop_hash" + i, 0);
            int        int3   = zdo.GetInt("drop_amount" + i, 0);
            GameObject prefab = ZNetScene.instance.GetPrefab(int2);
            if (prefab == null)
            {
                ZLog.LogWarning("Ragdoll: Missing prefab:" + int2 + " when dropping loot");
            }
            else
            {
                list.Add(new KeyValuePair <GameObject, int>(prefab, int3));
            }
        }
        CharacterDrop.DropItems(list, center + Vector3.up * 0.75f, 0.5f);
    }
Пример #5
0
        private static bool Prefix(ref ZNet __instance, ZRpc rpc, ZPackage pkg)
        {
            if (__instance.IsServer())
            {
                string self = "";
                if (pkg.Size() > 32)
                {
                    pkg.SetPos(pkg.Size() - 32 - 1);
                    if (pkg.ReadByte() == (byte)32)
                    {
                        pkg.SetPos(pkg.GetPos() - 1);
                        self = pkg.ReadString();
                    }
                }

                ZLog.Log((object)("[AntiMods]: Got client hash: " + self + "\nmine: " + VACPlugin.PluginsHash));
                ZLog.LogWarning("Plugins Hash is Equals: " + !self.Equals(VACPlugin.PluginsHash) + " ForceMods: " + VACPlugin.forcesamemods.Value);
                ZLog.LogWarning("Is in Admin List: " + !ZNet.instance.m_adminList.Contains(rpc.GetSocket().GetHostName()) + "Admin Bypass: "******"[AntiMods]: Kicking Client: " + rpc.GetSocket().GetEndPointString() + " (incompatible mods)"));
                    rpc.Invoke("Error", (object)num);
                    return(false);
                }

                ZLog.Log((object)("[AntiMods]: Accepting Client: " + rpc.GetSocket().GetEndPointString()));
            }
            return(true);
        }
Пример #6
0
    // Token: 0x060006FB RID: 1787 RVA: 0x00039690 File Offset: 0x00037890
    private void SetupItem(bool enabled)
    {
        if (!enabled)
        {
            if (this.m_instance)
            {
                UnityEngine.Object.Destroy(this.m_instance);
                this.m_instance = null;
            }
            return;
        }
        if (this.m_instance)
        {
            return;
        }
        if (this.m_itemPrefab == null)
        {
            return;
        }
        GameObject attachPrefab = this.GetAttachPrefab();

        if (attachPrefab == null)
        {
            ZLog.LogWarning("Failed to get attach prefab for item " + this.m_itemPrefab.name);
            return;
        }
        this.m_instance = UnityEngine.Object.Instantiate <GameObject>(attachPrefab, base.transform.position, base.transform.rotation, base.transform);
        this.m_instance.transform.localPosition = attachPrefab.transform.localPosition;
        this.m_instance.transform.localRotation = attachPrefab.transform.localRotation;
    }
Пример #7
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);
            }
        }
Пример #8
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);
    }
Пример #9
0
 private void Awake()
 {
     if (ZNetView.m_forceDisableInit)
     {
         UnityEngine.Object.Destroy((UnityEngine.Object) this);
     }
     else
     {
         this.m_body = (Rigidbody)((Component)this).GetComponent <Rigidbody>();
         if (ZNetView.m_useInitZDO && ZNetView.m_initZDO == null)
         {
             ZLog.LogWarning((object)("Double ZNetview when initializing object " + ((UnityEngine.Object)((Component)this).get_gameObject()).get_name()));
         }
         if (ZNetView.m_initZDO != null)
         {
             this.m_zdo         = ZNetView.m_initZDO;
             ZNetView.m_initZDO = (ZDO)null;
             if (this.m_zdo.m_type != this.m_type && this.m_zdo.IsOwner())
             {
                 this.m_zdo.SetType(this.m_type);
             }
             if (this.m_zdo.m_distant != this.m_distant && this.m_zdo.IsOwner())
             {
                 this.m_zdo.SetDistant(this.m_distant);
             }
             if (this.m_syncInitialScale)
             {
                 ((Component)this).get_transform().set_localScale(this.m_zdo.GetVec3("scale", ((Component)this).get_transform().get_localScale()));
             }
             if (UnityEngine.Object.op_Implicit((UnityEngine.Object) this.m_body))
             {
                 this.m_body.Sleep();
             }
         }
         else
         {
             string prefabName = this.GetPrefabName();
             this.m_zdo = ZDOMan.instance.CreateNewZDO(((Component)this).get_transform().get_position());
             this.m_zdo.m_persistent = this.m_persistent;
             this.m_zdo.m_type       = this.m_type;
             this.m_zdo.m_distant    = this.m_distant;
             this.m_zdo.SetPrefab(prefabName.GetStableHashCode());
             this.m_zdo.SetRotation(((Component)this).get_transform().get_rotation());
             if (this.m_syncInitialScale)
             {
                 this.m_zdo.Set("scale", ((Component)this).get_transform().get_localScale());
             }
             if (ZNetView.m_ghostInit)
             {
                 this.m_ghost = true;
                 return;
             }
         }
         ZNetScene.instance.AddInstance(this.m_zdo, this);
     }
 }
Пример #10
0
 private bool LoadPlayerFromDisk()
 {
     try
     {
         ZPackage zpackage = this.LoadPlayerDataFromDisk();
         if (zpackage == null)
         {
             ZLog.LogWarning((object)"No player data");
             return(false);
         }
         int version = zpackage.ReadInt();
         if (!Version.IsPlayerVersionCompatible(version))
         {
             ZLog.Log((object)"Player data is not compatible, ignoring");
             return(false);
         }
         if (version >= 28)
         {
             this.m_playerStats.m_kills  = zpackage.ReadInt();
             this.m_playerStats.m_deaths = zpackage.ReadInt();
             this.m_playerStats.m_crafts = zpackage.ReadInt();
             this.m_playerStats.m_builds = zpackage.ReadInt();
         }
         this.m_worldData.Clear();
         int num = zpackage.ReadInt();
         for (int index = 0; index < num; ++index)
         {
             long key = zpackage.ReadLong();
             PlayerProfile.WorldPlayerData worldPlayerData = new PlayerProfile.WorldPlayerData();
             worldPlayerData.m_haveCustomSpawnPoint = zpackage.ReadBool();
             worldPlayerData.m_spawnPoint           = zpackage.ReadVector3();
             worldPlayerData.m_haveLogoutPoint      = zpackage.ReadBool();
             worldPlayerData.m_logoutPoint          = zpackage.ReadVector3();
             if (version >= 30)
             {
                 worldPlayerData.m_haveDeathPoint = zpackage.ReadBool();
                 worldPlayerData.m_deathPoint     = zpackage.ReadVector3();
             }
             worldPlayerData.m_homePoint = zpackage.ReadVector3();
             if (version >= 29 && zpackage.ReadBool())
             {
                 worldPlayerData.m_mapData = zpackage.ReadByteArray();
             }
             this.m_worldData.Add(key, worldPlayerData);
         }
         this.m_playerName = zpackage.ReadString();
         this.m_playerID   = zpackage.ReadLong();
         this.m_startSeed  = zpackage.ReadString();
         this.m_playerData = !zpackage.ReadBool() ? (byte[])null : zpackage.ReadByteArray();
     }
     catch (Exception ex)
     {
         ZLog.LogWarning((object)("Exception while loading player profile:" + this.m_filename + " , " + ex.ToString()));
     }
     return(true);
 }
Пример #11
0
 // Token: 0x060008A1 RID: 2209 RVA: 0x00041F5C File Offset: 0x0004015C
 private void Awake()
 {
     if (ZNetView.m_forceDisableInit)
     {
         UnityEngine.Object.Destroy(this);
         return;
     }
     this.m_body = base.GetComponent <Rigidbody>();
     if (ZNetView.m_useInitZDO && ZNetView.m_initZDO == null)
     {
         ZLog.LogWarning("Double ZNetview when initializing object " + base.gameObject.name);
     }
     if (ZNetView.m_initZDO != null)
     {
         this.m_zdo         = ZNetView.m_initZDO;
         ZNetView.m_initZDO = null;
         if (this.m_zdo.m_type != this.m_type && this.m_zdo.IsOwner())
         {
             this.m_zdo.SetType(this.m_type);
         }
         if (this.m_zdo.m_distant != this.m_distant && this.m_zdo.IsOwner())
         {
             this.m_zdo.SetDistant(this.m_distant);
         }
         if (this.m_syncInitialScale)
         {
             Vector3 vec = this.m_zdo.GetVec3("scale", base.transform.localScale);
             base.transform.localScale = vec;
         }
         if (this.m_body)
         {
             this.m_body.Sleep();
         }
     }
     else
     {
         string prefabName = this.GetPrefabName();
         this.m_zdo = ZDOMan.instance.CreateNewZDO(base.transform.position);
         this.m_zdo.m_persistent = this.m_persistent;
         this.m_zdo.m_type       = this.m_type;
         this.m_zdo.m_distant    = this.m_distant;
         this.m_zdo.SetPrefab(prefabName.GetStableHashCode());
         this.m_zdo.SetRotation(base.transform.rotation);
         if (this.m_syncInitialScale)
         {
             this.m_zdo.Set("scale", base.transform.localScale);
         }
         if (ZNetView.m_ghostInit)
         {
             this.m_ghost = true;
             return;
         }
     }
     ZNetScene.instance.AddInstance(this.m_zdo, this);
 }
Пример #12
0
    // Token: 0x060008B3 RID: 2227 RVA: 0x000422E4 File Offset: 0x000404E4
    public void HandleRoutedRPC(ZRoutedRpc.RoutedRPCData rpcData)
    {
        RoutedMethodBase routedMethodBase;

        if (this.m_functions.TryGetValue(rpcData.m_methodHash, out routedMethodBase))
        {
            routedMethodBase.Invoke(rpcData.m_senderPeerID, rpcData.m_parameters);
            return;
        }
        ZLog.LogWarning("Failed to find rpc method " + rpcData.m_methodHash);
    }
Пример #13
0
    // Token: 0x06000D4A RID: 3402 RVA: 0x0005EDB8 File Offset: 0x0005CFB8
    private Transform GetRodTop(Character owner)
    {
        Transform transform = Utils.FindChild(owner.transform, "_RodTop");

        if (transform == null)
        {
            ZLog.LogWarning("Failed to find fishing rod top");
            return(null);
        }
        return(transform);
    }
Пример #14
0
    // Token: 0x060000FC RID: 252 RVA: 0x000077E4 File Offset: 0x000059E4
    public void OnFoot(string name)
    {
        Transform transform = this.FindFoot(name);

        if (transform == null)
        {
            ZLog.LogWarning("FAiled to find foot:" + name);
            return;
        }
        this.OnFoot(transform);
    }
Пример #15
0
    // Token: 0x06000940 RID: 2368 RVA: 0x00044658 File Offset: 0x00042858
    private void PkgSizeReceived(IAsyncResult res)
    {
        if (this.m_socket == null || !this.m_socket.Connected)
        {
            ZLog.LogWarning("PkgSizeReceived socket closed");
            this.Close();
            return;
        }
        int num;

        try
        {
            num = this.m_socket.GetStream().EndRead(res);
        }
        catch (Exception ex)
        {
            ZLog.LogWarning("PkgSizeReceived exception " + ex.ToString());
            this.Close();
            return;
        }
        if (num == 0)
        {
            ZLog.LogWarning("PkgSizeReceived Got 0 bytes data,closing socket");
            this.Close();
            return;
        }
        this.m_gotData         = true;
        this.m_recvSizeOffset += num;
        if (this.m_recvSizeOffset < this.m_recvSizeBuffer.Length)
        {
            int count = this.m_recvSizeBuffer.Length - this.m_recvOffset;
            this.m_socket.GetStream().BeginRead(this.m_recvSizeBuffer, this.m_recvSizeOffset, count, new AsyncCallback(this.PkgSizeReceived), this.m_socket);
            return;
        }
        int num2 = BitConverter.ToInt32(this.m_recvSizeBuffer, 0);

        if (num2 == 0 || num2 > 10485760)
        {
            ZLog.LogError("PkgSizeReceived Invalid pkg size " + num2);
            return;
        }
        this.m_lastRecvPkgSize = num2;
        this.m_recvOffset      = 0;
        this.m_lastRecvPkgSize = num2;
        if (this.m_recvBuffer == null)
        {
            this.m_recvBuffer = new byte[ZSocket2.m_maxRecvBuffer];
        }
        this.m_socket.GetStream().BeginRead(this.m_recvBuffer, this.m_recvOffset, this.m_lastRecvPkgSize, new AsyncCallback(this.PkgReceived), this.m_socket);
    }
Пример #16
0
 // Token: 0x0600093D RID: 2365 RVA: 0x0004455D File Offset: 0x0004275D
 public bool StartHost(int port)
 {
     if (this.m_listner != null)
     {
         this.m_listner.Stop();
         this.m_listner = null;
     }
     if (!this.BindSocket(port, port + 10))
     {
         ZLog.LogWarning("Failed to bind socket");
         return(false);
     }
     return(true);
 }
Пример #17
0
 private static bool Prefix(ref MineRock5 __instance, ref long sender, ref HitData hit)
 {
     if (VACPlugin.AntiParams_IsEnabled.Value)
     {
         if (VACPlugin.debugmode.Value)
         {
             ZLog.LogWarning("Damage to MineRock5");
         }
         return(Damage_Rule.Execute(hit));
     }
     else
     {
         return(true);
     }
 }
Пример #18
0
 // Token: 0x06000921 RID: 2337 RVA: 0x00043CBC File Offset: 0x00041EBC
 public bool StartHost(int port)
 {
     if (this.m_listenPort != 0)
     {
         this.Close();
     }
     if (!this.BindSocket(this.m_socket, IPAddress.Any, port, port + 10))
     {
         ZLog.LogWarning("Failed to bind socket");
         return(false);
     }
     this.m_socket.Listen(100);
     this.m_socket.BeginAccept(new AsyncCallback(this.AcceptCallback), this.m_socket);
     return(true);
 }
Пример #19
0
 // Token: 0x06000A0C RID: 2572 RVA: 0x00048BF4 File Offset: 0x00046DF4
 public bool IsDLCInstalled(string name)
 {
     if (name.Length == 0)
     {
         return(true);
     }
     foreach (DLCMan.DLCInfo dlcinfo in this.m_dlcs)
     {
         if (dlcinfo.m_name == name)
         {
             return(dlcinfo.m_installed);
         }
     }
     ZLog.LogWarning("DLC " + name + " not registered in DLCMan");
     return(false);
 }
Пример #20
0
 // Token: 0x06000ACF RID: 2767 RVA: 0x0004DD18 File Offset: 0x0004BF18
 private void RPC_DiscoverClosestLocation(long sender, string name, Vector3 point, string pinName, int pinType)
 {
     ZoneSystem.LocationInstance locationInstance;
     if (ZoneSystem.instance.FindClosestLocation(name, point, out locationInstance))
     {
         ZLog.Log("Found location of type " + name);
         ZRoutedRpc.instance.InvokeRoutedRPC(sender, "DiscoverLocationRespons", new object[]
         {
             pinName,
             pinType,
             locationInstance.m_position
         });
         return;
     }
     ZLog.LogWarning("Failed to find location of type " + name);
 }
Пример #21
0
        public static void Prefix(World world)
        {
            if (world.m_menu)
            {
                return;
            }

            FileStream biomeStream = null;

            try
            {
                biomeStream = File.OpenRead(SavingData.GetBiomeSavePath(world));
            }
            catch
            {
                if (biomeStream == null)
                {
                    UnityEngine.Debug.Log("No biome data found.");
                    WorldGenOptions.GenOptions.hasBiomeData = false;
                    WorldGenOptions.GenOptions.usingData    = WorldGenOptions.GenOptions.defaultData;
                    return;
                }
            }
            UnityEngine.Debug.Log("Biome data found for " + world.m_name + ".");
            WorldGenOptions.GenOptions.hasBiomeData = true;
            WorldGenData data = new WorldGenData();

            try
            {
                BinaryReader reader  = new BinaryReader(biomeStream);
                int          count   = reader.ReadInt32();
                ZPackage     package = new ZPackage(reader.ReadBytes(count));
                data.ReadBiomeData(ref package);
            }
            catch
            {
                ZLog.LogWarning("Incomplete biome data for " + world.m_name);
            }
            finally
            {
                if (biomeStream != null)
                {
                    biomeStream.Dispose();
                }
                WorldGenOptions.GenOptions.usingData = data;
            }
        }
Пример #22
0
 // Token: 0x060002DD RID: 733 RVA: 0x00017358 File Offset: 0x00015558
 private void OnTriggerStay(Collider collider)
 {
     if (this.m_triggerEnterOnly)
     {
         return;
     }
     if (!this.m_useTriggers)
     {
         ZLog.LogWarning("AOE got OnTriggerStay but trigger damage is disabled in " + base.gameObject.name);
         return;
     }
     if (this.m_nview != null && (!this.m_nview.IsValid() || !this.m_nview.IsOwner()))
     {
         return;
     }
     this.OnHit(collider, collider.transform.position);
 }
Пример #23
0
Файл: VAC.cs Проект: fclante/VAC
        void Awake()
        {
            // MCE
            ConfigManager.RegisterMod(pluginid, Config);
            VConfigMCE.Configuration.SetConfig();
            harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "br.com.castcodes.vac");
            ZLog.LogWarning("===================== Configuration synchronization initiated by MCE!");

            // ========================= ANTI-CHEAT

            logger = Logger;
            posMap = new Dictionary <ZNetPeer, Vector3>();
            toKick = new List <ZNetPeer>();

            string newerversionused = IsNewVersionAvailable();

            if (newerversionused == "new")
            {
                Logger.LogError("There is a newer version available of Valheim Anti Cheat.");
                Logger.LogWarning("Please visit " + VACPlugin.Repository + ".");
            }
            else if (newerversionused == "same")
            {
                Logger.LogInfo("AntiMods [" + version + "] is up to date.");
            }
            else if (newerversionused == "old")
            {
                Logger.LogError("You are in a version ahead of the most current one.");
                Logger.LogWarning(
                    "If you are not a developer, please switch back to the most current stable version published.");
                Logger.LogWarning("Please visit " + VACPlugin.Repository + ".");
            }
            else if (newerversionused == "fail")
            {
                Logger.LogError("There was a fail in stipulating the version.");
                Logger.LogWarning("Please visit " + VACPlugin.Repository + ".");
            }
            else
            {
                Logger.LogError("There was a fail in stipulating the version.");
                Logger.LogWarning("Please visit " + VACPlugin.Repository + ".");
            }

            // By RaIŇİ᎐#0213 ^^
            AntiMods();
        }
Пример #24
0
 // Token: 0x06000909 RID: 2313 RVA: 0x00043220 File Offset: 0x00041420
 private void UpdatePing(float dt)
 {
     this.m_pingTimer += dt;
     if (this.m_pingTimer > ZRpc.m_pingInterval)
     {
         this.m_pingTimer = 0f;
         this.m_pkg.Clear();
         this.m_pkg.Write(0);
         this.m_pkg.Write(true);
         this.SendPackage(this.m_pkg);
     }
     this.m_timeSinceLastPing += dt;
     if (this.m_timeSinceLastPing > ZRpc.m_timeout)
     {
         ZLog.LogWarning("ZRpc timeout detected");
         this.m_socket.Close();
     }
 }
Пример #25
0
    // Token: 0x06000DE1 RID: 3553 RVA: 0x0006327C File Offset: 0x0006147C
    private void SetVisualItem(string itemName, int variant)
    {
        if (this.m_visualName == itemName && this.m_visualVariant == variant)
        {
            return;
        }
        this.m_visualName      = itemName;
        this.m_visualVariant   = variant;
        this.m_currentItemName = "";
        if (this.m_visualName == "")
        {
            UnityEngine.Object.Destroy(this.m_visualItem);
            return;
        }
        GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemName);

        if (itemPrefab == null)
        {
            ZLog.LogWarning("Missing item prefab " + itemName);
            return;
        }
        GameObject attachPrefab = this.GetAttachPrefab(itemPrefab);

        if (attachPrefab == null)
        {
            ZLog.LogWarning("Failed to get attach prefab for item " + itemName);
            return;
        }
        ItemDrop component = itemPrefab.GetComponent <ItemDrop>();

        this.m_currentItemName = component.m_itemData.m_shared.m_name;
        Transform attach = this.GetAttach(component.m_itemData);

        this.m_visualItem = UnityEngine.Object.Instantiate <GameObject>(attachPrefab, attach.position, attach.rotation, attach);
        this.m_visualItem.transform.localPosition = attachPrefab.transform.localPosition;
        this.m_visualItem.transform.localRotation = attachPrefab.transform.localRotation;
        IEquipmentVisual componentInChildren = this.m_visualItem.GetComponentInChildren <IEquipmentVisual>();

        if (componentInChildren != null)
        {
            componentInChildren.Setup(this.m_visualVariant);
        }
    }
Пример #26
0
    // Token: 0x06000FF0 RID: 4080 RVA: 0x00070450 File Offset: 0x0006E650
    private void SyncPlayer(bool doNetworkSync)
    {
        Player localPlayer = Player.m_localPlayer;

        if (localPlayer == null)
        {
            ZLog.LogWarning("No local player");
            return;
        }
        localPlayer.transform.rotation = this.m_attachPoint.rotation;
        localPlayer.transform.position = this.m_attachPoint.position - localPlayer.transform.TransformVector(this.m_attachOffset);
        localPlayer.GetComponent <Rigidbody>().position = localPlayer.transform.position;
        if (doNetworkSync)
        {
            ZNet.instance.SetReferencePosition(localPlayer.transform.position);
            localPlayer.GetComponent <ZSyncTransform>().SyncNow();
            base.GetComponent <ZSyncTransform>().SyncNow();
        }
    }
Пример #27
0
    // Token: 0x060009E1 RID: 2529 RVA: 0x00047B54 File Offset: 0x00045D54
    private uint LoadAPPID()
    {
        string environmentVariable = Environment.GetEnvironmentVariable("SteamAppId");

        if (environmentVariable != null)
        {
            ZLog.Log("Using environment steamid " + environmentVariable);
            return(uint.Parse(environmentVariable));
        }
        try
        {
            string s = File.ReadAllText("steam_appid.txt");
            ZLog.Log("Using steam_appid.txt");
            return(uint.Parse(s));
        }
        catch
        {
        }
        ZLog.LogWarning("Failed to find APPID");
        return(0U);
    }
Пример #28
0
 // Token: 0x06001091 RID: 4241 RVA: 0x0007586C File Offset: 0x00073A6C
 private void PlaceEndCaps(ZoneSystem.SpawnMode mode)
 {
     for (int i = 0; i < DungeonGenerator.m_openConnections.Count; i++)
     {
         RoomConnection roomConnection = DungeonGenerator.m_openConnections[i];
         bool           flag           = false;
         for (int j = 0; j < DungeonGenerator.m_openConnections.Count; j++)
         {
             if (j != i && roomConnection.TestContact(DungeonGenerator.m_openConnections[j]))
             {
                 flag = true;
                 break;
             }
         }
         if (flag)
         {
             ZLog.Log("cyclic detected , cool");
         }
         else
         {
             this.FindEndCaps(roomConnection, DungeonGenerator.m_tempRooms);
             IEnumerable <DungeonDB.RoomData> enumerable = from item in DungeonGenerator.m_tempRooms
                                                           orderby item.m_room.m_endCapPrio descending
                                                           select item;
             bool flag2 = false;
             foreach (DungeonDB.RoomData roomData in enumerable)
             {
                 if (this.PlaceRoom(roomConnection, roomData, mode))
                 {
                     flag2 = true;
                     break;
                 }
             }
             if (!flag2)
             {
                 ZLog.LogWarning("Failed to place end cap " + roomConnection.name + " " + roomConnection.transform.parent.gameObject.name);
             }
         }
     }
 }
Пример #29
0
    // Token: 0x06000941 RID: 2369 RVA: 0x000447DC File Offset: 0x000429DC
    private void PkgReceived(IAsyncResult res)
    {
        int num;

        try
        {
            num = this.m_socket.GetStream().EndRead(res);
        }
        catch (Exception ex)
        {
            ZLog.Log("PkgReceived error " + ex.ToString());
            this.Close();
            return;
        }
        if (num == 0)
        {
            ZLog.LogWarning("PkgReceived: Got 0 bytes data,closing socket");
            this.Close();
            return;
        }
        this.m_gotData     = true;
        this.m_totalRecv  += num;
        this.m_recvOffset += num;
        if (this.m_recvOffset < this.m_lastRecvPkgSize)
        {
            int count = this.m_lastRecvPkgSize - this.m_recvOffset;
            if (this.m_recvBuffer == null)
            {
                this.m_recvBuffer = new byte[ZSocket2.m_maxRecvBuffer];
            }
            this.m_socket.GetStream().BeginRead(this.m_recvBuffer, this.m_recvOffset, count, new AsyncCallback(this.PkgReceived), this.m_socket);
            return;
        }
        ZPackage item = new ZPackage(this.m_recvBuffer, this.m_lastRecvPkgSize);

        this.m_mutex.WaitOne();
        this.m_pkgQueue.Enqueue(item);
        this.m_mutex.ReleaseMutex();
        this.BeginReceive();
    }
Пример #30
0
 // Token: 0x06000100 RID: 256 RVA: 0x00007948 File Offset: 0x00005B48
 private void DoEffect(FootStep.StepEffect effect, Vector3 point)
 {
     foreach (GameObject gameObject in effect.m_effectPrefabs)
     {
         GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, point, base.transform.rotation);
         FootStep.m_stepInstances.Enqueue(gameObject2);
         if (gameObject2.GetComponent <ZNetView>() != null)
         {
             ZLog.LogWarning(string.Concat(new string[]
             {
                 "Foot step effect ",
                 effect.m_name,
                 " prefab ",
                 gameObject.name,
                 " in ",
                 this.m_character.gameObject.name,
                 " should not contain a ZNetView component"
             }));
         }
     }
     FootStep.PurgeOldEffects();
 }