Ejemplo n.º 1
0
    public override void SetLOD(int lod)
    {
        EventInstance windEvent = TreeWindSfx.BeginTransfer(this.CurrentLodTransform);

        base.SetLOD(lod);
        TreeWindSfx.CompleteTransfer(this.CurrentLodTransform, windEvent);
    }
Ejemplo n.º 2
0
 public void Init(TreeWindSfx tree)
 {
     this.tree        = tree;
     this.position    = tree.transform.position;
     this.sqrDistance = 0f;
     this.direction   = 0f;
 }
Ejemplo n.º 3
0
 public static void Add(TreeWindSfx tree)
 {
     if (!TreeWindSfxManager.sTrees.Contains(tree))
     {
         TreeWindSfxManager.sTrees.Add(tree);
         TreeWindSfxManager.sTreeInfoList.Add(TreeWindSfxManager.GetTreeInfo(tree));
     }
 }
Ejemplo n.º 4
0
 private static TreeWindSfxManager.TreeInfo GetTreeInfo(TreeWindSfx tree)
 {
     TreeWindSfxManager.TreeInfo treeInfo;
     if (TreeWindSfxManager.sTreeInfoListPool.Count > 0)
     {
         treeInfo = TreeWindSfxManager.sTreeInfoListPool.Dequeue();
         treeInfo.Init(tree);
     }
     else
     {
         treeInfo = new TreeWindSfxManager.TreeInfo(tree);
     }
     return(treeInfo);
 }
Ejemplo n.º 5
0
    public static EventInstance BeginTransfer(Transform source)
    {
        EventInstance result = null;

        if (source != null)
        {
            TreeWindSfx componentInChildren = source.GetComponentInChildren <TreeWindSfx>();
            if (componentInChildren != null)
            {
                result = componentInChildren.WindEvent;
                componentInChildren.WindEvent = null;
            }
        }
        return(result);
    }
Ejemplo n.º 6
0
 public void Deactivate(float persistTime)
 {
     if (this.WaitingForTimeout)
     {
         if (Time.time >= this.Timeout)
         {
             TreeWindSfx.StopEvent(this.WindEvent);
             this.WindEvent = null;
         }
     }
     else
     {
         this.Timeout           = Time.time + persistTime;
         this.WaitingForTimeout = true;
     }
 }
Ejemplo n.º 7
0
 public static void Remove(TreeWindSfx tree)
 {
     if (TreeWindSfxManager.sTrees.Contains(tree))
     {
         TreeWindSfxManager.sTrees.Remove(tree);
         for (int i = 0; i < TreeWindSfxManager.sTreeInfoList.Count; i++)
         {
             TreeWindSfxManager.TreeInfo treeInfo = TreeWindSfxManager.sTreeInfoList[i];
             if (treeInfo.tree == tree)
             {
                 treeInfo.Clear();
                 TreeWindSfxManager.sTreeInfoListPool.Enqueue(treeInfo);
                 TreeWindSfxManager.sTreeInfoList.RemoveAt(i);
                 break;
             }
         }
     }
 }
Ejemplo n.º 8
0
 private void State_Damaged()
 {
     FMOD.Studio.EventInstance windEvent = TreeWindSfx.BeginTransfer(this.lod.CurrentLodTransform);
     this.SpawnCutTree();
     if (this.lod.CurrentLodTransform)
     {
         UnityEngine.Object.Destroy(this.lod.CurrentLodTransform.gameObject);
         this.lod.CurrentLodTransform = null;
     }
     if (this.cut)
     {
         TreeWindSfx.CompleteTransfer(this.cut.transform, windEvent);
         this.ChunkUpdater1();
         this.ChunkUpdater2();
         this.ChunkUpdater3();
         this.ChunkUpdater4();
     }
 }
Ejemplo n.º 9
0
    public override void SetLOD(int lod)
    {
        bool          flag = this.currentLOD == 2 || lod == 2;
        EventInstance windEvent;

        if (flag)
        {
            windEvent = TreeWindSfx.BeginTransfer(this.CurrentLodTransform);
        }
        else
        {
            windEvent = null;
        }
        base.SetLOD(lod);
        if (flag)
        {
            TreeWindSfx.CompleteTransfer(this.CurrentLodTransform, windEvent);
        }
    }
