using System; using System.Collections; using System.Collections.Generic; using DarkTonic.MasterAudio; using Pathfinding; using UnityEngine; // Token: 0x0200002D RID: 45 public class Fauna : MonoBehaviour { // Token: 0x060006E5 RID: 1765 RVA: 0x00094328 File Offset: 0x00092528 public void GetVariables() { this.attacking = false; this.moving = false; this.t = 0f; this.currentIndex = 0; this.tr = base.transform; this.anim = base.gameObject.GetComponent(); this.seeker = base.gameObject.GetComponent(); this.seeker.pathCallback = new OnPathDelegate(this.PathFinished); GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(84); this.tr.parent = null; pooledGameObject.SetActive(true); this.startPosition = this.tr.position; } // Token: 0x060006E6 RID: 1766 RVA: 0x000943CE File Offset: 0x000925CE public void Spawn() { this.anim.Play("Cast"); } // Token: 0x060006E7 RID: 1767 RVA: 0x000943E0 File Offset: 0x000925E0 public void Collide() { if (!this.attacking && base.gameObject.activeSelf && base.gameObject.activeInHierarchy) { this.attacking = true; base.StartCoroutine(this.Attacking()); } } // Token: 0x060006E8 RID: 1768 RVA: 0x00094418 File Offset: 0x00092618 private IEnumerator Attacking() { this.moving = false; this.anim.Play("Combat_basic_attack"); MasterAudio.PlaySound3DAtVector3AndForget("Squish", this.tr.position, 1f, new float?(1f), 0f, "", null); yield return new WaitForSeconds(0.5f); this.Remove(); base.gameObject.SetActive(false); yield break; } // Token: 0x060006E9 RID: 1769 RVA: 0x00094428 File Offset: 0x00092628 public void Remove() { if (!this.fx) { this.fx = Links.x.cellar.GetPooledGameObject(21); if (this.fx) { this.fx.transform.position = base.gameObject.transform.position; this.fx.SetActive(true); } } } // Token: 0x060006EA RID: 1770 RVA: 0x00094494 File Offset: 0x00092694 public void MakePath(GraphNode targetNode, int environment) { if (this.attacking) { return; } this.nodeConstraint.constrainWalkability = true; this.nodeConstraint.walkable = true; this.nodeConstraint.constrainTags = false; this.nodeConstraint.checkCircleID = 0; this.nodeConstraint.passID = 0; this.nodeConstraint.passID2 = 0; this.nodeConstraint.checkConnections = 0; this.nodeConstraint.constrainPenalty = 0; this.nodeConstraint.constrainToEnvironment = -1; this.nodeConstraint.constrainToArea = -1; if (targetNode != null && Links.x.gaia.sceneLoaded && Links.x.gaia.changingMapsComplete) { this.seeker.pathConstraint = this.nodeConstraint; this.seeker.StartPath(this.node, targetNode, new OnPathDelegate(this.PathFinished)); } } // Token: 0x060006EB RID: 1771 RVA: 0x00094578 File Offset: 0x00092778 public void Stop() { this.moving = false; this.anim.Play("Combat_Idle_loop"); if (!this.tileEffect) { this.Remove(); base.gameObject.SetActive(false); return; } this.tileEffect.FaunaRepath(this); } // Token: 0x060006EC RID: 1772 RVA: 0x000945C8 File Offset: 0x000927C8 public void PathFinished(Path p) { p.Claim(this); if (!p.error && !this.attacking) { this.nodes.Clear(); this.nodeVectors.Clear(); this.pathVectors = p.vectorPath; this.pathNodes = p.path; for (int i = 0; i < this.pathVectors.Count; i++) { this.nodeVectors.Add(this.pathVectors[i]); this.nodes.Add(this.pathNodes[i]); } this.lastNode = this.pathNodes[this.pathNodes.Count - 1]; this.currentIndex = 0; this.t = 0f; this.startPosition = (Vector3)this.node.position; if (this.currentIndex < this.nodes.Count && this.currentIndex > -1) { if (this.node == this.nodes[this.currentIndex] && this.currentIndex + 1 < this.nodes.Count) { this.currentIndex++; } this.targetPosition = this.nodeVectors[this.currentIndex]; this.node = this.nodes[this.currentIndex]; this.anim.Play("Combat_walk"); if (Records.x.banquetIsle) { this.anim.speed = 1.75f; } else if (this.type.Contains("Lizard")) { this.anim.speed = 2f; } else if (this.type.Contains("Roly")) { this.anim.speed = 1.75f; } else { this.anim.speed = 1.4f; } this.moving = true; } else { this.targetPosition = this.tr.position; this.Stop(); this.moving = false; } p.Release(this, false); if (!this.tileEffect) { this.Remove(); base.gameObject.SetActive(false); return; } } else { p.Release(this, false); this.moving = false; if (!this.tileEffect) { this.Remove(); base.gameObject.SetActive(false); return; } this.tileEffect.FaunaRepath(this); } } // Token: 0x060006ED RID: 1773 RVA: 0x00094848 File Offset: 0x00092A48 private void OnAnimatorMove() { if (this.targetPosition != Vector3.zero && this.startPosition != Vector3.zero && !Records.x.pocketPause && this.moving) { if ((this.tr.position - this.targetPosition).sqrMagnitude < 0.09f || (this.tr.position - this.targetPosition).sqrMagnitude > Records.x.nodeSize * 2f * (Records.x.nodeSize * 2f)) { if (this.currentIndex + 1 < this.nodes.Count && this.nodes.Count > 0) { if (this.tileEffect) { this.tileEffect.UpdateFaunaNode(this.node, this); } this.currentIndex++; this.targetPosition = this.nodeVectors[this.currentIndex]; this.node = this.nodes[this.currentIndex]; this.t = 0f; this.startPosition = this.tr.position; } else { if (!this.tileEffect) { this.Remove(); base.gameObject.SetActive(false); return; } this.tileEffect.FaunaRepath(this); return; } } if (this.useRootMotion) { this.tr.rotation = Quaternion.Slerp(this.tr.rotation, Quaternion.LookRotation(this.targetPosition - this.tr.position), Time.deltaTime * 30f); Vector3 rootPosition = this.anim.rootPosition; rootPosition.y = Mathf.Lerp(this.tr.position.y, this.targetPosition.y, Time.deltaTime * 5f); this.tr.position = rootPosition; } else { this.tr.rotation = Quaternion.Slerp(this.tr.rotation, Quaternion.LookRotation(this.targetPosition - this.tr.position), Time.deltaTime * 9f); this.t += Time.deltaTime; this.tr.position = Vector3.Lerp(this.startPosition, this.targetPosition, this.t * 3f); } } if (Records.x.pocketPause) { this.anim.speed = 0f; return; } this.anim.speed = 1f; } // Token: 0x04000A06 RID: 2566 public Transform tr; // Token: 0x04000A07 RID: 2567 private Animator anim; // Token: 0x04000A08 RID: 2568 private Vector3 moveFollow; // Token: 0x04000A09 RID: 2569 private Seeker seeker; // Token: 0x04000A0A RID: 2570 private NNConstraint nodeConstraint = new NNConstraint(); // Token: 0x04000A0B RID: 2571 public List nodeVectors = new List(); // Token: 0x04000A0C RID: 2572 public List nodes = new List(); // Token: 0x04000A0D RID: 2573 private List pathVectors; // Token: 0x04000A0E RID: 2574 private List pathNodes; // Token: 0x04000A0F RID: 2575 private GraphNode lastNode; // Token: 0x04000A10 RID: 2576 private Vector3 targetPosition; // Token: 0x04000A11 RID: 2577 private Vector3 startPosition; // Token: 0x04000A12 RID: 2578 private float t; // Token: 0x04000A13 RID: 2579 private int currentIndex; // Token: 0x04000A14 RID: 2580 public GraphNode node; // Token: 0x04000A15 RID: 2581 public bool useRootMotion; // Token: 0x04000A16 RID: 2582 public TileEffects tileEffect; // Token: 0x04000A17 RID: 2583 public bool moving; // Token: 0x04000A18 RID: 2584 public bool attacking; // Token: 0x04000A19 RID: 2585 private GameObject fx; // Token: 0x04000A1A RID: 2586 public string type; }