// Token: 0x060000EF RID: 239 RVA: 0x0000714C File Offset: 0x0000534C
    private void UpdateSpawner()
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("spawn_id");

        if (this.m_respawnTimeMinuts <= 0f && !zdoid.IsNone())
        {
            return;
        }
        if (!zdoid.IsNone() && ZDOMan.instance.GetZDO(zdoid) != null)
        {
            this.m_nview.GetZDO().Set("alive_time", ZNet.instance.GetTime().Ticks);
            return;
        }
        if (this.m_respawnTimeMinuts > 0f)
        {
            DateTime time = ZNet.instance.GetTime();
            DateTime d    = new DateTime(this.m_nview.GetZDO().GetLong("alive_time", 0L));
            if ((time - d).TotalMinutes < (double)this.m_respawnTimeMinuts)
            {
                return;
            }
        }
        if (!this.m_spawnAtDay && EnvMan.instance.IsDay())
        {
            return;
        }
        if (!this.m_spawnAtNight && EnvMan.instance.IsNight())
        {
            return;
        }
        bool requireSpawnArea = this.m_requireSpawnArea;

        if (!this.m_spawnInPlayerBase && EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.PlayerBase, 0f))
        {
            return;
        }
        if (this.m_triggerNoise > 0f)
        {
            if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance, this.m_triggerNoise))
            {
                return;
            }
        }
        else if (!Player.IsPlayerInRange(base.transform.position, this.m_triggerDistance))
        {
            return;
        }
        this.Spawn();
    }
Beispiel #2
0
            private static void Process(ZNet __instance, ZDOID zdoID)
            {
                if (zdoID.IsNone())
                {
                    return;
                }

                var zdo = ZDOMan.instance.GetZDO(zdoID);

                if (zdo == null)
                {
                    return;
                }

                var dead = zdo.GetBool("dead", false);

                // If dead, and not in deadPlayers, add to deadPlayers and create event
                // If dead, and in deadPlayers, do nothing
                // If not dead, and in deadPlayers, remove
                // If not dead, and not in deadPlayers, do nothing
                if (dead)
                {
                    if (DeadPlayers.Contains(zdoID.userID))
                    {
                        return;
                    }
                    DeadPlayers.Add(zdoID.userID);
                    ValheimEventHandler.OnPlayerDeath(GetPlayerInfo(__instance, zdoID));
                }
                else if (DeadPlayers.Contains(zdoID.userID))
                {
                    DeadPlayers.Remove(zdoID.userID);
                }
            }
Beispiel #3
0
    // Token: 0x06000F09 RID: 3849 RVA: 0x0006B864 File Offset: 0x00069A64
    public bool IsLocalUser()
    {
        if (!Player.m_localPlayer)
        {
            return(false);
        }
        ZDOID user = this.GetUser();

        return(!user.IsNone() && user == Player.m_localPlayer.GetZDOID());
    }
        public static void VTTeleportTo(this Player player, ZNet.PlayerInfo target)
        {
            if (player != null)
            {
                ZDOID characterID = target.m_characterID;

                if (!characterID.IsNone())
                {
                    player.TeleportTo(target.m_position, player.transform.rotation, true);
                }
            }
        }
