public override void StateThink(float delta) { base.StateThink(delta); if ((double)Vector3.Distance(this.GetEntity().finalDestination, this.GetEntity().ServerPosition) < 2.0 | (double)Time.get_time() - (double)this.lastDestinationTime > 25.0 && (double)this.nextRoamPositionTime == -1.0) { this.nextRoamPositionTime = Time.get_time() + Random.Range(5f, 10f); } if ((double)this.nextRoamPositionTime == -1.0 || (double)Time.get_time() <= (double)this.nextRoamPositionTime) { return; } AIMovePoint bestRoamPosition = this.GetEntity().GetBestRoamPosition(this.GetEntity().ServerPosition); if (Object.op_Implicit((Object)bestRoamPosition)) { float num = Vector3.Distance(((Component)bestRoamPosition).get_transform().get_position(), this.GetEntity().ServerPosition) / 1.5f; bestRoamPosition.MarkUsedForRoam(num + 11f, (BaseEntity)null); } this.lastDestinationTime = Time.get_time(); this.GetEntity().SetDestination(Object.op_Equality((Object)bestRoamPosition, (Object)null) ? this.GetEntity().ServerPosition : ((Component)bestRoamPosition).get_transform().get_position()); this.nextRoamPositionTime = -1f; }
public override void StateThink(float delta) { Vector3 vector3; base.StateThink(delta); if (Vector3.Distance(base.GetEntity().finalDestination, base.GetEntity().ServerPosition) < 2f | Time.time - this.lastDestinationTime > 25f && this.nextRoamPositionTime == -1f) { this.nextRoamPositionTime = Time.time + UnityEngine.Random.Range(5f, 10f); } if (this.nextRoamPositionTime != -1f && Time.time > this.nextRoamPositionTime) { AIMovePoint bestRoamPosition = base.GetEntity().GetBestRoamPosition(base.GetEntity().ServerPosition); if (bestRoamPosition) { float single = Vector3.Distance(bestRoamPosition.transform.position, base.GetEntity().ServerPosition) / 1.5f; bestRoamPosition.MarkUsedForRoam(single + 11f, null); } this.lastDestinationTime = Time.time; vector3 = (bestRoamPosition == null ? base.GetEntity().ServerPosition : bestRoamPosition.transform.position); base.GetEntity().SetDestination(vector3); this.nextRoamPositionTime = -1f; } }