D:\ValheimDev\Dumps\Old\assembly_valheim\LuredWisp.cs D:\ValheimDev\Dumps\Latest\assembly_valheim\LuredWisp.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
   
public class LuredWisp : MonoBehaviour public class LuredWisp : MonoBehaviour
{ {
    private void Awake()     private void Awake()
    {     {
        LuredWisp.m_wisps.Add(this);         LuredWisp.m_wisps.Add(this);
        this.m_nview = base.GetComponent<ZNetView>();         this.m_nview = base.GetComponent<ZNetView>();
        this.m_targetPoint = base.transform.position;         this.m_targetPoint = base.transform.position;
        this.m_time = (float)UnityEngine.Random.Range(0, 1000);         this.m_time = (float)UnityEngine.Random.Range(0, 1000);
        base.InvokeRepeating("UpdateTarget", UnityEngine.Random.Range(0f, 2f), 2f);         base.InvokeRepeating("UpdateTarget", UnityEngine.Random.Range(0f, 2f), 2f);
    }     }
   
    private void OnDestroy()     private void OnDestroy()
    {     {
        LuredWisp.m_wisps.Remove(this);         LuredWisp.m_wisps.Remove(this);
    }     }
   
    private void UpdateTarget()     private void UpdateTarget()
    {     {
        if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())         if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())
        {         {
            return;             return;
        }         }
        if (this.m_despawnTimer > 0f)         if (this.m_despawnTimer > 0f)
        {         {
            return;             return;
        }         }
        WispSpawner bestSpawner = WispSpawner.GetBestSpawner(base.transform.position, this.m_maxLureDistance);         WispSpawner bestSpawner = WispSpawner.GetBestSpawner(base.transform.position, this.m_maxLureDistance);
.        if (bestSpawner == null || (this.m_despawnInDaylight && EnvMan.instance.IsDaylight()))         if (bestSpawner == null || (this.m_despawnInDaylight && EnvMan.IsDaylight()))
        {         {
            this.m_despawnTimer = 3f;             this.m_despawnTimer = 3f;
            this.m_targetPoint = base.transform.position + Quaternion.Euler(-20f, (float)UnityEngine.Random.Range(0, 360), 0f) * Vector3.forward * 100f;             this.m_targetPoint = base.transform.position + Quaternion.Euler(-20f, (float)UnityEngine.Random.Range(0, 360), 0f) * Vector3.forward * 100f;
            return;             return;
        }         }
        this.m_despawnTimer = 0f;         this.m_despawnTimer = 0f;
        this.m_targetPoint = bestSpawner.m_spawnPoint.position;         this.m_targetPoint = bestSpawner.m_spawnPoint.position;
    }     }
   
    private void FixedUpdate()     private void FixedUpdate()
    {     {
        if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())         if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())
        {         {
            return;             return;
        }         }
        this.UpdateMovement(this.m_targetPoint, Time.fixedDeltaTime);         this.UpdateMovement(this.m_targetPoint, Time.fixedDeltaTime);
    }     }
   
    private void UpdateMovement(Vector3 targetPos, float dt)     private void UpdateMovement(Vector3 targetPos, float dt)
    {     {
        if (this.m_despawnTimer > 0f)         if (this.m_despawnTimer > 0f)
        {         {
            this.m_despawnTimer -= dt;             this.m_despawnTimer -= dt;
            if (this.m_despawnTimer <= 0f)             if (this.m_despawnTimer <= 0f)
            {             {
                this.m_despawnEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1);                 this.m_despawnEffects.Create(base.transform.position, base.transform.rotation, null, 1f, -1);
                this.m_nview.Destroy();                 this.m_nview.Destroy();
                return;                 return;
            }             }
        }         }
        this.m_time += dt;         this.m_time += dt;
        float num = this.m_time * this.m_noiseSpeed;         float num = this.m_time * this.m_noiseSpeed;
        targetPos += new Vector3(Mathf.Sin(num * 4f), Mathf.Sin(num * 2f) * this.m_noiseDistanceYScale, Mathf.Cos(num * 5f)) * this.m_noiseDistance;         targetPos += new Vector3(Mathf.Sin(num * 4f), Mathf.Sin(num * 2f) * this.m_noiseDistanceYScale, Mathf.Cos(num * 5f)) * this.m_noiseDistance;
        Vector3 normalized = (targetPos - base.transform.position).normalized;         Vector3 normalized = (targetPos - base.transform.position).normalized;
        this.m_ballVel += normalized * this.m_acceleration * dt;         this.m_ballVel += normalized * this.m_acceleration * dt;
        if (this.m_ballVel.magnitude > this.m_maxSpeed)         if (this.m_ballVel.magnitude > this.m_maxSpeed)
        {         {
            this.m_ballVel = this.m_ballVel.normalized * this.m_maxSpeed;             this.m_ballVel = this.m_ballVel.normalized * this.m_maxSpeed;
        }         }
        this.m_ballVel -= this.m_ballVel * this.m_friction;         this.m_ballVel -= this.m_ballVel * this.m_friction;
        base.transform.position = base.transform.position + this.m_ballVel * dt;         base.transform.position = base.transform.position + this.m_ballVel * dt;
    }     }
   
    public static int GetWispsInArea(Vector3 p, float r)     public static int GetWispsInArea(Vector3 p, float r)
    {     {
        float num = r * r;         float num = r * r;
        int num2 = 0;         int num2 = 0;
        foreach (LuredWisp luredWisp in LuredWisp.m_wisps)         foreach (LuredWisp luredWisp in LuredWisp.m_wisps)
        {         {
            if (Utils.DistanceSqr(p, luredWisp.transform.position) < num)             if (Utils.DistanceSqr(p, luredWisp.transform.position) < num)
            {             {
                num2++;                 num2++;
            }             }
        }         }
        return num2;         return num2;
    }     }
   
    public bool m_despawnInDaylight = true;     public bool m_despawnInDaylight = true;
   
    public float m_maxLureDistance = 20f;     public float m_maxLureDistance = 20f;
   
    public float m_acceleration = 6f;     public float m_acceleration = 6f;
   
    public float m_noiseDistance = 1.5f;     public float m_noiseDistance = 1.5f;
   
    public float m_noiseDistanceYScale = 0.2f;     public float m_noiseDistanceYScale = 0.2f;
   
    public float m_noiseSpeed = 0.5f;     public float m_noiseSpeed = 0.5f;
   
    public float m_maxSpeed = 40f;     public float m_maxSpeed = 40f;
   
    public float m_friction = 0.03f;     public float m_friction = 0.03f;
   
    public EffectList m_despawnEffects = new EffectList();     public EffectList m_despawnEffects = new EffectList();
   
    private static List<LuredWisp> m_wisps = new List<LuredWisp>();     private static List<LuredWisp> m_wisps = new List<LuredWisp>();
   
    private Vector3 m_ballVel = Vector3.zero;     private Vector3 m_ballVel = Vector3.zero;
   
    private ZNetView m_nview;     private ZNetView m_nview;
   
    private Vector3 m_targetPoint;     private Vector3 m_targetPoint;
   
    private float m_despawnTimer;     private float m_despawnTimer;
   
    private float m_time;     private float m_time;
} }