Beispiel #5
0
 // Token: 0x06000AC7 RID: 2759 RVA: 0x0004DA3C File Offset: 0x0004BC3C
 private IEnumerator ConnectPortals()
 {
     for (;;)
     {
         this.m_tempPortalList.Clear();
         int  index = 0;
         bool done  = false;
         do
         {
             done = ZDOMan.instance.GetAllZDOsWithPrefabIterative(this.m_portalPrefab.name, this.m_tempPortalList, ref index);
             yield return(null);
         }while (!done);
         foreach (ZDO zdo in this.m_tempPortalList)
         {
             ZDOID  zdoid   = zdo.GetZDOID("target");
             string @string = zdo.GetString("tag", "");
             if (!zdoid.IsNone())
             {
                 ZDO zdo2 = ZDOMan.instance.GetZDO(zdoid);
                 if (zdo2 == null || zdo2.GetString("tag", "") != @string)
                 {
                     zdo.SetOwner(ZDOMan.instance.GetMyID());
                     zdo.Set("target", ZDOID.None);
                     ZDOMan.instance.ForceSendZDO(zdo.m_uid);
                 }
             }
         }
         foreach (ZDO zdo3 in this.m_tempPortalList)
         {
             string string2 = zdo3.GetString("tag", "");
             if (zdo3.GetZDOID("target").IsNone())
             {
                 ZDO zdo4 = this.FindRandomUnconnectedPortal(this.m_tempPortalList, zdo3, string2);
                 if (zdo4 != null)
                 {
                     zdo3.SetOwner(ZDOMan.instance.GetMyID());
                     zdo4.SetOwner(ZDOMan.instance.GetMyID());
                     zdo3.Set("target", zdo4.m_uid);
                     zdo4.Set("target", zdo3.m_uid);
                     ZDOMan.instance.ForceSendZDO(zdo3.m_uid);
                     ZDOMan.instance.ForceSendZDO(zdo4.m_uid);
                 }
             }
         }
         yield return(new WaitForSeconds(5f));
     }
     yield break;
 }
    // Token: 0x06000D4E RID: 3406 RVA: 0x0005F1A4 File Offset: 0x0005D3A4
    public Fish GetCatch()
    {
        if (!this.m_nview.IsValid())
        {
            return(null);
        }
        ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("CatchID");

        if (!zdoid.IsNone())
        {
            GameObject gameObject = ZNetScene.instance.FindInstance(zdoid);
            if (gameObject)
            {
                return(gameObject.GetComponent <Fish>());
            }
        }
        return(null);
    }
Beispiel #7
0
            static bool Prefix(TeleportWorld __instance, ref ZNetView ___m_nview, ref string __result)
            {
                string destPortalTag = "None";
                string tag           = __instance.GetText();

                if (tag == "")
                {
                    tag = "Empty tag";
                }
                if (___m_nview == null || !___m_nview.IsValid())
                {
                    Debug.LogError("HoverTextPatch: ___m_nview is not valid");
                }
                else
                {
                    ZDOID targetZDOID = ___m_nview.GetZDO().GetZDOID("target");
                    if (!targetZDOID.IsNone())
                    {
                        var destPortalZDO = ZDOMan.instance.GetZDO(targetZDOID);
                        if (destPortalZDO == null || !destPortalZDO.IsValid())
                        {
                            Debug.Log("HoverText: destPortalZDO is null or invalid");
                            destPortalTag = "None";
                            // Reset the target since it's bad...
                            Debug.Log("HoverText: Clearing out the target");
                            ___m_nview.GetZDO().Set("target", ZDOID.None);
                            ZDOMan.instance.ForceSendZDO(___m_nview.GetZDO().m_uid);
                        }
                        else
                        {
                            destPortalTag = destPortalZDO.GetString("tag", "Empty tag");
                        }
                    }
                }
                __result = Localization.instance.Localize($"Portal Tag: {tag}\nDestination Portal Tag: {destPortalTag}\n[<color=yellow><b>$KEY_Use</b></color>] Configure Portal");
                return(false);
            }
Beispiel #8
0
    // Token: 0x060007D3 RID: 2003 RVA: 0x0003D98C File Offset: 0x0003BB8C
    private void RPC_ZDOData(ZRpc rpc, ZPackage pkg)
    {
        ZDOMan.ZDOPeer zdopeer = this.FindPeer(rpc);
        if (zdopeer == null)
        {
            ZLog.Log("ZDO data from unkown host, ignoring");
            return;
        }
        float    time = Time.time;
        int      num  = 0;
        ZPackage pkg2 = new ZPackage();
        int      num2 = pkg.ReadInt();

        for (int i = 0; i < num2; i++)
        {
            ZDOID id  = pkg.ReadZDOID();
            ZDO   zdo = this.GetZDO(id);
            if (zdo != null)
            {
                zdo.InvalidateSector();
            }
        }
        for (;;)
        {
            ZDOID zdoid = pkg.ReadZDOID();
            if (zdoid.IsNone())
            {
                break;
            }
            num++;
            uint    num3   = pkg.ReadUInt();
            uint    num4   = pkg.ReadUInt();
            long    owner  = pkg.ReadLong();
            Vector3 vector = pkg.ReadVector3();
            pkg.ReadPackage(ref pkg2);
            ZDO  zdo2 = this.GetZDO(zdoid);
            bool flag = false;
            if (zdo2 != null)
            {
                if (num4 <= zdo2.m_dataRevision)
                {
                    if (num3 > zdo2.m_ownerRevision)
                    {
                        zdo2.m_owner          = owner;
                        zdo2.m_ownerRevision  = num3;
                        zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(num4, num3, time);
                        continue;
                    }
                    continue;
                }
            }
            else
            {
                zdo2 = this.CreateNewZDO(zdoid, vector);
                flag = true;
            }
            zdo2.m_ownerRevision = num3;
            zdo2.m_dataRevision  = num4;
            zdo2.m_owner         = owner;
            zdo2.InternalSetPosition(vector);
            zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(zdo2.m_dataRevision, zdo2.m_ownerRevision, time);
            zdo2.Deserialize(pkg2);
            if (ZNet.instance.IsServer() && flag && this.m_deadZDOs.ContainsKey(zdoid))
            {
                zdo2.SetOwner(this.m_myid);
                this.DestroyZDO(zdo2);
            }
        }
        this.m_zdosRecv += num;
    }
