841 lines
21 KiB
C#
841 lines
21 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
// Token: 0x020000F4 RID: 244
|
|
public class FlockChild : MonoBehaviour
|
|
{
|
|
// Token: 0x0600155D RID: 5469 RVA: 0x001986D8 File Offset: 0x001968D8
|
|
public void Start()
|
|
{
|
|
this.FindRequiredComponents();
|
|
if (this._spawner == null)
|
|
{
|
|
base.enabled = false;
|
|
return;
|
|
}
|
|
this.Wander();
|
|
base.InvokeRepeating("FindWaypoint", 0f, 20f);
|
|
this.SetRandomScale();
|
|
this.FindWaypoint();
|
|
this._thisT.position = this._wayPoint;
|
|
this.RandomizeStartAnimationFrame();
|
|
this.InitAvoidanceValues();
|
|
this._speed = this._spawner._minSpeed;
|
|
this._spawner._activeChildren += 1f;
|
|
this._instantiated = true;
|
|
if (this._spawner._skipFrame)
|
|
{
|
|
FlockChild._updateNextSeed++;
|
|
this._updateSeed = FlockChild._updateNextSeed;
|
|
FlockChild._updateNextSeed %= 1;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600155E RID: 5470 RVA: 0x001987A4 File Offset: 0x001969A4
|
|
public void BirdUpdate()
|
|
{
|
|
if (this == null || !this._instantiated)
|
|
{
|
|
return;
|
|
}
|
|
if (!this._spawner._skipFrame || this._spawner._updateCounter == this._updateSeed)
|
|
{
|
|
if (this._spawner.LimitPitchRotation || this._landing)
|
|
{
|
|
this.LimitRotationOfModel();
|
|
}
|
|
if (!this._landing)
|
|
{
|
|
this.SoarTimeLimit();
|
|
this.CheckForDistanceToWaypoint();
|
|
this.RotationBasedOnWaypointOrAvoidance();
|
|
this.Move();
|
|
}
|
|
else if (!this._move)
|
|
{
|
|
this.RotateBird();
|
|
if (!this._bakedAnimator)
|
|
{
|
|
return;
|
|
}
|
|
if (this._bakedAnimator.isActiveAndEnabled)
|
|
{
|
|
this._bakedAnimator.AnimateUpdate();
|
|
}
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (this.distance > 5f)
|
|
{
|
|
this._wayPoint = this.GetLandingSpotPosition() + this._landingSpot._preLandWaypoint;
|
|
}
|
|
else
|
|
{
|
|
this._wayPoint = this.AddVectors(this.AddVectors(this._landingSpot.landingPoint, this._landingPosOffset), this._landingOffsetFix * this._thisT.localScale.y);
|
|
}
|
|
this._damping = this._landingSpot._controller._landingTurnSpeedModifier;
|
|
this.RotationBasedOnWaypointOrAvoidance();
|
|
this.Move();
|
|
this.Landing();
|
|
}
|
|
}
|
|
if (!this._bakedAnimator)
|
|
{
|
|
return;
|
|
}
|
|
if (this._bakedAnimator.isActiveAndEnabled)
|
|
{
|
|
this._bakedAnimator.AnimateUpdate();
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600155F RID: 5471 RVA: 0x00198914 File Offset: 0x00196B14
|
|
private void Landing()
|
|
{
|
|
if (this.currentAnim == 2)
|
|
{
|
|
return;
|
|
}
|
|
Vector3 position = this._thisT.position;
|
|
Vector3 landingSpotPosition = this.GetLandingSpotPosition();
|
|
this.distance = this.SubtractVectors(position, landingSpotPosition).sqrMagnitude;
|
|
if (!this._landingSpot._controller._soarLand && this.currentAnim != 0)
|
|
{
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._flapAnimation, 0.5f);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._flapAnimation, 0.5f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this._bakedAnimator.SetAnimation(0, -1);
|
|
this._bakedAnimator.SetSpeedMultiplier(this._spawner._maxAnimationSpeed);
|
|
}
|
|
this.currentAnim = 0;
|
|
}
|
|
if (this.distance < 64f && this.distance >= 1f)
|
|
{
|
|
if (this._landingSpot._controller._soarLand)
|
|
{
|
|
if (this.distance < 16f)
|
|
{
|
|
if (this.currentAnim != 0)
|
|
{
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._flapAnimation, 0.5f);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._flapAnimation, 0.5f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this._bakedAnimator.SetAnimation(0, -1);
|
|
this._bakedAnimator.SetSpeedMultiplier(this._spawner._maxAnimationSpeed);
|
|
}
|
|
this.currentAnim = 0;
|
|
}
|
|
}
|
|
else if (this.currentAnim != 1)
|
|
{
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._soarAnimation, 0.5f);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._soarAnimation, 0.5f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this._bakedAnimator.SetAnimation(1);
|
|
this._bakedAnimator.SetSpeedMultiplier(this._spawner._minAnimationSpeed);
|
|
}
|
|
this.currentAnim = 1;
|
|
}
|
|
}
|
|
this._targetSpeed = this._spawner._maxSpeed * this._landingSpot._controller._landingSpeedModifier;
|
|
return;
|
|
}
|
|
if (this.distance < 1f)
|
|
{
|
|
float num = this._spawner._newDelta * this._landingSpot._controller._closeToSpotSpeedModifier * this._targetSpeed;
|
|
this._thisT.position += this.SubtractVectors(landingSpotPosition, position).normalized * num;
|
|
this._closeToSpot = true;
|
|
if (this.distance < this._landingSpot._controller._snapLandDistance * this._landingSpot._controller._snapLandDistance)
|
|
{
|
|
if (this.currentAnim != 2)
|
|
{
|
|
base.Invoke("Idle", Random.Range(0.1f, 0.75f));
|
|
this.currentAnim = 2;
|
|
}
|
|
this._move = false;
|
|
this._thisT.position = landingSpotPosition;
|
|
this._modelT.localRotation = Quaternion.identity;
|
|
this._thisT.eulerAngles = new Vector3(0f, this._thisT.rotation.eulerAngles.y, 0f);
|
|
this._damping = 0.75f;
|
|
return;
|
|
}
|
|
this._speed = this._spawner._minSpeed * 0.2f;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001560 RID: 5472 RVA: 0x00198C94 File Offset: 0x00196E94
|
|
public Vector3 SubtractVectors(Vector3 a, Vector3 b)
|
|
{
|
|
Vector3 vector;
|
|
vector.x = a.x - b.x;
|
|
vector.y = a.y - b.y;
|
|
vector.z = a.z - b.z;
|
|
return vector;
|
|
}
|
|
|
|
// Token: 0x06001561 RID: 5473 RVA: 0x00198CE0 File Offset: 0x00196EE0
|
|
public Vector3 AddVectors(Vector3 a, Vector3 b)
|
|
{
|
|
Vector3 vector;
|
|
vector.x = a.x + b.x;
|
|
vector.y = a.y + b.y;
|
|
vector.z = a.z + b.z;
|
|
return vector;
|
|
}
|
|
|
|
// Token: 0x06001562 RID: 5474 RVA: 0x00198D2C File Offset: 0x00196F2C
|
|
private void Idle()
|
|
{
|
|
if (this._animationIsBaked)
|
|
{
|
|
this._bakedAnimator.SetAnimation(2, -1);
|
|
return;
|
|
}
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._idleAnimation, 0.5f);
|
|
return;
|
|
}
|
|
this._animator.CrossFade(this._spawner._idleAnimation, 0.5f);
|
|
}
|
|
|
|
// Token: 0x06001563 RID: 5475 RVA: 0x00198D93 File Offset: 0x00196F93
|
|
public Vector3 GetLandingSpotPosition()
|
|
{
|
|
return this.AddVectors(this.AddVectors(this._landingSpot.landingPoint, this._landingPosOffset), this._landingOffsetFix * this._thisT.localScale.y);
|
|
}
|
|
|
|
// Token: 0x06001564 RID: 5476 RVA: 0x00198DD0 File Offset: 0x00196FD0
|
|
public void RotateBird()
|
|
{
|
|
if (!this._landingSpot._controller._rotateAfterLanding)
|
|
{
|
|
return;
|
|
}
|
|
if (this._thisT.rotation != this._landingSpot.landingRot)
|
|
{
|
|
this._thisT.rotation = this._landingSpot.landingRot;
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001565 RID: 5477 RVA: 0x00198E24 File Offset: 0x00197024
|
|
public void OnDisable()
|
|
{
|
|
base.CancelInvoke();
|
|
if (this._spawner)
|
|
{
|
|
this._spawner._activeChildren -= 1f;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001566 RID: 5478 RVA: 0x00198E50 File Offset: 0x00197050
|
|
public void OnEnable()
|
|
{
|
|
if (this._instantiated)
|
|
{
|
|
this._spawner._activeChildren += 1f;
|
|
if (this._animationIsBaked)
|
|
{
|
|
if (this._landing)
|
|
{
|
|
this._bakedAnimator.SetAnimation(2);
|
|
return;
|
|
}
|
|
this._bakedAnimator.SetAnimation(0);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (this._landing)
|
|
{
|
|
this._modelAnimation.Play(this._spawner._idleAnimation);
|
|
return;
|
|
}
|
|
this._modelAnimation.Play(this._spawner._flapAnimation);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001567 RID: 5479 RVA: 0x00198EE0 File Offset: 0x001970E0
|
|
public void FindRequiredComponents()
|
|
{
|
|
if (this._thisT == null)
|
|
{
|
|
this._thisT = base.transform;
|
|
}
|
|
if (this._model == null)
|
|
{
|
|
this._model = this._thisT.Find("Model").gameObject;
|
|
}
|
|
if (this._bakedAnimator == null)
|
|
{
|
|
this._bakedAnimator = base.GetComponent<BakedMeshAnimator>();
|
|
}
|
|
if (this._bakedAnimator == null)
|
|
{
|
|
this._bakedAnimator = this._model.GetComponent<BakedMeshAnimator>();
|
|
}
|
|
if (this._modelT == null)
|
|
{
|
|
this._modelT = this._model.transform;
|
|
}
|
|
this._modelAnimation = this._model.GetComponent<Animation>();
|
|
if (!this._modelAnimation)
|
|
{
|
|
this._animator = this._model.GetComponent<Animator>();
|
|
}
|
|
if (!this._modelAnimation && !this._animator)
|
|
{
|
|
this._animationIsBaked = true;
|
|
return;
|
|
}
|
|
this._animationIsBaked = false;
|
|
}
|
|
|
|
// Token: 0x06001568 RID: 5480 RVA: 0x00198FE0 File Offset: 0x001971E0
|
|
public void RandomizeStartAnimationFrame()
|
|
{
|
|
if (this._animationIsBaked || this._animator)
|
|
{
|
|
return;
|
|
}
|
|
foreach (object obj in this._modelAnimation)
|
|
{
|
|
AnimationState animationState = (AnimationState)obj;
|
|
animationState.time = Random.value * animationState.length;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001569 RID: 5481 RVA: 0x0019905C File Offset: 0x0019725C
|
|
public void InitAvoidanceValues()
|
|
{
|
|
this._avoidValue = Random.Range(0.3f, 0.1f);
|
|
if (this._spawner._birdAvoidDistanceMax != this._spawner._birdAvoidDistanceMin)
|
|
{
|
|
this._avoidDistance = Random.Range(this._spawner._birdAvoidDistanceMax, this._spawner._birdAvoidDistanceMin);
|
|
return;
|
|
}
|
|
this._avoidDistance = this._spawner._birdAvoidDistanceMin;
|
|
}
|
|
|
|
// Token: 0x0600156A RID: 5482 RVA: 0x001990CC File Offset: 0x001972CC
|
|
public void SetRandomScale()
|
|
{
|
|
float num = Random.Range(this._spawner._minScale, this._spawner._maxScale);
|
|
this._thisT.localScale = new Vector3(num, num, num);
|
|
}
|
|
|
|
// Token: 0x0600156B RID: 5483 RVA: 0x00199108 File Offset: 0x00197308
|
|
public void SoarTimeLimit()
|
|
{
|
|
if (this._soar && this._spawner._soarMaxTime > 0f)
|
|
{
|
|
if (this._soarTimer > this._spawner._soarMaxTime)
|
|
{
|
|
this.Flap(0.5f);
|
|
this._soarTimer = 0f;
|
|
return;
|
|
}
|
|
this._soarTimer += this._spawner._newDelta;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600156C RID: 5484 RVA: 0x00199174 File Offset: 0x00197374
|
|
public void CheckForDistanceToWaypoint()
|
|
{
|
|
if (!this._landing && (this._thisT.position - this._wayPoint).magnitude < this._spawner._waypointDistance)
|
|
{
|
|
this.Wander();
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600156D RID: 5485 RVA: 0x001991BC File Offset: 0x001973BC
|
|
public void RotationBasedOnWaypointOrAvoidance()
|
|
{
|
|
if (this._avoiding)
|
|
{
|
|
return;
|
|
}
|
|
Vector3 position = this._thisT.position;
|
|
Vector3 vector = this.SubtractVectors(this._wayPoint, position);
|
|
if (this._targetSpeed > -1f && vector.x != 0f && vector.z != 0f)
|
|
{
|
|
Quaternion quaternion = Quaternion.LookRotation(vector);
|
|
this._thisT.rotation = Quaternion.Slerp(this._thisT.rotation, quaternion, this._spawner._newDelta * this._damping);
|
|
}
|
|
if (this._spawner._childTriggerPos && this.SubtractVectors(position, this._spawner._posBuffer).magnitude < 1f)
|
|
{
|
|
this._spawner.SetFlockRandomPosition();
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600156E RID: 5486 RVA: 0x00199284 File Offset: 0x00197484
|
|
private void Move()
|
|
{
|
|
if (this._move)
|
|
{
|
|
this.ChangeSpeed();
|
|
if (!this._closeToSpot)
|
|
{
|
|
this._thisT.position += this._thisT.forward * this._speed * this._spawner._newDelta;
|
|
}
|
|
if (this.SubtractVectors(this._thisT.position, Links.x.rtsCamera.cameraTargetPosition).sqrMagnitude < 2500f && this.Avoidance() && !this._avoiding)
|
|
{
|
|
this._avoiding = true;
|
|
base.Invoke("AvoidNoLonger", Random.Range(0.25f, 0.5f));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600156F RID: 5487 RVA: 0x00199346 File Offset: 0x00197546
|
|
private void AvoidNoLonger()
|
|
{
|
|
this._avoiding = false;
|
|
}
|
|
|
|
// Token: 0x06001570 RID: 5488 RVA: 0x00199350 File Offset: 0x00197550
|
|
private void ChangeSpeed()
|
|
{
|
|
if (this._speed < this._targetSpeed)
|
|
{
|
|
this._speed += this._acceleration * this._spawner._newDelta;
|
|
return;
|
|
}
|
|
if (this._speed > this._targetSpeed)
|
|
{
|
|
this._speed -= this._acceleration * this._spawner._newDelta;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001571 RID: 5489 RVA: 0x001993B8 File Offset: 0x001975B8
|
|
public bool Avoidance()
|
|
{
|
|
if (!this._avoid || !this._spawner._birdAvoid)
|
|
{
|
|
return false;
|
|
}
|
|
Vector3 forward = this._modelT.forward;
|
|
bool flag = false;
|
|
Vector3 position = this._thisT.position;
|
|
Quaternion rotation = this._thisT.rotation;
|
|
Vector3 eulerAngles = this._thisT.rotation.eulerAngles;
|
|
if (Physics.Raycast(this._thisT.position, forward + this._modelT.right * this._avoidValue, this._avoidDistance, 1))
|
|
{
|
|
if (this._landing)
|
|
{
|
|
this._damping = this._spawner._minDamping;
|
|
}
|
|
eulerAngles.y -= (float)this._spawner._birdAvoidHorizontalForce * this._spawner._newDelta * this._damping;
|
|
rotation.eulerAngles = eulerAngles;
|
|
this._thisT.rotation = rotation;
|
|
return true;
|
|
}
|
|
if (Physics.Raycast(this._thisT.position, forward + this._modelT.right * -this._avoidValue, this._avoidDistance, 1))
|
|
{
|
|
if (this._landing)
|
|
{
|
|
this._damping = this._spawner._minDamping;
|
|
}
|
|
eulerAngles.y += (float)this._spawner._birdAvoidHorizontalForce * this._spawner._newDelta * this._damping;
|
|
rotation.eulerAngles = eulerAngles;
|
|
this._thisT.rotation = rotation;
|
|
return true;
|
|
}
|
|
if (this._spawner._birdAvoidDown && this._spawner._birdAvoidDown && !this._landing && Physics.Raycast(this._thisT.position, -Vector3.up, this._avoidDistance, 1))
|
|
{
|
|
eulerAngles.x -= (float)this._spawner._birdAvoidVerticalForce * this._spawner._newDelta * this._damping;
|
|
rotation.eulerAngles = eulerAngles;
|
|
this._thisT.rotation = rotation;
|
|
position.y += (float)this._spawner._birdAvoidVerticalForce * this._spawner._newDelta * 0.01f;
|
|
this._thisT.position = position;
|
|
flag = true;
|
|
}
|
|
if (this._spawner._birdAvoidUp && this._spawner._birdAvoidUp && !this._landing && Physics.Raycast(this._thisT.position, Vector3.up, this._avoidDistance, 1))
|
|
{
|
|
eulerAngles.x += (float)this._spawner._birdAvoidVerticalForce * this._spawner._newDelta * this._damping;
|
|
rotation.eulerAngles = eulerAngles;
|
|
this._thisT.rotation = rotation;
|
|
position.y -= (float)this._spawner._birdAvoidVerticalForce * this._spawner._newDelta * 0.01f;
|
|
this._thisT.position = position;
|
|
flag = true;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x06001572 RID: 5490 RVA: 0x001996BF File Offset: 0x001978BF
|
|
public void LimitRotationOfModel()
|
|
{
|
|
}
|
|
|
|
// Token: 0x06001573 RID: 5491 RVA: 0x001996C4 File Offset: 0x001978C4
|
|
public void Wander()
|
|
{
|
|
if (!this._landing)
|
|
{
|
|
this._damping = Random.Range(this._spawner._minDamping, this._spawner._maxDamping);
|
|
this._targetSpeed = Random.Range(this._spawner._minSpeed, this._spawner._maxSpeed);
|
|
if (this != null)
|
|
{
|
|
this.SetRandomMode();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001574 RID: 5492 RVA: 0x0019972C File Offset: 0x0019792C
|
|
public void Wander(float delay)
|
|
{
|
|
if (!this._landing)
|
|
{
|
|
this._damping = Random.Range(this._spawner._minDamping, this._spawner._maxDamping);
|
|
this._targetSpeed = Random.Range(this._spawner._minSpeed, this._spawner._maxSpeed);
|
|
if (this != null)
|
|
{
|
|
base.Invoke("SetRandomMode", delay);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06001575 RID: 5493 RVA: 0x00199798 File Offset: 0x00197998
|
|
public void SetRandomMode()
|
|
{
|
|
base.CancelInvoke("SetRandomMode");
|
|
if (!this._dived && Random.value < this._spawner._soarFrequency)
|
|
{
|
|
this.Soar(0.75f);
|
|
return;
|
|
}
|
|
if (!this._dived && Random.value < this._spawner._diveFrequency)
|
|
{
|
|
this.Dive();
|
|
return;
|
|
}
|
|
this.Flap(0.5f);
|
|
}
|
|
|
|
// Token: 0x06001576 RID: 5494 RVA: 0x00199804 File Offset: 0x00197A04
|
|
public void Flap(float crossfadeSeconds = 0.5f)
|
|
{
|
|
this.AnimationSpeed();
|
|
this.FindWaypoint();
|
|
if (this.currentAnim == 0 || !this._move)
|
|
{
|
|
return;
|
|
}
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._flapAnimation, crossfadeSeconds);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._flapAnimation, crossfadeSeconds);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.CachedAnimationHandler(0);
|
|
}
|
|
this._soar = false;
|
|
this._dived = false;
|
|
this.currentAnim = 0;
|
|
}
|
|
|
|
// Token: 0x06001577 RID: 5495 RVA: 0x00199894 File Offset: 0x00197A94
|
|
public void FindWaypoint()
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
zero.x = Random.Range(-this._spawner._spawnSphere, this._spawner._spawnSphere) + this._spawner._posBuffer.x;
|
|
zero.z = Random.Range(-this._spawner._spawnSphereDepth, this._spawner._spawnSphereDepth) + this._spawner._posBuffer.z;
|
|
zero.y = Random.Range(-this._spawner._spawnSphereHeight, this._spawner._spawnSphereHeight) + this._spawner._posBuffer.y;
|
|
this._wayPoint = zero;
|
|
}
|
|
|
|
// Token: 0x06001578 RID: 5496 RVA: 0x0019994C File Offset: 0x00197B4C
|
|
public void Soar(float crossfadeSeconds = 0.75f)
|
|
{
|
|
this.FindWaypoint();
|
|
if (this.currentAnim == 1 || !this._move)
|
|
{
|
|
return;
|
|
}
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._soarAnimation, crossfadeSeconds);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._soarAnimation, crossfadeSeconds);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.CachedAnimationHandler(1);
|
|
}
|
|
this._soar = true;
|
|
this.currentAnim = 1;
|
|
}
|
|
|
|
// Token: 0x06001579 RID: 5497 RVA: 0x001999D0 File Offset: 0x00197BD0
|
|
public void CachedAnimationHandler(int type)
|
|
{
|
|
if (!this._bakedAnimator)
|
|
{
|
|
return;
|
|
}
|
|
if (type == 0)
|
|
{
|
|
this._bakedAnimator.SetAnimation(0);
|
|
return;
|
|
}
|
|
if (type == 1)
|
|
{
|
|
this._bakedAnimator.SetAnimation(1);
|
|
return;
|
|
}
|
|
if (type == 2)
|
|
{
|
|
this._bakedAnimator.SetAnimation(2);
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600157A RID: 5498 RVA: 0x00199A20 File Offset: 0x00197C20
|
|
public void Dive()
|
|
{
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
this._modelAnimation.CrossFade(this._spawner._soarAnimation, 0.2f);
|
|
}
|
|
else
|
|
{
|
|
this._animator.CrossFade(this._spawner._soarAnimation, 0.2f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.CachedAnimationHandler(1);
|
|
}
|
|
this.currentAnim = 1;
|
|
this._wayPoint = this._thisT.position;
|
|
this._wayPoint.y = this._wayPoint.y - this._spawner._diveValue;
|
|
this._dived = true;
|
|
}
|
|
|
|
// Token: 0x0600157B RID: 5499 RVA: 0x00199ABC File Offset: 0x00197CBC
|
|
public void AnimationSpeed()
|
|
{
|
|
if (!this._animationIsBaked)
|
|
{
|
|
if (!this._animator)
|
|
{
|
|
if (this.flapState == null)
|
|
{
|
|
this.flapState = this._modelAnimation[this._spawner._flapAnimation];
|
|
this.idleState = this._modelAnimation[this._spawner._idleAnimation];
|
|
this.soarState = this._modelAnimation[this._spawner._soarAnimation];
|
|
}
|
|
float num;
|
|
if (!this._dived && !this._landing)
|
|
{
|
|
num = Random.Range(this._spawner._minAnimationSpeed, this._spawner._maxAnimationSpeed);
|
|
}
|
|
else
|
|
{
|
|
num = this._spawner._maxAnimationSpeed;
|
|
}
|
|
if (this.currentAnim == 0)
|
|
{
|
|
this.flapState.speed = num;
|
|
return;
|
|
}
|
|
if (this.currentAnim == 1)
|
|
{
|
|
this.soarState.speed = num;
|
|
return;
|
|
}
|
|
if (this.currentAnim == 1)
|
|
{
|
|
this.idleState.speed = num;
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!this._dived && !this._landing)
|
|
{
|
|
this._animator.speed = Random.Range(this._spawner._minAnimationSpeed, this._spawner._maxAnimationSpeed);
|
|
return;
|
|
}
|
|
this._animator.speed = this._spawner._maxAnimationSpeed;
|
|
}
|
|
return;
|
|
}
|
|
if (!this._dived && !this._landing)
|
|
{
|
|
this._bakedAnimator.SetSpeedMultiplier(Random.Range(this._spawner._minAnimationSpeed, this._spawner._maxAnimationSpeed));
|
|
return;
|
|
}
|
|
this._bakedAnimator.SetSpeedMultiplier(this._spawner._maxAnimationSpeed);
|
|
}
|
|
|
|
// Token: 0x0400253E RID: 9534
|
|
[HideInInspector]
|
|
public FlockController _spawner;
|
|
|
|
// Token: 0x0400253F RID: 9535
|
|
[HideInInspector]
|
|
public Vector3 _wayPoint;
|
|
|
|
// Token: 0x04002540 RID: 9536
|
|
[HideInInspector]
|
|
public float _speed;
|
|
|
|
// Token: 0x04002541 RID: 9537
|
|
[HideInInspector]
|
|
public bool _dived = true;
|
|
|
|
// Token: 0x04002542 RID: 9538
|
|
[HideInInspector]
|
|
public float _damping;
|
|
|
|
// Token: 0x04002543 RID: 9539
|
|
[HideInInspector]
|
|
public bool _soar = true;
|
|
|
|
// Token: 0x04002544 RID: 9540
|
|
[HideInInspector]
|
|
public bool _landing;
|
|
|
|
// Token: 0x04002545 RID: 9541
|
|
[HideInInspector]
|
|
public bool _landed;
|
|
|
|
// Token: 0x04002546 RID: 9542
|
|
[HideInInspector]
|
|
public LandingSpot _landingSpot;
|
|
|
|
// Token: 0x04002547 RID: 9543
|
|
[HideInInspector]
|
|
public float _targetSpeed;
|
|
|
|
// Token: 0x04002548 RID: 9544
|
|
[HideInInspector]
|
|
public bool _move = true;
|
|
|
|
// Token: 0x04002549 RID: 9545
|
|
public GameObject _model;
|
|
|
|
// Token: 0x0400254A RID: 9546
|
|
public Transform _modelT;
|
|
|
|
// Token: 0x0400254B RID: 9547
|
|
[HideInInspector]
|
|
public float _avoidValue;
|
|
|
|
// Token: 0x0400254C RID: 9548
|
|
[HideInInspector]
|
|
public float _avoidDistance;
|
|
|
|
// Token: 0x0400254D RID: 9549
|
|
private float _soarTimer;
|
|
|
|
// Token: 0x0400254E RID: 9550
|
|
private bool _instantiated;
|
|
|
|
// Token: 0x0400254F RID: 9551
|
|
private static int _updateNextSeed;
|
|
|
|
// Token: 0x04002550 RID: 9552
|
|
private int _updateSeed = -1;
|
|
|
|
// Token: 0x04002551 RID: 9553
|
|
[HideInInspector]
|
|
public bool _avoid = true;
|
|
|
|
// Token: 0x04002552 RID: 9554
|
|
public Transform _thisT;
|
|
|
|
// Token: 0x04002553 RID: 9555
|
|
public Vector3 _landingPosOffset;
|
|
|
|
// Token: 0x04002554 RID: 9556
|
|
[HideInInspector]
|
|
public bool _animationIsBaked;
|
|
|
|
// Token: 0x04002555 RID: 9557
|
|
public BakedMeshAnimator _bakedAnimator;
|
|
|
|
// Token: 0x04002556 RID: 9558
|
|
[HideInInspector]
|
|
public Animation _modelAnimation;
|
|
|
|
// Token: 0x04002557 RID: 9559
|
|
public Animator _animator;
|
|
|
|
// Token: 0x04002558 RID: 9560
|
|
private float _acceleration = 20f;
|
|
|
|
// Token: 0x04002559 RID: 9561
|
|
[HideInInspector]
|
|
public int currentAnim;
|
|
|
|
// Token: 0x0400255A RID: 9562
|
|
[HideInInspector]
|
|
public bool _closeToSpot;
|
|
|
|
// Token: 0x0400255B RID: 9563
|
|
private float distance;
|
|
|
|
// Token: 0x0400255C RID: 9564
|
|
private bool _avoiding;
|
|
|
|
// Token: 0x0400255D RID: 9565
|
|
private AnimationState flapState;
|
|
|
|
// Token: 0x0400255E RID: 9566
|
|
private AnimationState soarState;
|
|
|
|
// Token: 0x0400255F RID: 9567
|
|
private AnimationState idleState;
|
|
|
|
// Token: 0x04002560 RID: 9568
|
|
public Vector3 _landingOffsetFix = new Vector3(0f, 0.1f, 0f);
|
|
}
|