using System.Collections.Generic; public class EntityHornetRebirth : EntityFlyingRebirth { public override void Awake() { BoxCollider component = base.gameObject.GetComponent(); if (component) { component.center = new Vector3(0f, 0.35f, 0f); component.size = new Vector3(0.4f, 0.4f, 0.4f); } base.Awake(); Transform transform = base.transform.Find("Graphics/BlobShadowProjector"); if (transform) { transform.gameObject.SetActive(false); } } public override void Init(int _entityClass) { base.Init(_entityClass); this.emodel.SetVisible(true, false); if (this.navigator != null) { this.navigator.setCanDrown(true); } } public override void InitFromPrefab(int _entityClass) { base.InitFromPrefab(_entityClass); this.emodel.SetVisible(true, false); if (this.navigator != null) { this.navigator.setCanDrown(true); } } public override void updateTasks() { if (GamePrefs.GetBool(EnumGamePrefs.DebugStopEnemiesMoving) || GameStats.GetInt(EnumGameStats.GameState) == 2) { return; } base.GetEntitySenses().ClearIfExpired(); if (this.attackCounter > 0) { this.attackCounter--; } if (this.attackCounter <= 0) { Vector3 a = this.waypoint - this.position; float sqrMagnitude = a.sqrMagnitude; if (sqrMagnitude < 1f || sqrMagnitude > 2304f) { if (!base.isWithinHomeDistanceCurrentPosition()) { Vector3 vector = RandomPositionGenerator.CalcTowards(this, 10, 30, base.getMaximumHomeDistance() / 2, base.getHomePosition().position.ToVector3()); if (!vector.Equals(Vector3.zero)) { this.waypoint = vector; this.bDuringHomePathing = true; } } else { this.bDuringHomePathing = false; if (base.GetRevengeTarget() != null && base.GetRevengeTarget().GetDistanceSq(this) < 2304f && this.rand.RandomFloat <= 0.5f) { this.waypoint = base.GetRevengeTarget().GetPosition() + Vector3.up; } else { this.waypoint = base.GetPosition() + new Vector3((this.rand.RandomFloat * 2f - 1f) * 16f, (this.rand.RandomFloat * 2f - 1f) * 16f, (this.rand.RandomFloat * 2f - 1f) * 16f); } } this.waypoint.y = Mathf.Min(this.waypoint.y, 250f); } int num = this.courseChangeCooldown; this.courseChangeCooldown = num - 1; if (num <= 0) { this.courseChangeCooldown += this.rand.RandomRange(5) + 2; if (this.isCourseTraversable(this.waypoint, out sqrMagnitude)) { this.motion += a / sqrMagnitude * 0.1f; } else { this.waypoint = base.GetPosition(); } } } if (base.GetRevengeTarget() != null && base.GetRevengeTarget().IsDead()) { base.SetRevengeTarget((EntityAlive) null); } if (!(base.GetRevengeTarget() == null)) { int num = this.aggroCooldown; this.aggroCooldown = num - 1; if (num > 0) { goto IL_296; } } EntityPlayer closestPlayer = this.world.GetClosestPlayer(this, 48f, false); if (base.CanSee(closestPlayer)) { base.SetRevengeTarget(closestPlayer); } if (base.GetRevengeTarget() != null) { this.aggroCooldown = 20; } IL_296: float distanceSq; if (!this.bDuringHomePathing && base.GetRevengeTarget() != null && (distanceSq = base.GetRevengeTarget().GetDistanceSq(this)) < 2304f) { float y = base.GetRevengeTarget().position.x - this.position.x; float x = base.GetRevengeTarget().position.z - this.position.z; this.rotation.y = Mathf.Atan2(y, x) * 180f / 3.1415927f; if (this.attackCounter <= 0 && distanceSq < 2.8f && this.position.y >= base.GetRevengeTarget().position.y && this.position.y <= base.GetRevengeTarget().getHeadPosition().y && base.Attack(false)) { this.attackCounter = base.GetAttackTimeoutTicks(); base.Attack(true); return; } } else { this.rotation.y = (float)Math.Atan2((double)this.motion.x, (double)this.motion.z) * 180f / 3.1415927f; } } protected bool isCourseTraversable(Vector3 _pos, out float _distance) { float num = _pos.x - this.position.x; float num2 = _pos.y - this.position.y; float num3 = _pos.z - this.position.z; _distance = Mathf.Sqrt(num * num + num2 * num2 + num3 * num3); if (_distance < 1.5f) { return true; } num /= _distance; num2 /= _distance; num3 /= _distance; Bounds boundingBox = this.boundingBox; this.collBB.Clear(); int num4 = 1; while ((float)num4 < _distance - 1f) { boundingBox.center += new Vector3(num, num2, num3); this.world.GetCollidingBounds(this, boundingBox, this.collBB); if (this.collBB.Count > 0) { return false; } num4++; } return true; } public override void fallHitGround(float _v, Vector3 _fallMotion) { } public override bool isDetailedHeadBodyColliders() { return true; } public override bool isRadiationSensitive() { return false; } public override float GetEyeHeight() { return 0.5f; } public override int DamageEntity(DamageSource _damageSource, int _strength, bool _criticalHit, float impulseScale) { return base.DamageEntity(_damageSource, _strength, _criticalHit, impulseScale); } private const float maxDistanceToTarget = 48f; private int courseChangeCooldown; private Vector3 waypoint; private bool bDuringHomePathing; private int aggroCooldown; private int attackCounter; private List collBB = new List(); }