Beispiel #9
0
    // Token: 0x06000F08 RID: 3848 RVA: 0x0006B838 File Offset: 0x00069A38
    public bool HaveValidUser()
    {
        ZDOID user = this.GetUser();

        return(!user.IsNone() && this.m_ship.IsPlayerInBoat(user));
    }
    // Token: 0x060009D5 RID: 2517 RVA: 0x000475AC File Offset: 0x000457AC
    private void SyncPosition(ZDO zdo, float dt)
    {
        if (this.m_characterParentSync && zdo.HasOwner())
        {
            ZDOID zdoid = zdo.GetZDOID(ZSyncTransform.m_parentIDHash);
            if (!zdoid.IsNone())
            {
                GameObject gameObject = ZNetScene.instance.FindInstance(zdoid);
                if (gameObject)
                {
                    ZSyncTransform component = gameObject.GetComponent <ZSyncTransform>();
                    if (component)
                    {
                        component.ClientSync(dt);
                    }
                    Vector3 vector = zdo.GetVec3(ZSyncTransform.m_relPos, Vector3.zero);
                    Vector3 vec    = zdo.GetVec3(ZSyncTransform.m_velHash, Vector3.zero);
                    if (zdo.m_dataRevision != this.m_posRevision)
                    {
                        this.m_posRevision    = zdo.m_dataRevision;
                        this.m_targetPosTimer = 0f;
                    }
                    this.m_targetPosTimer += dt;
                    this.m_targetPosTimer  = Mathf.Min(this.m_targetPosTimer, 2f);
                    vector += vec * this.m_targetPosTimer;
                    if (!this.m_haveTempRelPos)
                    {
                        this.m_haveTempRelPos = true;
                        this.m_tempRelPos     = vector;
                    }
                    if (Vector3.Distance(this.m_tempRelPos, vector) > 0.001f)
                    {
                        this.m_tempRelPos = Vector3.Lerp(this.m_tempRelPos, vector, 0.2f);
                        vector            = this.m_tempRelPos;
                    }
                    Vector3 vector2 = gameObject.transform.TransformPoint(vector);
                    if (Vector3.Distance(base.transform.position, vector2) > 0.001f)
                    {
                        base.transform.position = vector2;
                    }
                    return;
                }
            }
        }
        this.m_haveTempRelPos = false;
        Vector3 vector3 = zdo.GetPosition();

        if (zdo.m_dataRevision != this.m_posRevision)
        {
            this.m_posRevision    = zdo.m_dataRevision;
            this.m_targetPosTimer = 0f;
        }
        if (zdo.HasOwner())
        {
            this.m_targetPosTimer += dt;
            this.m_targetPosTimer  = Mathf.Min(this.m_targetPosTimer, 2f);
            Vector3 vec2 = zdo.GetVec3(ZSyncTransform.m_velHash, Vector3.zero);
            vector3 += vec2 * this.m_targetPosTimer;
        }
        float num = Vector3.Distance(base.transform.position, vector3);

        if (num > 0.001f)
        {
            base.transform.position = ((num < 5f) ? Vector3.Lerp(base.transform.position, vector3, 0.2f) : vector3);
        }
    }