D:\ValheimDev\Dumps\Old\assembly_valheim\CraftingStation.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\CraftingStation.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
   
.public class CraftingStation : MonoBehaviour, Hoverable, Interactable  public class CraftingStation : MonoBehaviour, Hoverable, Interactable, IMonoUpdater 
{ {
    private void Start()     private void Start()
    {     {
        this.m_nview = base.GetComponent<ZNetView>();         this.m_nview = base.GetComponent<ZNetView>();
        if (this.m_nview && this.m_nview.GetZDO() == null)         if (this.m_nview && this.m_nview.GetZDO() == null)
        {         {
            return;             return;
        }         }
        CraftingStation.m_allStations.Add(this);         CraftingStation.m_allStations.Add(this);
        if (this.m_areaMarker)         if (this.m_areaMarker)
        {         {
            this.m_areaMarker.SetActive(false);             this.m_areaMarker.SetActive(false);
            this.m_areaMarkerCircle = this.m_areaMarker.GetComponent<CircleProjector>();             this.m_areaMarkerCircle = this.m_areaMarker.GetComponent<CircleProjector>();
        }         }
        if (this.m_craftRequireFire)         if (this.m_craftRequireFire)
        {         {
            base.InvokeRepeating("CheckFire", 1f, 1f);             base.InvokeRepeating("CheckFire", 1f, 1f);
        }         }
        this.m_updateExtensionTimer = 2f;         this.m_updateExtensionTimer = 2f;
    }     }
   
.      protected virtual void OnEnable()
      {
          CraftingStation.Instances.Add(this);
      }
   
      protected virtual void OnDisable()
      {
          CraftingStation.Instances.Remove(this);
      }
   
    private void OnDestroy()     private void OnDestroy()
    {     {
        CraftingStation.m_allStations.Remove(this);         CraftingStation.m_allStations.Remove(this);
    }     }
   
    public bool Interact(Humanoid user, bool repeat, bool alt)     public bool Interact(Humanoid user, bool repeat, bool alt)
    {     {
        if (repeat)         if (repeat)
        {         {
            return false;             return false;
        }         }
        if (user == Player.m_localPlayer)         if (user == Player.m_localPlayer)
        {         {
            if (!this.InUseDistance(user))             if (!this.InUseDistance(user))
            {             {
                return false;                 return false;
            }             }
            Player player = user as Player;             Player player = user as Player;
            if (this.CheckUsable(player, true))             if (this.CheckUsable(player, true))
            {             {
                player.SetCraftingStation(this);                 player.SetCraftingStation(this);
                InventoryGui.instance.Show(null, 3);                 InventoryGui.instance.Show(null, 3);
                return false;                 return false;
            }             }
        }         }
        return false;         return false;
    }     }
   
    public bool UseItem(Humanoid user, ItemDrop.ItemData item)     public bool UseItem(Humanoid user, ItemDrop.ItemData item)
    {     {
        return false;         return false;
    }     }
   
    public bool CheckUsable(Player player, bool showMessage)     public bool CheckUsable(Player player, bool showMessage)
    {     {
        if (this.m_craftRequireRoof)         if (this.m_craftRequireRoof)
        {         {
            float num;             float num;
            bool flag;             bool flag;
            Cover.GetCoverForPoint(this.m_roofCheckPoint.position, out num, out flag, 0.5f);             Cover.GetCoverForPoint(this.m_roofCheckPoint.position, out num, out flag, 0.5f);
            if (!flag)             if (!flag)
            {             {
                if (showMessage)                 if (showMessage)
                {                 {
                    player.Message(MessageHud.MessageType.Center, "$msg_stationneedroof", 0, null);                     player.Message(MessageHud.MessageType.Center, "$msg_stationneedroof", 0, null);
                }                 }
                return false;                 return false;
            }             }
            if (num < 0.7f)             if (num < 0.7f)
            {             {
                if (showMessage)                 if (showMessage)
                {                 {
                    player.Message(MessageHud.MessageType.Center, "$msg_stationtooexposed", 0, null);                     player.Message(MessageHud.MessageType.Center, "$msg_stationtooexposed", 0, null);
                }                 }
                return false;                 return false;
            }             }
        }         }
        if (this.m_craftRequireFire && !this.m_haveFire)         if (this.m_craftRequireFire && !this.m_haveFire)
        {         {
            if (showMessage)             if (showMessage)
            {             {
                player.Message(MessageHud.MessageType.Center, "$msg_needfire", 0, null);                 player.Message(MessageHud.MessageType.Center, "$msg_needfire", 0, null);
            }             }
            return false;             return false;
        }         }
        return true;         return true;
    }     }
   
    public string GetHoverText()     public string GetHoverText()
    {     {
        if (!this.InUseDistance(Player.m_localPlayer))         if (!this.InUseDistance(Player.m_localPlayer))
        {         {
            return Localization.instance.Localize("<color=#888888>$piece_toofar</color>");             return Localization.instance.Localize("<color=#888888>$piece_toofar</color>");
        }         }
        return Localization.instance.Localize(this.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use ");         return Localization.instance.Localize(this.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use ");
    }     }
   
    public string GetHoverName()     public string GetHoverName()
    {     {
        return this.m_name;         return this.m_name;
    }     }
   
    public void ShowAreaMarker()     public void ShowAreaMarker()
    {     {
        if (this.m_areaMarker)         if (this.m_areaMarker)
        {         {
            this.m_areaMarker.SetActive(true);             this.m_areaMarker.SetActive(true);
            base.CancelInvoke("HideMarker");             base.CancelInvoke("HideMarker");
            base.Invoke("HideMarker", 0.5f);             base.Invoke("HideMarker", 0.5f);
            this.PokeInUse();             this.PokeInUse();
        }         }
    }     }
   
    private void HideMarker()     private void HideMarker()
    {     {
        this.m_areaMarker.SetActive(false);         this.m_areaMarker.SetActive(false);
    }     }
   
    public static void UpdateKnownStationsInRange(Player player)     public static void UpdateKnownStationsInRange(Player player)
    {     {
        Vector3 position = player.transform.position;         Vector3 position = player.transform.position;
        foreach (CraftingStation craftingStation in CraftingStation.m_allStations)         foreach (CraftingStation craftingStation in CraftingStation.m_allStations)
        {         {
            if (Vector3.Distance(craftingStation.transform.position, position) < craftingStation.m_discoverRange)             if (Vector3.Distance(craftingStation.transform.position, position) < craftingStation.m_discoverRange)
            {             {
                player.AddKnownStation(craftingStation);                 player.AddKnownStation(craftingStation);
            }             }
        }         }
    }     }
   
.    private void FixedUpdate()     public void CustomUpdate(float deltaTime, float time)
    {     {
        if (this.m_nview == null || !this.m_nview.IsValid())         if (this.m_nview == null || !this.m_nview.IsValid())
        {         {
            return;             return;
        }         }
.        this.m_useTimer += Time.fixedDeltaTime;         this.m_useTimer += deltaTime;
        this.m_updateExtensionTimer += Time.fixedDeltaTime;         this.m_updateExtensionTimer += deltaTime;
        if (this.m_inUseObject)         if (this.m_inUseObject)
        {         {
.            this.m_inUseObject.SetActive(this.m_useTimer < 1f);             bool flag = this.m_useTimer < 1f; 
              if (this.m_inUseObject.activeSelf != flag) 
              { 
                  this.m_inUseObject.SetActive(flag);
              } 
        }         }
    }     }
   
    private void CheckFire()     private void CheckFire()
    {     {
        this.m_haveFire = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Burning, 0.25f);         this.m_haveFire = EffectArea.IsPointInsideArea(base.transform.position, EffectArea.Type.Burning, 0.25f);
        if (this.m_haveFireObject)         if (this.m_haveFireObject)
        {         {
            this.m_haveFireObject.SetActive(this.m_haveFire);             this.m_haveFireObject.SetActive(this.m_haveFire);
        }         }
    }     }
   
    public void PokeInUse()     public void PokeInUse()
    {     {
        this.m_useTimer = 0f;         this.m_useTimer = 0f;
        this.TriggerExtensionEffects();         this.TriggerExtensionEffects();
    }     }
   
    public static CraftingStation GetCraftingStation(Vector3 point)     public static CraftingStation GetCraftingStation(Vector3 point)
    {     {
        if (CraftingStation.m_triggerMask == 0)         if (CraftingStation.m_triggerMask == 0)
        {         {
            CraftingStation.m_triggerMask = LayerMask.GetMask(new string[] { "character_trigger" });             CraftingStation.m_triggerMask = LayerMask.GetMask(new string[] { "character_trigger" });
        }         }
        foreach (Collider collider in Physics.OverlapSphere(point, 0.1f, CraftingStation.m_triggerMask, QueryTriggerInteraction.Collide))         foreach (Collider collider in Physics.OverlapSphere(point, 0.1f, CraftingStation.m_triggerMask, QueryTriggerInteraction.Collide))
        {         {
            if (collider.gameObject.CompareTag("StationUseArea"))             if (collider.gameObject.CompareTag("StationUseArea"))
            {             {
                CraftingStation componentInParent = collider.GetComponentInParent<CraftingStation>();                 CraftingStation componentInParent = collider.GetComponentInParent<CraftingStation>();
                if (componentInParent != null)                 if (componentInParent != null)
                {                 {
                    return componentInParent;                     return componentInParent;
                }                 }
            }             }
        }         }
        return null;         return null;
    }     }
   
    public static CraftingStation HaveBuildStationInRange(string name, Vector3 point)     public static CraftingStation HaveBuildStationInRange(string name, Vector3 point)
    {     {
        foreach (CraftingStation craftingStation in CraftingStation.m_allStations)         foreach (CraftingStation craftingStation in CraftingStation.m_allStations)
        {         {
            if (!(craftingStation.m_name != name))             if (!(craftingStation.m_name != name))
            {             {
                float stationBuildRange = craftingStation.GetStationBuildRange();                 float stationBuildRange = craftingStation.GetStationBuildRange();
                point.y = craftingStation.transform.position.y;                 point.y = craftingStation.transform.position.y;
                if (Vector3.Distance(craftingStation.transform.position, point) < stationBuildRange)                 if (Vector3.Distance(craftingStation.transform.position, point) < stationBuildRange)
                {                 {
                    return craftingStation;                     return craftingStation;
                }                 }
            }             }
        }         }
        return null;         return null;
    }     }
   
    public static void FindStationsInRange(string name, Vector3 point, float range, List<CraftingStation> stations)     public static void FindStationsInRange(string name, Vector3 point, float range, List<CraftingStation> stations)
    {     {
        foreach (CraftingStation craftingStation in CraftingStation.m_allStations)         foreach (CraftingStation craftingStation in CraftingStation.m_allStations)
        {         {
            if (!(craftingStation.m_name != name) && Vector3.Distance(craftingStation.transform.position, point) < range)             if (!(craftingStation.m_name != name) && Vector3.Distance(craftingStation.transform.position, point) < range)
            {             {
                stations.Add(craftingStation);                 stations.Add(craftingStation);
            }             }
        }         }
    }     }
   
    public static CraftingStation FindClosestStationInRange(string name, Vector3 point, float range)     public static CraftingStation FindClosestStationInRange(string name, Vector3 point, float range)
    {     {
        CraftingStation craftingStation = null;         CraftingStation craftingStation = null;
        float num = 99999f;         float num = 99999f;
        foreach (CraftingStation craftingStation2 in CraftingStation.m_allStations)         foreach (CraftingStation craftingStation2 in CraftingStation.m_allStations)
        {         {
            if (!(craftingStation2.m_name != name))             if (!(craftingStation2.m_name != name))
            {             {
                float num2 = Vector3.Distance(craftingStation2.transform.position, point);                 float num2 = Vector3.Distance(craftingStation2.transform.position, point);
                if (num2 < range && (num2 < num || craftingStation == null))                 if (num2 < range && (num2 < num || craftingStation == null))
                {                 {
                    craftingStation = craftingStation2;                     craftingStation = craftingStation2;
                    num = num2;                     num = num2;
                }                 }
            }             }
        }         }
        return craftingStation;         return craftingStation;
    }     }
   
    private List<StationExtension> GetExtensions()     private List<StationExtension> GetExtensions()
    {     {
        if (this.m_updateExtensionTimer >= 2f)         if (this.m_updateExtensionTimer >= 2f)
        {         {
            this.m_updateExtensionTimer = 0f;             this.m_updateExtensionTimer = 0f;
            this.m_attachedExtensions.Clear();             this.m_attachedExtensions.Clear();
            StationExtension.FindExtensions(this, base.transform.position, this.m_attachedExtensions);             StationExtension.FindExtensions(this, base.transform.position, this.m_attachedExtensions);
            this.m_buildRange = this.m_rangeBuild + (float)this.GetExtentionCount(false) * this.m_extraRangePerLevel;             this.m_buildRange = this.m_rangeBuild + (float)this.GetExtentionCount(false) * this.m_extraRangePerLevel;
            if (this.m_areaMarker)             if (this.m_areaMarker)
            {             {
                this.m_areaMarkerCircle.m_radius = this.m_buildRange;                 this.m_areaMarkerCircle.m_radius = this.m_buildRange;
            }             }
.            if (this.m_effectAreaCollider != null)             if (this.m_effectAreaCollider == null)
            {             {
.                this.m_effectAreaCollider.radius = this.m_buildRange;                 return this.m_attachedExtensions; 
              } 
              Collider effectAreaCollider = this.m_effectAreaCollider; 
              SphereCollider sphereCollider = effectAreaCollider as SphereCollider; 
              if (sphereCollider == null) 
              { 
                  CapsuleCollider capsuleCollider = effectAreaCollider as CapsuleCollider; 
                  if (capsuleCollider != null) 
                  { 
                      capsuleCollider.radius = this.m_buildRange;
                  } 
              } 
              else 
              { 
                  sphereCollider.radius = this.m_buildRange; 
            }             }
        }         }
        return this.m_attachedExtensions;         return this.m_attachedExtensions;
    }     }
   
    private void TriggerExtensionEffects()     private void TriggerExtensionEffects()
    {     {
        Vector3 connectionEffectPoint = this.GetConnectionEffectPoint();         Vector3 connectionEffectPoint = this.GetConnectionEffectPoint();
        foreach (StationExtension stationExtension in this.GetExtensions())         foreach (StationExtension stationExtension in this.GetExtensions())
        {         {
            if (stationExtension)             if (stationExtension)
            {             {
                stationExtension.StartConnectionEffect(connectionEffectPoint, 1f);                 stationExtension.StartConnectionEffect(connectionEffectPoint, 1f);
            }             }
        }         }
    }     }
   
    public Vector3 GetConnectionEffectPoint()     public Vector3 GetConnectionEffectPoint()
    {     {
        if (this.m_connectionPoint)         if (this.m_connectionPoint)
        {         {
            return this.m_connectionPoint.position;             return this.m_connectionPoint.position;
        }         }
        return base.transform.position;         return base.transform.position;
    }     }
   
    public int GetLevel(bool checkExtensions = true)     public int GetLevel(bool checkExtensions = true)
    {     {
        return 1 + this.GetExtentionCount(checkExtensions);         return 1 + this.GetExtentionCount(checkExtensions);
    }     }
   
    public int GetExtentionCount(bool checkExtensions = true)     public int GetExtentionCount(bool checkExtensions = true)
    {     {
        if (checkExtensions)         if (checkExtensions)
        {         {
            this.GetExtensions();             this.GetExtensions();
        }         }
        return this.m_attachedExtensions.Count;         return this.m_attachedExtensions.Count;
    }     }
   
    public float GetStationBuildRange()     public float GetStationBuildRange()
    {     {
        this.GetExtensions();         this.GetExtensions();
        return this.m_buildRange;         return this.m_buildRange;
    }     }
   
    public bool InUseDistance(Humanoid human)     public bool InUseDistance(Humanoid human)
    {     {
        return Vector3.Distance(human.transform.position, base.transform.position) < this.m_useDistance;         return Vector3.Distance(human.transform.position, base.transform.position) < this.m_useDistance;
    }     }
   
.      public static List<IMonoUpdater> Instances { get; } = new List<IMonoUpdater>();
   
    public string m_name = "";     public string m_name = "";
   
    public Sprite m_icon;     public Sprite m_icon;
   
    public float m_discoverRange = 4f;     public float m_discoverRange = 4f;
   
    public float m_rangeBuild = 10f;     public float m_rangeBuild = 10f;
   
    public float m_extraRangePerLevel;     public float m_extraRangePerLevel;
   
    public bool m_craftRequireRoof = true;     public bool m_craftRequireRoof = true;
   
    public bool m_craftRequireFire = true;     public bool m_craftRequireFire = true;
   
    public Transform m_roofCheckPoint;     public Transform m_roofCheckPoint;
   
    public Transform m_connectionPoint;     public Transform m_connectionPoint;
   
    public bool m_showBasicRecipies;     public bool m_showBasicRecipies;
   
    public float m_useDistance = 2f;     public float m_useDistance = 2f;
   
.    public SphereCollider m_effectAreaCollider;     public Collider m_effectAreaCollider;
   
    public int m_useAnimation;     public int m_useAnimation;
   
    public GameObject m_areaMarker;     public GameObject m_areaMarker;
   
    public GameObject m_inUseObject;     public GameObject m_inUseObject;
   
    public GameObject m_haveFireObject;     public GameObject m_haveFireObject;
   
    public EffectList m_craftItemEffects = new EffectList();     public EffectList m_craftItemEffects = new EffectList();
   
    public EffectList m_craftItemDoneEffects = new EffectList();     public EffectList m_craftItemDoneEffects = new EffectList();
   
    public EffectList m_repairItemDoneEffects = new EffectList();     public EffectList m_repairItemDoneEffects = new EffectList();
   
    private const float m_updateExtensionInterval = 2f;     private const float m_updateExtensionInterval = 2f;
   
    private float m_updateExtensionTimer;     private float m_updateExtensionTimer;
   
    private bool m_initialized;     private bool m_initialized;
   
    private float m_useTimer = 10f;     private float m_useTimer = 10f;
   
    private bool m_haveFire;     private bool m_haveFire;
   
    private float m_buildRange;     private float m_buildRange;
   
    private ZNetView m_nview;     private ZNetView m_nview;
   
    private List<StationExtension> m_attachedExtensions = new List<StationExtension>();     private List<StationExtension> m_attachedExtensions = new List<StationExtension>();
   
    private static List<CraftingStation> m_allStations = new List<CraftingStation>();     private static List<CraftingStation> m_allStations = new List<CraftingStation>();
   
    private static int m_triggerMask = 0;     private static int m_triggerMask = 0;
   
    private CircleProjector m_areaMarkerCircle;     private CircleProjector m_areaMarkerCircle;
} }