D:\ValheimDev\Dumps\Old\assembly_valheim\TombStone.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\TombStone.cs
using System; using System;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
   
public class TombStone : MonoBehaviour, Hoverable, Interactable public class TombStone : MonoBehaviour, Hoverable, Interactable
{ {
    private void Awake()     private void Awake()
    {     {
        this.m_nview = base.GetComponent<ZNetView>();         this.m_nview = base.GetComponent<ZNetView>();
        this.m_container = base.GetComponent<Container>();         this.m_container = base.GetComponent<Container>();
        this.m_floating = base.GetComponent<Floating>();         this.m_floating = base.GetComponent<Floating>();
        this.m_body = base.GetComponent<Rigidbody>();         this.m_body = base.GetComponent<Rigidbody>();
        this.m_body.maxDepenetrationVelocity = 1f;         this.m_body.maxDepenetrationVelocity = 1f;
        this.m_body.solverIterations = 10;         this.m_body.solverIterations = 10;
        Container container = this.m_container;         Container container = this.m_container;
        container.m_onTakeAllSuccess = (Action)Delegate.Combine(container.m_onTakeAllSuccess, new Action(this.OnTakeAllSuccess));         container.m_onTakeAllSuccess = (Action)Delegate.Combine(container.m_onTakeAllSuccess, new Action(this.OnTakeAllSuccess));
        if (this.m_nview.IsOwner() && this.m_nview.GetZDO().GetLong(ZDOVars.s_timeOfDeath, 0L) == 0L)         if (this.m_nview.IsOwner() && this.m_nview.GetZDO().GetLong(ZDOVars.s_timeOfDeath, 0L) == 0L)
        {         {
            this.m_nview.GetZDO().Set(ZDOVars.s_timeOfDeath, ZNet.instance.GetTime().Ticks);             this.m_nview.GetZDO().Set(ZDOVars.s_timeOfDeath, ZNet.instance.GetTime().Ticks);
            this.m_nview.GetZDO().Set(ZDOVars.s_spawnPoint, base.transform.position);             this.m_nview.GetZDO().Set(ZDOVars.s_spawnPoint, base.transform.position);
        }         }
        base.InvokeRepeating("UpdateDespawn", TombStone.m_updateDt, TombStone.m_updateDt);         base.InvokeRepeating("UpdateDespawn", TombStone.m_updateDt, TombStone.m_updateDt);
    }     }
   
    private void Start()     private void Start()
    {     {
        string text = CensorShittyWords.FilterUGC(this.m_nview.GetZDO().GetString(ZDOVars.s_ownerName, ""), UGCType.CharacterName, null, this.GetOwner());         string text = CensorShittyWords.FilterUGC(this.m_nview.GetZDO().GetString(ZDOVars.s_ownerName, ""), UGCType.CharacterName, null, this.GetOwner());
        base.GetComponent<Container>().m_name = text;         base.GetComponent<Container>().m_name = text;
        this.m_worldText.text = text;         this.m_worldText.text = text;
    }     }
   
    public string GetOwnerName()     public string GetOwnerName()
    {     {
        return CensorShittyWords.FilterUGC(this.m_nview.GetZDO().GetString(ZDOVars.s_ownerName, ""), UGCType.CharacterName, null, this.GetOwner());         return CensorShittyWords.FilterUGC(this.m_nview.GetZDO().GetString(ZDOVars.s_ownerName, ""), UGCType.CharacterName, null, this.GetOwner());
    }     }
   
    public string GetHoverText()     public string GetHoverText()
    {     {
        if (!this.m_nview.IsValid())         if (!this.m_nview.IsValid())
        {         {
            return "";             return "";
        }         }
        string text = this.m_text + " " + this.GetOwnerName();         string text = this.m_text + " " + this.GetOwnerName();
        if (this.m_container.GetInventory().NrOfItems() == 0)         if (this.m_container.GetInventory().NrOfItems() == 0)
        {         {
            return "";             return "";
        }         }
        return Localization.instance.Localize(text + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_container_open");         return Localization.instance.Localize(text + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_container_open");
    }     }
   
    public string GetHoverName()     public string GetHoverName()
    {     {
        return "";         return "";
    }     }
   
    public bool Interact(Humanoid character, bool hold, bool alt)     public bool Interact(Humanoid character, bool hold, bool alt)
    {     {
        if (hold)         if (hold)
        {         {
            return false;             return false;
        }         }
        if (this.m_container.GetInventory().NrOfItems() == 0)         if (this.m_container.GetInventory().NrOfItems() == 0)
        {         {
            return false;             return false;
        }         }
        if (!this.m_localOpened)         if (!this.m_localOpened)
        {         {
            Game.instance.IncrementPlayerStat((this.GetOwnerName() == Game.instance.GetPlayerProfile().GetName()) ? PlayerStatType.TombstonesOpenedOwn : PlayerStatType.TombstonesOpenedOther, 1f);             Game.instance.IncrementPlayerStat((this.GetOwnerName() == Game.instance.GetPlayerProfile().GetName()) ? PlayerStatType.TombstonesOpenedOwn : PlayerStatType.TombstonesOpenedOther, 1f);
        }         }
        if (this.IsOwner())         if (this.IsOwner())
        {         {
            Player player = character as Player;             Player player = character as Player;
            if (this.EasyFitInInventory(player))             if (this.EasyFitInInventory(player))
            {             {
                ZLog.Log("Grave should fit in inventory, loot all");                 ZLog.Log("Grave should fit in inventory, loot all");
                this.m_container.TakeAll(character);                 this.m_container.TakeAll(character);
                if (!this.m_localOpened)                 if (!this.m_localOpened)
                {                 {
                    Game.instance.IncrementPlayerStat(PlayerStatType.TombstonesFit, 1f);                     Game.instance.IncrementPlayerStat(PlayerStatType.TombstonesFit, 1f);
                }                 }
                return true;                 return true;
            }             }
        }         }
        this.m_localOpened = true;         this.m_localOpened = true;
        return this.m_container.Interact(character, false, false);         return this.m_container.Interact(character, false, false);
    }     }
   
    private void OnTakeAllSuccess()     private void OnTakeAllSuccess()
    {     {
        Player localPlayer = Player.m_localPlayer;         Player localPlayer = Player.m_localPlayer;
        if (localPlayer)         if (localPlayer)
        {         {
            localPlayer.m_pickupEffects.Create(localPlayer.transform.position, Quaternion.identity, null, 1f, -1);             localPlayer.m_pickupEffects.Create(localPlayer.transform.position, Quaternion.identity, null, 1f, -1);
            localPlayer.Message(MessageHud.MessageType.Center, "$piece_tombstone_recovered", 0, null);             localPlayer.Message(MessageHud.MessageType.Center, "$piece_tombstone_recovered", 0, null);
        }         }
    }     }
   
    private bool EasyFitInInventory(Player player)     private bool EasyFitInInventory(Player player)
    {     {
        int num = player.GetInventory().GetEmptySlots() - this.m_container.GetInventory().NrOfItems();         int num = player.GetInventory().GetEmptySlots() - this.m_container.GetInventory().NrOfItems();
        if (num < 0)         if (num < 0)
        {         {
            foreach (ItemDrop.ItemData itemData in this.m_container.GetInventory().GetAllItems())             foreach (ItemDrop.ItemData itemData in this.m_container.GetInventory().GetAllItems())
            {             {
                if (player.GetInventory().FindFreeStackSpace(itemData.m_shared.m_name, (float)itemData.m_worldLevel) >= itemData.m_stack)                 if (player.GetInventory().FindFreeStackSpace(itemData.m_shared.m_name, (float)itemData.m_worldLevel) >= itemData.m_stack)
                {                 {
                    num++;                     num++;
                }                 }
            }             }
            if (num < 0)             if (num < 0)
            {             {
                return false;                 return false;
            }             }
        }         }
        return player.GetInventory().GetTotalWeight() + this.m_container.GetInventory().GetTotalWeight() <= player.GetMaxCarryWeight();         return player.GetInventory().GetTotalWeight() + this.m_container.GetInventory().GetTotalWeight() <= player.GetMaxCarryWeight();
    }     }
   
    public bool UseItem(Humanoid user, ItemDrop.ItemData item)     public bool UseItem(Humanoid user, ItemDrop.ItemData item)
    {     {
        return false;         return false;
    }     }
   
    public void Setup(string ownerName, long ownerUID)     public void Setup(string ownerName, long ownerUID)
    {     {
        this.m_nview.GetZDO().Set(ZDOVars.s_ownerName, ownerName);         this.m_nview.GetZDO().Set(ZDOVars.s_ownerName, ownerName);
        this.m_nview.GetZDO().Set(ZDOVars.s_owner, ownerUID);         this.m_nview.GetZDO().Set(ZDOVars.s_owner, ownerUID);
        if (this.m_body)         if (this.m_body)
        {         {
            this.m_body.velocity = new Vector3(0f, this.m_spawnUpVel, 0f);             this.m_body.velocity = new Vector3(0f, this.m_spawnUpVel, 0f);
        }         }
    }     }
   
    private long GetOwner()     private long GetOwner()
    {     {
        if (this.m_nview.IsValid())         if (this.m_nview.IsValid())
        {         {
            return this.m_nview.GetZDO().GetLong(ZDOVars.s_owner, 0L);             return this.m_nview.GetZDO().GetLong(ZDOVars.s_owner, 0L);
        }         }
        return 0L;         return 0L;
    }     }
   
    private bool IsOwner()     private bool IsOwner()
    {     {
        long owner = this.GetOwner();         long owner = this.GetOwner();
        long playerID = Game.instance.GetPlayerProfile().GetPlayerID();         long playerID = Game.instance.GetPlayerProfile().GetPlayerID();
        return owner == playerID;         return owner == playerID;
    }     }
   
    private void UpdateDespawn()     private void UpdateDespawn()
    {     {
        if (!this.m_nview.IsValid())         if (!this.m_nview.IsValid())
        {         {
            return;             return;
        }         }
        if (this.m_floater != null)         if (this.m_floater != null)
        {         {
            this.UpdateFloater();             this.UpdateFloater();
        }         }
        if (!this.m_nview.IsOwner())         if (!this.m_nview.IsOwner())
        {         {
            return;             return;
        }         }
        this.PositionCheck();         this.PositionCheck();
        if (!this.m_container.IsInUse() && this.m_container.GetInventory().NrOfItems() <= 0)         if (!this.m_container.IsInUse() && this.m_container.GetInventory().NrOfItems() <= 0)
        {         {
            this.GiveBoost();             this.GiveBoost();
            this.m_removeEffect.Create(base.transform.position, base.transform.rotation, null, 1f, -1);             this.m_removeEffect.Create(base.transform.position, base.transform.rotation, null, 1f, -1);
            this.m_nview.Destroy();             this.m_nview.Destroy();
        }         }
    }     }
   
    private void GiveBoost()     private void GiveBoost()
    {     {
        if (this.m_lootStatusEffect == null)         if (this.m_lootStatusEffect == null)
        {         {
            return;             return;
        }         }
        Player player = this.FindOwner();         Player player = this.FindOwner();
        if (player)         if (player)
        {         {
            player.GetSEMan().AddStatusEffect(this.m_lootStatusEffect.NameHash(), true, 0, 0f);             player.GetSEMan().AddStatusEffect(this.m_lootStatusEffect.NameHash(), true, 0, 0f);
        }         }
    }     }
   
    private Player FindOwner()     private Player FindOwner()
    {     {
        long owner = this.GetOwner();         long owner = this.GetOwner();
        if (owner == 0L)         if (owner == 0L)
        {         {
            return null;             return null;
        }         }
        return Player.GetPlayer(owner);         return Player.GetPlayer(owner);
    }     }
   
    private void PositionCheck()     private void PositionCheck()
    {     {
.          if (!this.m_body)
          {
              this.m_body = FloatingTerrain.GetBody(base.gameObject);
          }
        Vector3 vec = this.m_nview.GetZDO().GetVec3(ZDOVars.s_spawnPoint, base.transform.position);         Vector3 vec = this.m_nview.GetZDO().GetVec3(ZDOVars.s_spawnPoint, base.transform.position);
        if (Utils.DistanceXZ(vec, base.transform.position) > 4f)         if (Utils.DistanceXZ(vec, base.transform.position) > 4f)
        {         {
            ZLog.Log("Tombstone moved too far from spawn position, reseting position");             ZLog.Log("Tombstone moved too far from spawn position, reseting position");
            base.transform.position = vec;             base.transform.position = vec;
            this.m_body.position = vec;             this.m_body.position = vec;
            this.m_body.velocity = Vector3.zero;             this.m_body.velocity = Vector3.zero;
        }         }
        float groundHeight = ZoneSystem.instance.GetGroundHeight(base.transform.position);         float groundHeight = ZoneSystem.instance.GetGroundHeight(base.transform.position);
        if (base.transform.position.y < groundHeight - 1f)         if (base.transform.position.y < groundHeight - 1f)
        {         {
            Vector3 position = base.transform.position;             Vector3 position = base.transform.position;
            position.y = groundHeight + 0.5f;             position.y = groundHeight + 0.5f;
            base.transform.position = position;             base.transform.position = position;
            this.m_body.position = position;             this.m_body.position = position;
            this.m_body.velocity = Vector3.zero;             this.m_body.velocity = Vector3.zero;
        }         }
    }     }
   
    private void UpdateFloater()     private void UpdateFloater()
    {     {
        if (this.m_nview.IsOwner())         if (this.m_nview.IsOwner())
        {         {
            bool flag = this.m_floating.BeenFloating();             bool flag = this.m_floating.BeenFloating();
            this.m_nview.GetZDO().Set(ZDOVars.s_inWater, flag);             this.m_nview.GetZDO().Set(ZDOVars.s_inWater, flag);
            this.m_floater.SetActive(flag);             this.m_floater.SetActive(flag);
            return;             return;
        }         }
        bool @bool = this.m_nview.GetZDO().GetBool(ZDOVars.s_inWater, false);         bool @bool = this.m_nview.GetZDO().GetBool(ZDOVars.s_inWater, false);
        this.m_floater.SetActive(@bool);         this.m_floater.SetActive(@bool);
    }     }
   
    private static float m_updateDt = 2f;     private static float m_updateDt = 2f;
   
    public string m_text = "$piece_tombstone";     public string m_text = "$piece_tombstone";
   
    public GameObject m_floater;     public GameObject m_floater;
   
    public TMP_Text m_worldText;     public TMP_Text m_worldText;
   
    public float m_spawnUpVel = 5f;     public float m_spawnUpVel = 5f;
   
    public StatusEffect m_lootStatusEffect;     public StatusEffect m_lootStatusEffect;
   
    public EffectList m_removeEffect = new EffectList();     public EffectList m_removeEffect = new EffectList();
   
    private Container m_container;     private Container m_container;
   
    private ZNetView m_nview;     private ZNetView m_nview;
   
    private Floating m_floating;     private Floating m_floating;
   
    private Rigidbody m_body;     private Rigidbody m_body;
   
    private bool m_localOpened;     private bool m_localOpened;
} }