private void ThinkEvade() { if (this.m_Enemies.Count == 0) { this.m_State = SwarmerQueenLarvaStates.SEEK; } else { --this.m_UpdateRate; if (this.m_UpdateRate > 0) { return; } this.m_UpdateRate = 30; int currEvadeNodeIndex = this.m_CurrEvadeNodeIndex; this.FindSafestNodeIndex(); if (currEvadeNodeIndex == this.m_CurrEvadeNodeIndex) { return; } float num1 = new Random().NextInclusive(-this.m_BeltThickness, this.m_BeltThickness); Vector3 evadeLocation = this.m_EvadeLocations[this.m_CurrEvadeNodeIndex]; Vector3 vector3_1 = evadeLocation - this.m_SwarmerQueenLarva.Position; vector3_1.Y = 0.0f; double num2 = (double)vector3_1.Normalize(); Vector3 vector3_2 = Vector3.Cross(vector3_1, Vector3.UnitY); this.m_SwarmerQueenLarva.Maneuvering.PostAddGoal(evadeLocation + vector3_2 * num1, vector3_1); } }
private void ThinkSeek() { if (this.m_Enemies.Count <= 0) { return; } if (this.HiveIsPresent()) { this.FindTarget(); this.m_State = SwarmerQueenLarvaStates.TRACK; } else { this.FindInitialNodeIndex(); this.m_State = SwarmerQueenLarvaStates.EVADE; } }
private void ThinkTrack() { --this.m_EnemyUpdateRate; if (this.m_Target == null || !this.HiveIsPresent() || this.m_EnemyUpdateRate <= 0) { this.m_State = SwarmerQueenLarvaStates.SEEK; } else { --this.m_UpdateRate; if (this.m_UpdateRate > 0) { return; } this.m_UpdateRate = 5; if (!(this.m_Target is Ship)) { return; } Ship target = this.m_Target as Ship; Vector3 vector3_1 = target.Position - this.m_SwarmerHive.Position; Vector3 vector3_2 = target.Maneuvering.Destination - this.m_SwarmerHive.Position; Vector3 vector3_3 = (double)vector3_2.LengthSquared < (double)vector3_1.LengthSquared ? target.Maneuvering.Destination : target.Position; Vector3 vector3_4 = new Vector3(); Vector3 vector3_5 = (double)vector3_2.LengthSquared >= (double)vector3_1.LengthSquared ? vector3_1 : vector3_2; vector3_5.Y = 0.0f; float length = vector3_5.Length; Vector3 look = vector3_5 / length; Vector3 position = this.m_SwarmerHive.Position; Vector3 targetPos; if ((double)length > 3000.0) { targetPos = position + look * Math.Min(length * 0.5f, 3000f); } else { float num = Math.Min((vector3_3 - this.m_SwarmerQueenLarva.Position).Length, 3000f); targetPos = (double)num <= 500.0 ? this.m_SwarmerQueenLarva.Position : vector3_3 - look * num; } this.m_SwarmerQueenLarva.Maneuvering.PostAddGoal(targetPos, look); } }
public override void Initialize() { this.m_Enemies = new List <Ship>(); this.m_State = SwarmerQueenLarvaStates.SEEK; this.m_EnemyUpdateRate = 0; this.m_UpdateRate = 0; this.m_SwarmerHive = (Ship)null; this.m_Target = (IGameObject)null; this.m_HasHadHive = false; this.m_BeltRadius = this.m_SwarmerQueenLarva.Position.Length; this.m_BeltThickness = 1000f; this.m_NumEvadeNodes = 10; this.m_CurrEvadeNodeIndex = 0; float radians = MathHelper.DegreesToRadians(360f / (float)this.m_NumEvadeNodes); this.m_EvadeLocations = new Vector3[this.m_NumEvadeNodes]; for (int index = 0; index < this.m_NumEvadeNodes; ++index) { this.m_EvadeLocations[index] = new Vector3((float)Math.Sin((double)radians * (double)index), 0.0f, (float)Math.Cos((double)radians * (double)index)) * this.m_BeltRadius; } }