Ejemplo n.º 10
0
 public static void CompleteTransfer(Transform destination, EventInstance windEvent)
 {
     if (windEvent != null)
     {
         TreeWindSfx treeWindSfx = null;
         if (destination != null)
         {
             treeWindSfx = destination.GetComponentInChildren <TreeWindSfx>();
         }
         if (treeWindSfx != null)
         {
             treeWindSfx.WindEvent = windEvent;
         }
         else
         {
             TreeWindSfx.StopEvent(windEvent);
         }
         windEvent = null;
     }
 }
Ejemplo n.º 11
0
    public void DoSpawnCutTree()
    {
        if (BoltNetwork.isRunning)
        {
            return;
        }
        EventInstance windEvent = TreeWindSfx.BeginTransfer(base.transform);

        this.Trunk = (GameObject)UnityEngine.Object.Instantiate(this.Trunk, base.transform.position, base.transform.rotation);
        if (!this.dontScaleTrunk)
        {
            this.Trunk.transform.localScale = base.transform.localScale;
        }
        TreeHealth component = this.Trunk.GetComponent <TreeHealth>();

        component.SetLodBase(this.LodTree);
        UnityEngine.Object.Destroy(base.gameObject);
        PrefabId log = BoltPrefabs.Log;

        TreeWindSfx.CompleteTransfer(this.Trunk.transform, windEvent);
    }
Ejemplo n.º 12
0
    private static void DrawDebug()
    {
        if (TreeWindSfxManager.activeTexture == null)
        {
            TreeWindSfxManager.CreateDebugTextures();
        }
        List <TreeWindSfxManager.TreeInfo> list = TreeWindSfxManager.sTreeInfoList;
        float num  = 0f;
        int   num2 = 0;

        for (int i = 0; i < list.Count; i++)
        {
            TreeWindSfxManager.TreeInfo treeInfo = list[i];
            TreeWindSfx tree   = treeInfo.tree;
            Vector3     vector = LocalPlayer.Transform.InverseTransformPoint(tree.transform.position);
            num = Math.Max(num, vector.sqrMagnitude);
            if (tree.IsActive)
            {
                num2++;
            }
            treeInfo.sqrDistance = vector.sqrMagnitude;
            treeInfo.direction   = Mathf.Atan2(vector.z, vector.x);
        }
        num = Mathf.Sqrt(num);
        Vector2 vector2 = new Vector2(110f, (float)(Camera.main.pixelHeight - 110));

        GUI.Box(new Rect(vector2.x - 105f, vector2.y - 105f - 35f, 210f, 245f), string.Format("Active trees: {0}  Total trees: {1}", num2, list.Count));
        foreach (TreeWindSfxManager.TreeInfo treeInfo2 in list)
        {
            float     num3  = Mathf.Sqrt(treeInfo2.sqrDistance) / num * 100f;
            float     num4  = vector2.x + num3 * Mathf.Cos(treeInfo2.direction);
            float     num5  = vector2.y - num3 * Mathf.Sin(treeInfo2.direction);
            Texture2D image = (!treeInfo2.tree.IsActive) ? TreeWindSfxManager.inactiveTexture : TreeWindSfxManager.activeTexture;
            GUI.DrawTexture(new Rect(num4 - 5f, num5 - 5f, 10f, 10f), image);
        }
        GUI.DrawTexture(new Rect(vector2.x - 5f, vector2.y - 5f, 10f, 10f), TreeWindSfxManager.playerTexture);
    }
Ejemplo n.º 13
0
 public TreeInfo(TreeWindSfx tree)
 {
     this.Init(tree);
 }
Ejemplo n.º 14
0
 private void OnDisable()
 {
     TreeWindSfx.StopEvent(this.WindEvent);
     TreeWindSfxManager.Remove(this);
 }
Ejemplo n.º 15
0
 public void Clear()
 {
     this.tree = null;
 }