Files
BepInEx/Projects/BanquetForFools/Source/Assembly-CSharp/EnemyGroup.cs
2025-05-21 20:40:04 +02:00

3648 lines
88 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Pathfinding;
using UnityEngine;
// Token: 0x0200002A RID: 42
public class EnemyGroup : MonoBehaviour
{
// Token: 0x060006AF RID: 1711 RVA: 0x0008F5EC File Offset: 0x0008D7EC
public void Setup(Character c1, Character c2, Character c3, Character c4, Character c5, Character c6, Character c7, Character c8, GraphNode startNode, GraphNode n1, GraphNode n2, GraphNode n3, GraphNode n4, GraphNode n5, GraphNode n6, GraphNode n7, GraphNode n8, GraphNode n9, GraphNode n10, GraphNode n11, GraphNode n12)
{
this.center = (Vector3)startNode.position;
this.centroid = this.center;
this.centerNode = startNode;
this.allCharacters.Clear();
this.circleTiles.Clear();
this.centerCharacter = c1;
this.dioramaCharacters = Links.x.diorama.characters;
this.frontOfCircle = this.center;
this.middleCircle = this.center;
this.backOfCircle = this.center;
this.morale = 50;
this.needsFade = true;
this.needsFadeOut = true;
if (this.staminaFilling)
{
this.staminaRecover = Links.x.cellar.GetPooledGameObject(131);
this.staminaRecover.SetActive(false);
}
this.timeSinceGather = Links.x.gameplay.seconds;
if (!Records.x.editor)
{
this.debugConsole = false;
this.debug = false;
}
if (this.debugConsole)
{
Debug.Log(string.Concat(new string[]
{
"New group ",
this.groupID.ToString(),
" aggressive? ",
this.aggressive.ToString(),
" stamina filling? ",
this.staminaFilling.ToString(),
" moving together? ",
this.movingTogether.ToString()
}));
}
if (c1)
{
this.allCharacters.Add(c1);
this.allCharactersFormation.Add(0);
}
if (c2)
{
this.allCharacters.Add(c2);
this.allCharactersFormation.Add(0);
}
if (c3)
{
this.allCharacters.Add(c3);
this.allCharactersFormation.Add(0);
}
if (c4)
{
this.allCharacters.Add(c4);
this.allCharactersFormation.Add(0);
}
if (c5)
{
this.allCharacters.Add(c5);
this.allCharactersFormation.Add(0);
}
if (c6)
{
this.allCharacters.Add(c6);
this.allCharactersFormation.Add(0);
}
if (c7)
{
this.allCharacters.Add(c7);
this.allCharactersFormation.Add(0);
}
if (c8)
{
this.allCharacters.Add(c8);
this.allCharactersFormation.Add(0);
}
this.CheckDirection(false);
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character)
{
character.group = this;
character.inCircle = true;
if (character.actions)
{
character.actions.ai.UpdateCircleTiles();
character.actions.CheckIfRunningAI();
}
character.ClearPathUpdates();
character.ClearCurrentPathNodes();
GraphNode formationPointInCircle = this.GetFormationPointInCircle(character, false);
if (formationPointInCircle != null && formationPointInCircle != character.node)
{
this.JoinCirclePath(formationPointInCircle, character);
}
}
}
if (n1 != null)
{
this.circleTiles.Add(n1);
}
if (n2 != null)
{
this.circleTiles.Add(n2);
}
if (n3 != null)
{
this.circleTiles.Add(n3);
}
if (n4 != null)
{
this.circleTiles.Add(n4);
}
if (n5 != null)
{
this.circleTiles.Add(n5);
}
if (n6 != null)
{
this.circleTiles.Add(n6);
}
if (n7 != null)
{
this.circleTiles.Add(n7);
}
if (n8 != null)
{
this.circleTiles.Add(n8);
}
if (n9 != null)
{
this.circleTiles.Add(n9);
}
if (n10 != null)
{
this.circleTiles.Add(n10);
}
if (n11 != null)
{
this.circleTiles.Add(n11);
}
if (n12 != null)
{
this.circleTiles.Add(n12);
}
this.savedEndPoint = startNode;
if (this.centerCharacter && this.centerCharacter.actions)
{
this.savedTarget = this.centerCharacter.actions.ai.NearestEnemy();
}
this.moveTo = (Vector3)this.savedEndPoint.position;
this.openTiles.Clear();
for (int j = 0; j < this.circleTiles.Count; j++)
{
this.openTiles.Add(this.circleTiles[j]);
}
int num = 9;
if (this.allCharacters.Count <= 6)
{
num = 6;
}
if (this.allCharacters.Count <= 4)
{
num = 4;
}
if (this.allCharacters.Count <= 3)
{
num = 3;
}
this.circleTiles.Clear();
this.circleTiles.Add(startNode);
for (int k = 1; k < 9; k++)
{
int num2 = -1;
if (num == 9 || num == 6)
{
if (k == 1)
{
num2 = 1;
}
if (k == 2)
{
num2 = 0;
}
if (k == 3)
{
num2 = 4;
}
if (k == 4)
{
num2 = 7;
}
if (k == 5)
{
num2 = 3;
}
if (k == 6)
{
num2 = 2;
}
if (k == 7)
{
num2 = 5;
}
if (k == 8)
{
num2 = 6;
}
}
else if (num == 4)
{
if (k == 1)
{
num2 = 1;
}
if (k == 2)
{
num2 = 0;
}
if (k == 3)
{
num2 = 4;
}
}
else if (num == 3)
{
if (k == 1)
{
num2 = 1;
}
if (k == 2)
{
num2 = 0;
}
}
if (num2 > -1)
{
GraphNode connectionAtIndex = startNode.GetConnectionAtIndex(num2);
if (connectionAtIndex != null)
{
float num3 = float.PositiveInfinity;
int num4 = -1;
for (int l = 0; l < this.openTiles.Count; l++)
{
float sqrMagnitude = ((Vector3)this.openTiles[l].position - (Vector3)connectionAtIndex.position).sqrMagnitude;
if (sqrMagnitude < num3)
{
num3 = sqrMagnitude;
num4 = l;
}
}
if (num4 > -1)
{
this.circleTiles.Add(this.openTiles[num4]);
this.openTiles.RemoveAt(num4);
}
}
}
}
if (this.circleTiles.Count < num && n1 != null && !this.circleTiles.Contains(n1))
{
this.circleTiles.Add(n1);
}
if (this.circleTiles.Count < num && n2 != null && !this.circleTiles.Contains(n2))
{
this.circleTiles.Add(n2);
}
if (this.circleTiles.Count < num && n3 != null && !this.circleTiles.Contains(n3))
{
this.circleTiles.Add(n3);
}
if (this.circleTiles.Count < num && n4 != null && !this.circleTiles.Contains(n4))
{
this.circleTiles.Add(n4);
}
if (this.circleTiles.Count < num && n5 != null && !this.circleTiles.Contains(n5))
{
this.circleTiles.Add(n5);
}
if (this.circleTiles.Count < num && n6 != null && !this.circleTiles.Contains(n6))
{
this.circleTiles.Add(n6);
}
if (this.circleTiles.Count < num && n7 != null && !this.circleTiles.Contains(n7))
{
this.circleTiles.Add(n7);
}
if (this.circleTiles.Count < num && n8 != null && !this.circleTiles.Contains(n8))
{
this.circleTiles.Add(n8);
}
if (this.circleTiles.Count < num && n9 != null && !this.circleTiles.Contains(n9))
{
this.circleTiles.Add(n9);
}
bool flag = true;
Vector3 vector = (Vector3)this.circleTiles[0].position;
for (int m = 1; m < this.circleTiles.Count; m++)
{
if ((vector - (Vector3)this.circleTiles[m].position).sqrMagnitude > 16f)
{
flag = false;
}
}
if (!flag)
{
this.circleTiles.Clear();
if (n1 != null)
{
this.circleTiles.Add(n1);
}
if (n2 != null)
{
this.circleTiles.Add(n2);
}
if (n3 != null)
{
this.circleTiles.Add(n3);
}
if (n4 != null)
{
this.circleTiles.Add(n4);
}
if (n5 != null)
{
this.circleTiles.Add(n5);
}
if (n6 != null)
{
this.circleTiles.Add(n6);
}
if (n7 != null)
{
this.circleTiles.Add(n7);
}
if (n8 != null)
{
this.circleTiles.Add(n8);
}
if (n9 != null)
{
this.circleTiles.Add(n9);
}
if (n10 != null)
{
this.circleTiles.Add(n10);
}
if (n11 != null)
{
this.circleTiles.Add(n11);
}
if (n12 != null)
{
this.circleTiles.Add(n12);
}
}
for (int num5 = 0; num5 < this.circleTiles.Count; num5++)
{
if (this.circleTiles[num5].circle == 0)
{
this.circleTiles[num5].circle = this.groupID;
}
this.nearNodes.Add(this.circleTiles[num5]);
}
this.SetCircleTiles(false);
if (this.staminaFilling || this.aggressive || this.movingTogether)
{
this.inFormationMovement = true;
this.timeSinceFormation = Links.x.gameplay.seconds;
for (int num6 = 0; num6 < this.allCharactersFormation.Count; num6++)
{
this.allCharactersFormation[num6] = 1;
}
this.FormationPoints(true, this.centerCharacter, this.savedEndPoint, "Flank");
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " Start formation listen");
}
}
else
{
this.defensive = true;
}
for (int num7 = 0; num7 < this.allCharacters.Count; num7++)
{
this.originalCharacters.Add(this.allCharacters[num7]);
this.timeOutsideCircle.Add(-1f);
}
}
// Token: 0x060006B0 RID: 1712 RVA: 0x0009001C File Offset: 0x0008E21C
public void Update()
{
if (this.fading)
{
this.currentDither = Mathf.Lerp(this.startDither, this.endDither, this.fadeAmount);
if ((this.endDither == 1f && this.currentDither >= 1f) || (this.endDither == 0f && this.currentDither <= 0f))
{
this.fading = false;
if (this.endDither == 1f)
{
Links.x.cameraEffects.ClearEnemyGroupTiles(this);
}
}
if (this.endDither == 1f)
{
this.fadeAmount += Time.deltaTime * 5f;
}
else
{
this.fadeAmount += Time.deltaTime * 1f;
}
}
if (this.pulsing)
{
this.pulse = Mathf.Lerp(this.startPulseDither, this.endPulseDither, this.pulseAmount);
if ((this.endPulseDither == 1f && this.pulse >= 1f) || (this.endPulseDither == 0f && this.pulse <= 0.01f))
{
if (this.endPulseDither == 1f)
{
this.StartPulse(false);
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character.hasCreatureBuff)
{
this.Rest(character);
}
}
}
else
{
this.pulsing = false;
}
}
else
{
this.pulseAmount += Time.deltaTime * 4f;
}
}
if (Links.x.gaia.pathfindingReady && Links.x.gaia.sceneLoaded && Records.x.combat && !this.isBreaking)
{
bool flag = false;
bool flag2 = true;
int count = this.originalCharacters.Count;
int num = (int)Mathf.Ceil((float)count / 2f) - 1;
int num2 = (int)Mathf.Round((float)count * 0.8f);
int num3 = (int)Mathf.Round((float)count * 0.6f);
if (num < 2)
{
num = 2;
}
int num4 = 1;
if (num == 4 || num == 5)
{
num4 = 2;
}
if (num >= 6)
{
num4 = 3;
}
this.dangerLevel = 0;
this.inCircleCount = 0;
this.canBeInCircle = 0;
float seconds = Links.x.gameplay.seconds;
int num5 = 0;
for (int j = 0; j < count; j++)
{
Character character2 = this.originalCharacters[j];
if (character2 && character2.IsSentient() && character2.inCircle)
{
bool flag3;
if (!character2.hasCreatureBuff)
{
if (this.timeOutsideCircle[j] == 0f)
{
this.canBeInCircle++;
this.timeOutsideCircle[j] = seconds;
flag3 = true;
if (this.defensive && this.CharacterNeedsToBeDefended(character2))
{
num5++;
}
}
else if (this.timeOutsideCircle[j] == -1f)
{
this.canBeInCircle++;
if (character2.hasCreatureBuff)
{
this.timeOutsideCircle[j] = 0f;
}
flag3 = true;
if (this.defensive && this.CharacterNeedsToBeDefended(character2))
{
num5++;
}
}
else if (seconds > this.timeOutsideCircle[j] + 10f)
{
this.canBeInCircle++;
flag3 = false;
if (this.defensive && this.CharacterNeedsToBeDefended(character2))
{
num5++;
}
}
else if (seconds > this.timeOutsideCircle[j] + 80f || (character2.fleeing && seconds > this.timeOutsideCircle[j] + 10f))
{
this.timeOutsideCircle[j] = -1f;
flag3 = false;
flag2 = true;
this.LeaveCircle(character2);
}
else
{
if (this.defensive && this.CharacterNeedsToBeDefended(character2))
{
num5++;
}
this.canBeInCircle++;
flag3 = true;
}
}
else
{
if (this.defensive && this.CharacterNeedsToBeDefended(character2))
{
num5++;
}
this.canBeInCircle++;
this.timeOutsideCircle[j] = 0f;
flag3 = character2.IsSentient();
if (!character2.IsSentient())
{
flag2 = true;
}
}
if (flag3)
{
this.inCircleCount++;
}
}
}
if (this.defensive && num5 == 0)
{
flag = true;
}
if (this.inCircleCount < num && !this.inSwarm && !this.inSwarmWait && !this.inFormationMovement && !this.movingTogether)
{
flag = true;
}
else
{
if (this.inCircleCount <= num2)
{
this.dangerLevel++;
}
if (this.inCircleCount <= num3)
{
this.dangerLevel++;
}
}
if (!flag)
{
this.intruderTemp.Clear();
this.intruderTimeTemp.Clear();
int num6 = 0;
int num7 = 0;
int num8 = 0;
Character characterInCircle = this.centerCharacter;
if (!characterInCircle)
{
characterInCircle = this.GetCharacterInCircle();
this.centerCharacter = characterInCircle;
}
if (characterInCircle)
{
for (int k = 0; k < this.dioramaCharacters.Count; k++)
{
Character character3 = this.dioramaCharacters[k];
if (character3 && (!character3.npc || characterInCircle.stats.IsTargetAnEnemy(character3.stats.allegiance)) && this.InCircle(character3.currentPosition, true, false, null))
{
int num9 = this.intruders.IndexOf(character3);
if (num9 == -1)
{
this.intruderTemp.Add(character3);
this.intruderTimeTemp.Add(seconds);
}
else
{
float num10 = this.intruderTime[num9];
this.intruderTemp.Add(character3);
this.intruderTimeTemp.Add(num10);
if (seconds > num10 + 100f)
{
num6++;
if (seconds > num10 + 400f)
{
num8++;
}
}
else
{
num7++;
}
}
}
}
this.intruders.Clear();
this.intruderTime.Clear();
int num11 = 0;
for (int l = 0; l < this.intruderTemp.Count; l++)
{
this.intruders.Add(this.intruderTemp[l]);
this.intruderTime.Add(this.intruderTimeTemp[l]);
if (seconds > this.intruderTimeTemp[l] + 60f)
{
num11++;
}
}
if (num6 >= num4 || num8 > 0)
{
flag = true;
flag2 = true;
}
if (num6 >= 1)
{
this.dangerLevel++;
}
if (num7 >= 1)
{
this.dangerLevel++;
}
if (num11 >= 2)
{
this.dangerLevel++;
}
}
else
{
flag = true;
}
}
if (!flag)
{
if (this.aggressive || this.staminaFilling || this.movingTogether)
{
if (this.inSwarmWait && seconds > this.timeSinceSwarmWait)
{
if (!this.movingTogether)
{
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " Swarm wait over, breaking");
}
this.BreakCircle(false, true);
return;
}
if (this.formationCoroutine == null && this.centerCharacter)
{
if (this.formationFlankTries >= 100 || Random.Range(0, 3) == 0)
{
this.BreakCircle(false, false);
return;
}
this.FindFormationPoint("Flank");
}
}
if (this.inSwarm && seconds > this.timeSinceSwarm + 1f)
{
int num12;
bool flag4 = this.CanEndFormation("Swarm", out num12);
if (!flag4 && this.formationCoroutine == null && seconds > this.timeSinceSwarm + 80f)
{
int num13 = 0;
int count2 = this.allCharacters.Count;
int num14 = 0;
for (int m = 0; m < count2; m++)
{
Character character4 = this.allCharacters[m];
float sqrMagnitude = this.SubtractVectors(character4.currentPosition, this.moveTo).sqrMagnitude;
if (sqrMagnitude < 16f)
{
num13++;
num14++;
}
if (character4.IsSentient() && !character4.isHit && character4.moving && sqrMagnitude < 225f && sqrMagnitude > 16f)
{
num14++;
}
}
if (num14 <= 1 || seconds > this.timeSinceSwarm + 150f)
{
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " Moving group because too much time has passed");
}
flag4 = true;
}
}
if (flag4)
{
if (this.debugConsole)
{
Debug.Log(string.Concat(new string[]
{
this.groupID.ToString(),
" End swarm ",
this.aggressive.ToString(),
" ",
seconds.ToString(),
" ",
this.timeSinceSwarm.ToString()
}));
}
this.inSwarm = false;
this.inSwarmWait = true;
this.center = this.centroid;
if (this.movingTogether)
{
this.timeSinceSwarmWait = seconds + (float)Random.Range(20, 40);
return;
}
this.timeSinceSwarmWait = seconds + 50f;
return;
}
}
if (this.inFormationWait)
{
if (!this.canShowLine && !this.movingTogether)
{
bool flag5 = false;
for (int n = 0; n < this.allCharacters.Count; n++)
{
Character character5 = this.allCharacters[n];
if (character5 && this.SubtractVectors(this.moveTo, character5.tr.position).sqrMagnitude < 25f)
{
flag5 = true;
break;
}
}
if (flag5)
{
this.canShowLine = true;
}
}
float num15 = 60f;
if (this.staminaFilling)
{
num15 = 200f;
}
if (this.movingTogether)
{
num15 = 30f;
}
if (seconds > this.timeSinceFormationWait + num15)
{
if (((this.inCircleCharacters.Count >= this.canBeInCircle - 1 && this.canBeInCircle > 2) || this.inCircleCharacters.Count == this.canBeInCircle || seconds > this.timeSinceFormationWait + num15 + 50f) && this.formationCoroutine == null && this.centerCharacter)
{
this.center = this.centroid;
if (this.debugConsole)
{
Debug.Log(string.Concat(new string[]
{
this.groupID.ToString(),
" end formation wait ",
this.inCircleCharacters.Count.ToString(),
" ",
this.canBeInCircle.ToString()
}));
}
if (this.staminaFilling)
{
this.BreakCircle(false, false);
return;
}
int num16 = 0;
int num17 = 0;
if (this.centerCharacter.stats.xmlName.Contains("Bakka") && !this.movingTogether)
{
for (int num18 = 0; num18 < this.allCharacters.Count; num18++)
{
Character character6 = this.allCharacters[num18];
if (character6 && character6.actions && character6.hasCreatureBuff)
{
if (character6.actions.ai.findingAction)
{
character6.actions.CheckIfRunningAI();
}
character6.ClearNodePath();
if (character6.IsSentient())
{
num17++;
if (this.Attack(character6, true))
{
num16++;
}
else
{
this.Attack(character6, false);
}
Effects effects = character6.gameObject.AddComponent<Effects>();
Links.x.cellar.AddEffects(effects);
effects.gameObject.SetActive(true);
effects.source = character6;
effects.target = character6;
effects.sourceLevel = (float)character6.stats.characterRow._Level;
effects.effectName = "CircleOffense";
effects.Inflicted(false);
this.EndChargeUp(character6);
}
}
}
for (int num19 = 0; num19 < this.allCharacters.Count; num19++)
{
Character character7 = this.allCharacters[num19];
}
this.BreakCircle(false, true);
return;
}
if (this.formationSwarmTries >= 100)
{
this.BreakCircle(false, false);
return;
}
if (this.movingTogether)
{
if (Random.Range(0, 2) == 0)
{
this.FindFormationPoint("Flank");
}
else
{
this.FindFormationPoint("Swarm");
}
}
else
{
this.FindFormationPoint("Swarm");
}
}
}
else if (this.staminaFilling)
{
bool flag6 = true;
bool flag7 = false;
bool flag8 = false;
if (Links.x.gameplay.seconds > this.staminaFillTime + 5f)
{
flag8 = true;
this.staminaFillTime = Links.x.gameplay.seconds;
}
if (this.inCircleCharacters.Count < this.allCharacters.Count - 1)
{
flag7 = true;
}
for (int num20 = 0; num20 < this.allCharacters.Count; num20++)
{
if ((this.allCharacters[num20].hasCreatureBuff || flag7) && this.allCharacters[num20].stats.StaminaPercent() < 0.93f)
{
flag6 = false;
}
if (flag8 && this.allCharacters[num20].hasCreatureBuff)
{
this.allCharacters[num20].stats.AddStamina(1f);
}
}
if (flag6)
{
this.BreakCircle(false, false);
}
}
}
if (this.inFormationMovement)
{
int num21;
bool flag9 = this.CanEndFormation("Flank", out num21);
if (!flag9)
{
float num22 = 250f;
if (this.aggressive)
{
num22 = 150f;
}
if (seconds > this.timeSinceFormation + num22 && this.formationCoroutine == null)
{
int num23 = 0;
int count3 = this.allCharacters.Count;
int num24 = 0;
for (int num25 = 0; num25 < count3; num25++)
{
Character character8 = this.allCharacters[num25];
float sqrMagnitude2 = this.SubtractVectors(character8.currentPosition, this.moveTo).sqrMagnitude;
if (sqrMagnitude2 < 49f)
{
num23++;
num24++;
}
else if (character8.IsSentient() && !character8.isHit && !character8.inAction && sqrMagnitude2 < 225f)
{
num24++;
}
}
if ((num23 >= num24 - 1 && this.useCenterLinking) || (!this.useCenterLinking && this.inCircleCount > num && num > 2) || (!this.useCenterLinking && this.inCircleCount == this.canBeInCircle) || seconds > this.timeSinceFormation + (num22 + 50f))
{
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " Moving group because too much time has passed");
}
flag9 = true;
}
}
}
if (flag9)
{
this.inFormationMovement = false;
this.inFormationWait = true;
this.RemoveAllMovementFlags();
this.timeSinceFormationWait = seconds;
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " start formation wait, can show line = " + this.canShowLine.ToString());
}
}
}
}
if (!this.movingTogether && this.canShowLine)
{
if (this.dangerLevel == 0)
{
this.morale = 100;
}
if (this.dangerLevel == 1)
{
this.morale = 50;
}
if (this.dangerLevel >= 2)
{
this.morale = 10;
}
}
else
{
this.morale = 100;
}
if (seconds > this.checkDirectionTime + 15f)
{
this.CheckDirection(true);
this.checkDirectionTime = seconds;
}
this.linkedTiles.Clear();
this.inCircleCharacters.Clear();
this.CheckCircle(false);
if (this.inCircleCharacters.Count >= 1)
{
this.circleIsActive = true;
}
else
{
this.circleIsActive = false;
}
this.centroid = Vector3.zero;
int num26 = 0;
for (int num27 = 0; num27 < this.inCircleCharacters.Count; num27++)
{
this.centroid += this.inCircleCharacters[num27].currentPosition;
num26++;
}
if (!this.circleIsActive)
{
num26 = 0;
for (int num28 = 0; num28 < this.circleTiles.Count; num28++)
{
this.centroid += (Vector3)this.circleTiles[num28].position;
num26++;
}
}
if (this.centroid != Vector3.zero && num26 > 0 && (this.staminaFilling || this.aggressive || this.movingTogether))
{
if (this.inFormationMovement || this.inSwarm)
{
this.centroid /= (float)num26;
}
else
{
this.centroid /= (float)num26;
}
}
else if (this.inFormationMovement || this.inSwarm)
{
this.centroid = this.centerCharacter.currentPosition;
}
else
{
this.centroid = this.center;
}
if (this.circleIsActive)
{
this.CheckCircle(true);
for (int num29 = 0; num29 < this.inCircleCharacters.Count; num29++)
{
Character character9 = this.inCircleCharacters[num29];
if (character9 != null)
{
this.linkedTiles.Add(character9.currentPosition);
}
}
if (this.canShowLine && this.staminaFilling && this.inCircleCharacters.Count > 0)
{
float num30 = 20f;
if (!this.staminaFilling)
{
num30 = 200f;
}
if (seconds > this.updateTime + num30 && !this.pulsing)
{
this.updateTime = seconds;
this.StartPulse(true);
}
}
this.SetCircleTiles(false);
}
if (this.canShowLine && this.staminaFilling && !this.staminaRecover.activeSelf && Time.timeSinceLevelLoad > this.staminaRecoverTime + 1f)
{
this.PlaceStamina();
this.staminaRecoverTime = Time.timeSinceLevelLoad;
}
if (!this.aggressive && !this.staminaFilling && !this.movingTogether)
{
this.canShowLine = true;
}
if (!this.canShowLine || ((this.staminaFilling || this.aggressive) && !this.inFormationWait && !this.inFormationMovement))
{
if (this.canShowLine && this.useCenterLinking)
{
Links.x.cameraEffects.ClearEnemyGroupTiles(this);
}
this.ReturnLines(this.linenum);
return;
}
bool flag10 = false;
if (this.aggressive || this.staminaFilling)
{
bool flag11 = true;
if (this.linkedTiles.Count > 1)
{
for (int num31 = 1; num31 < this.linkedTiles.Count; num31++)
{
if (flag11)
{
Vector3 vector = this.linkedTiles[num31];
bool flag12 = false;
for (int num32 = 0; num32 < this.linkedTiles.Count; num32++)
{
if (num32 != num31 && !flag12 && (this.linkedTiles[num32] - vector).sqrMagnitude < 13.690001f)
{
flag12 = true;
}
}
if (!flag12)
{
flag11 = false;
}
}
}
}
flag10 = false;
}
if (this.needsFade)
{
this.StartCircleFade(false);
this.needsFade = false;
if (!this.useCenterLinking && !flag10 && !this.movingTogether)
{
for (int num33 = 0; num33 < this.circleTiles.Count; num33++)
{
Links.x.cameraEffects.GroupCharacters((Vector3)this.circleTiles[num33].position, this, true);
}
}
if (this.centerCharacter.stats.isFishMonster)
{
this.AddEffect("Acid");
}
}
if (flag10 && !this.movingTogether)
{
Links.x.cameraEffects.ClearEnemyGroupTiles(this);
for (int num34 = 0; num34 < this.linkedTiles.Count; num34++)
{
Links.x.cameraEffects.GroupCharacters(this.linkedTiles[num34], this, true);
}
}
if (this.useCenterLinking && !this.movingTogether)
{
Links.x.cameraEffects.ClearEnemyGroupTiles(this);
for (int num35 = 0; num35 < this.linkedTiles.Count; num35++)
{
Links.x.cameraEffects.GroupCharacters(this.linkedTiles[num35], this, true);
}
return;
}
}
else
{
this.BreakCircle(flag2, false);
}
}
}
// Token: 0x060006B1 RID: 1713 RVA: 0x00091518 File Offset: 0x0008F718
public void CheckDirection(bool sendMoveEvent)
{
if (!this.centerCharacter)
{
return;
}
Quaternion quaternion = this.targetRotation;
Vector3 vector = this.centerCharacter.currentPosition;
if (this.centerCharacter.actions)
{
Character character = this.centerCharacter.actions.ai.NearestEnemy();
if (character)
{
vector = character.currentPosition;
}
}
if (vector == this.centerCharacter.currentPosition)
{
vector = Links.x.gameplay.NearestEnemyClump(false, this.centerCharacter);
}
if (vector == Vector3.zero)
{
vector = this.centerCharacter.currentPosition;
}
Vector3 vector2 = this.centroid;
if (!this.useCenterLinking)
{
vector2 = (Vector3)this.centerNode.position;
}
this.targetRotation = Quaternion.LookRotation(vector - vector2);
Vector3 vector3 = vector2 + this.targetRotation * Vector3.forward * 10f;
this.middleCircle = vector2;
vector2 + this.targetRotation * Vector3.forward * -10f;
float num = float.PositiveInfinity;
for (int i = 0; i < this.circleTiles.Count; i++)
{
if (this.circleTiles[i] != null)
{
float sqrMagnitude = ((Vector3)this.circleTiles[i].position - vector3).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
this.frontOfCircle = (Vector3)this.circleTiles[i].position;
}
}
}
if (this.GetRotationAngle(quaternion, this.targetRotation) > 60f && sendMoveEvent)
{
for (int j = 0; j < this.allCharacters.Count; j++)
{
Character character2 = this.allCharacters[j];
if (character2 && character2.hasCreatureBuff && !character2.moving && !character2.inAction && !character2.inRecovery && character2.IsSentient() && character2.hasCreatureBuff && !character2.turning && this.GetRotationAngle(this.targetRotation, character2.rot) > 40f)
{
character2.SetRotation(this.targetRotation, true, false);
}
}
}
}
// Token: 0x060006B2 RID: 1714 RVA: 0x00091778 File Offset: 0x0008F978
private void GetChargeUp(Character c)
{
if (!c.actions)
{
return;
}
if (!c.actions.chargeUpFX)
{
c.actions.chargeUpNum = 130;
c.actions.chargeUpFX = Links.x.cellar.GetPooledGameObject(c.actions.chargeUpNum);
c.actions.chargeUpFX.transform.SetParent(c.body.GetNeck(), true);
c.actions.chargeUpFX.transform.localPosition = Vector3.zero;
c.actions.chargeUpFX.SetActive(true);
}
if (c.stats.animal && c.stats.hasCircleAnims)
{
c.animator.SetBool("Hyped", true);
if (c.animID == 0)
{
c.PlayAnimation("Hyped", 0f);
}
}
}
// Token: 0x060006B3 RID: 1715 RVA: 0x0009186C File Offset: 0x0008FA6C
private void EndChargeUp(Character c)
{
if (c.actions)
{
c.actions.ReturnChargeUpFX();
}
c.animator.SetBool("Hyped", false);
}
// Token: 0x060006B4 RID: 1716 RVA: 0x00091898 File Offset: 0x0008FA98
public void CheckCircle(bool canAddBuff)
{
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character && character.inCircle)
{
bool hasCreatureBuff = character.hasCreatureBuff;
if (this.LinkedToCenter(character) && character.IsSentient())
{
if (!hasCreatureBuff && canAddBuff && this.canShowLine)
{
character.hasCreatureBuff = true;
if (!this.aggressive && !this.staminaFilling && !this.movingTogether)
{
Effects effects = character.gameObject.AddComponent<Effects>();
Links.x.cellar.AddEffects(effects);
effects.gameObject.SetActive(true);
effects.source = character;
effects.target = character;
effects.sourceLevel = (float)character.stats.characterRow._Level;
effects.effectName = "CircleDefense";
effects.Inflicted(false);
}
if (this.aggressive && character.actions)
{
character.actions.ai.circleMovement = false;
}
}
if (!canAddBuff)
{
this.inCircleCharacters.Add(character);
}
if (canAddBuff && this.canShowLine && this.aggressive && (this.inFormationWait || this.inFormationMovement))
{
if (true)
{
this.GetChargeUp(character);
}
else
{
this.EndChargeUp(character);
}
}
}
else if (hasCreatureBuff)
{
bool flag = true;
int num = this.originalCharacters.IndexOf(character);
if (num > -1 && Links.x.gameplay.seconds < this.timeOutsideCircle[num] + 10f)
{
flag = false;
}
if (flag)
{
character.hasCreatureBuff = false;
if (!this.aggressive && !this.staminaFilling && !this.movingTogether)
{
character.stats.HealEffect("CircleDefense");
}
if (character.actions && this.aggressive)
{
this.EndChargeUp(character);
}
if (character.resting)
{
character.resting = false;
character.GetUp();
}
}
}
}
}
}
// Token: 0x060006B5 RID: 1717 RVA: 0x00091AC0 File Offset: 0x0008FCC0
public int FreeSpots()
{
int count = this.originalCharacters.Count;
int count2 = this.allCharacters.Count;
if (count2 < count)
{
return count - count2;
}
return 0;
}
// Token: 0x060006B6 RID: 1718 RVA: 0x00091AF0 File Offset: 0x0008FCF0
public void Rest(Character v)
{
if (!v.resting && v.stats.hasCircleAnims)
{
v.resting = true;
if (!v.moving && !v.stats.pinned && !v.stats.pinning && v.NodesCount() == 0 && v.waitingForPath == 0 && !v.isHit && v.IsSentient())
{
v.PlayAnimation("Idle", 0f);
}
}
}
// Token: 0x060006B7 RID: 1719 RVA: 0x00091B6B File Offset: 0x0008FD6B
public bool LinkedToCenter(Character c)
{
return this.LinkedToCenter(c.currentPosition, c);
}
// Token: 0x060006B8 RID: 1720 RVA: 0x00091B7C File Offset: 0x0008FD7C
public bool LinkedToCenter(Vector3 pt, Character c)
{
if (this.useCenterLinking)
{
float num = 14.0625f;
if (this.inFormationMovement)
{
num = 20.25f;
}
if (this.SubtractVectors(this.centroid, pt).sqrMagnitude <= num)
{
return true;
}
if (this.centerCharacter && (this.inFormationMovement || this.inSwarm) && this.SubtractVectors(this.centerCharacter.tr.position, pt).sqrMagnitude <= 100f)
{
return true;
}
int count = this.allCharacters.Count;
for (int i = 0; i < count; i++)
{
Character character = this.allCharacters[i];
if (character && character != c && character.IsSentient() && !character.body.IsHit())
{
Vector3 currentPosition = character.currentPosition;
if (this.SubtractVectors(currentPosition, pt).sqrMagnitude <= num && this.SubtractVectors(currentPosition, this.centroid).sqrMagnitude <= num)
{
return true;
}
}
}
}
else if (this.InCircle(pt, true, false, null))
{
return true;
}
return false;
}
// Token: 0x060006B9 RID: 1721 RVA: 0x00091CA8 File Offset: 0x0008FEA8
public bool LinkedToNewPoint(Vector3 pt, Character c)
{
if (this.useCenterLinking)
{
float num = 14.0625f;
Vector3 currentPosition = c.currentPosition;
if (this.SubtractVectors(pt, currentPosition).sqrMagnitude <= num)
{
return true;
}
int count = this.allCharacters.Count;
for (int i = 0; i < count; i++)
{
Character character = this.allCharacters[i];
if (character && character != c)
{
Vector3 currentPosition2 = character.currentPosition;
if (this.SubtractVectors(currentPosition2, currentPosition).sqrMagnitude <= num && this.SubtractVectors(currentPosition2, pt).sqrMagnitude <= num)
{
return true;
}
}
}
}
else if (this.InCircle(pt, true, false, null))
{
return true;
}
return false;
}
// Token: 0x060006BA RID: 1722 RVA: 0x00091D64 File Offset: 0x0008FF64
public bool InCircle(GraphNode n, bool mustBeInside, bool testLinked, Character c)
{
return this.InCircle((Vector3)n.position, mustBeInside, testLinked, c);
}
// Token: 0x060006BB RID: 1723 RVA: 0x00091D7C File Offset: 0x0008FF7C
public bool InCircle(Vector3 test, bool mustBeInside, bool testLinked, Character c)
{
bool flag = false;
Vector3 vector = Vector3.zero;
float num = 5f;
if (mustBeInside)
{
num = 1.5f;
}
for (int i = 0; i < this.circleTiles.Count; i++)
{
vector = (Vector3)this.circleTiles[i].position;
float num2 = vector.x - test.x;
if (num2 < 0f)
{
num2 *= -1f;
}
if (num2 < num)
{
float num3 = vector.z - test.z;
if (num3 < 0f)
{
num3 *= -1f;
}
if (num3 < num)
{
flag = true;
break;
}
}
}
return flag;
}
// Token: 0x060006BC RID: 1724 RVA: 0x00091E24 File Offset: 0x00090024
public void AddToCircle(Character c)
{
if (!this.isBreaking)
{
if (this.debugConsole)
{
Debug.Log("Adding to group! " + ((c != null) ? c.ToString() : null));
}
this.originalCharacters.Add(c);
this.allCharacters.Add(c);
this.allCharactersFormation.Add(0);
this.timeOutsideCircle.Add(-1f);
c.inCircle = true;
c.group = this;
if (c.actions)
{
c.actions.ai.UpdateCircleTiles();
}
}
}
// Token: 0x060006BD RID: 1725 RVA: 0x00091EC0 File Offset: 0x000900C0
public void LeaveCircle(Character c)
{
int num = this.allCharacters.IndexOf(c);
if (num > -1)
{
this.allCharacters.RemoveAt(num);
this.allCharactersFormation.RemoveAt(num);
}
c.hasCreatureBuff = false;
c.ignoreNodeIDs = false;
c.inCircle = false;
c.timeSinceCircle = Links.x.gameplay.seconds;
c.stats.HealEffect("CircleDefense");
if (c.resting)
{
c.resting = false;
c.GetUp();
}
if (this.aggressive && c.actions)
{
c.actions.ReturnChargeUpFX();
}
c.animator.SetBool("Hyped", false);
}
// Token: 0x060006BE RID: 1726 RVA: 0x00091F76 File Offset: 0x00090176
public void BreakCircle(bool fromEnemies, bool swarmBreak)
{
if (!this.isBreaking)
{
this.isBreaking = true;
base.StartCoroutine(this.Break(fromEnemies, swarmBreak));
}
}
// Token: 0x060006BF RID: 1727 RVA: 0x00091F96 File Offset: 0x00090196
private IEnumerator Break(bool fromEnemies, bool swarmBreak)
{
if (this.debugConsole)
{
Debug.Log(this.groupID.ToString() + " BREAK CIRCLE");
}
this.SetCircleTiles(true);
this.RemoveAllMovementFlags();
this.RemoveEffect();
for (int i = 0; i < this.circleTiles.Count; i++)
{
if (this.circleTiles[i].circle == this.groupID)
{
this.circleTiles[i].circle = 0;
}
}
if (this.staminaRecover)
{
Links.x.cellar.ReturnPooledGameObject(131, this.staminaRecover);
}
for (int j = 0; j < this.allCharacters.Count; j++)
{
Character character = this.allCharacters[j];
if (character)
{
character.inCircle = false;
if (character.resting)
{
character.resting = false;
character.GetUp();
}
character.hasCreatureBuff = false;
character.ignoreNodeIDs = false;
character.stats.HealEffect("CircleDefense");
character.timeSinceCircle = Links.x.gameplay.seconds;
if (this.aggressive && character.actions)
{
character.actions.ReturnChargeUpFX();
}
character.animator.SetBool("Hyped", false);
}
}
swarmBreak = true;
if (swarmBreak)
{
if (this.needsFadeOut)
{
this.StartCircleFade(true);
while (this.fading)
{
yield return null;
}
this.needsFadeOut = false;
}
}
else
{
this.doFade = true;
this.fade = 1f;
float timeToLerp = 1f;
float percentage = 0f;
float startTime = Time.time;
while (percentage < 1f)
{
percentage = (Time.time - startTime) / timeToLerp;
this.fade = percentage;
yield return null;
}
}
Links.x.cameraEffects.ClearEnemyGroupTiles(this);
if (this.debug)
{
for (int k = 0; k < this.spheres.Count; k++)
{
Object.Destroy(this.spheres[k]);
}
this.spheres.Clear();
}
if (this.sphere)
{
Object.Destroy(this.sphere);
}
if (Records.x.combat)
{
Links.x.combat.RemoveGroup(this);
}
this.ReturnLines(this.linenum);
Object.Destroy(this);
yield break;
}
// Token: 0x060006C0 RID: 1728 RVA: 0x00091FAC File Offset: 0x000901AC
private Character GetCharacterInCircle()
{
for (int i = 0; i < this.allCharacters.Count; i++)
{
if (this.allCharacters[i].inCircle)
{
return this.allCharacters[i];
}
}
return null;
}
// Token: 0x060006C1 RID: 1729 RVA: 0x00091FF0 File Offset: 0x000901F0
private Character GetCharacterWithBuff()
{
for (int i = 0; i < this.allCharacters.Count; i++)
{
if (this.allCharacters[i].inCircle && this.allCharacters[i].hasCreatureBuff)
{
return this.allCharacters[i];
}
}
return null;
}
// Token: 0x060006C2 RID: 1730 RVA: 0x00092048 File Offset: 0x00090248
public bool InFormationMovement(Character c)
{
int num = this.allCharacters.IndexOf(c);
return this.allCharactersFormation[num] == 1;
}
// Token: 0x060006C3 RID: 1731 RVA: 0x00092074 File Offset: 0x00090274
public GraphNode GetFormationPointInCircle(Character c, bool rotationChanged)
{
GraphNode graphNode = c.node;
if (!rotationChanged && this.InCircle(c.tr.position, true, true, c) && c.hasCreatureBuff)
{
return graphNode;
}
if (graphNode == null)
{
return null;
}
this.nodeConstraintFormation.constrainToArea = (int)graphNode.Area;
this.nodeConstraintFormation.walkable = true;
this.nodeConstraintFormation.constrainWalkability = true;
this.nodeConstraintFormation.constrainTags = false;
this.nodeConstraintFormation.checkCircleID = this.groupID;
this.nodeConstraintFormation.passID = 0;
this.nodeConstraintFormation.constrainPenalty = 0;
this.nodeConstraintFormation.checkConnections = c.ConnectionNumber();
this.nodeConstraintFormation.constrainToEnvironment = 1;
if (c.movesOnWater)
{
this.nodeConstraintFormation.constrainToEnvironment = 2;
}
this.openTiles.Clear();
for (int i = 0; i < this.circleTiles.Count; i++)
{
GraphNode graphNode2 = this.circleTiles[i];
if (this.nodeConstraintFormation.Suitable(graphNode2) && (graphNode2.ID == 0 || graphNode2.ID == c.nodeStationaryID || graphNode2.ID == c.nodeMovingID))
{
this.openTiles.Add(graphNode2);
}
}
Vector3 vector = this.frontOfCircle;
float num = float.PositiveInfinity;
if (!c.protectMe && c.stats.formationGroup >= 4 && c.stats.formationGroup <= 6)
{
vector = this.middleCircle;
}
if (c.protectMe || (c.stats.formationGroup >= 7 && c.stats.formationGroup <= 9))
{
vector = this.backOfCircle;
}
for (int j = 0; j < this.openTiles.Count; j++)
{
float sqrMagnitude = ((Vector3)this.openTiles[j].position - vector).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
graphNode = this.openTiles[j];
}
}
return graphNode;
}
// Token: 0x060006C4 RID: 1732 RVA: 0x00092270 File Offset: 0x00090470
public bool CheckCirclePositionAndMove(Character c)
{
if (this.inSwarm || this.inSwarmWait)
{
return false;
}
GraphNode graphNode = c.node;
if (c.hasCreatureBuff)
{
return false;
}
graphNode = this.GetFormationPointInCircle(c, false);
if (graphNode != null && graphNode != c.node)
{
c.ClearPathUpdates();
this.JoinCirclePath(graphNode, c);
return true;
}
return false;
}
// Token: 0x060006C5 RID: 1733 RVA: 0x000922C8 File Offset: 0x000904C8
private void ReturnLines(int l)
{
for (int i = 0; i < this.lines.Count; i++)
{
Links.x.cellar.ReturnPooledGameObject(l, this.lines[i]);
}
this.lines.Clear();
}
// Token: 0x060006C6 RID: 1734 RVA: 0x00092314 File Offset: 0x00090514
private void DrawCircle()
{
float num = 9f;
int num2 = 60;
int num3 = this.linenum;
this.linenum = 127;
if (this.morale > 33 && this.morale < 66)
{
this.linenum = 126;
}
if (this.morale <= 33)
{
this.linenum = 125;
}
if (this.linenum != num3)
{
this.ReturnLines(num3);
}
Vector3 vector = Vector3.zero;
Vector3 vector2 = Vector3.up * -1f;
Vector3 forward = Vector3.forward;
Vector3 zero = Vector3.zero;
float num4 = 0.25f;
197120;
Quaternion quaternion = Quaternion.identity;
Vector3 vector3 = this.centroid;
if (!this.useCenterLinking)
{
vector3 = (Vector3)this.centerNode.position;
}
Vector3 vector4 = vector3;
Vector3 one = Vector3.one;
int num5 = 0;
this.positions.Clear();
float num6 = 1.25f;
for (int i = 0; i < this.circleTiles.Count; i++)
{
vector = (Vector3)this.circleTiles[i].position;
this.positions.Add(vector + new Vector3(num6, 0f, num6));
this.positions.Add(vector + new Vector3(num6 * -1f, 0f, num6));
this.positions.Add(vector + new Vector3(num6, 0f, num6 * -1f));
this.positions.Add(vector + new Vector3(num6 * -1f, 0f, num6 * -1f));
}
float num7 = 6.2831855f / (float)num2;
for (int j = 0; j < num2 + 1; j++)
{
int num8 = j;
if (j == num2)
{
num8 = 0;
}
float num9 = (float)num8 * num7;
float num10 = num * Mathf.Cos(num9);
float num11 = num * Mathf.Sin(num9);
vector = vector3;
vector.x += num10;
vector.z += num11;
float num12 = 200f;
int num13 = -1;
for (int k = 0; k < this.positions.Count; k++)
{
this.positions[k].y = vector.y;
float sqrMagnitude = (this.positions[k] - vector).sqrMagnitude;
if (sqrMagnitude < num12)
{
num12 = sqrMagnitude;
num13 = k;
}
}
if (num13 > -1)
{
vector = this.positions[num13];
}
else
{
vector = Vector3.zero;
}
if (vector.x != 0f && vector.z != 0f)
{
float y = vector.y;
vector.y += 3f;
RaycastHit raycastHit;
if (Physics.Raycast(vector, vector2, out raycastHit, 8f, Links.x.floor))
{
vector.y = raycastHit.point.y + num4;
}
else
{
vector.y = y + num4;
}
if (vector4 != vector)
{
quaternion = Quaternion.LookRotation(vector4 - vector);
if (j > 0)
{
GameObject gameObject;
if (num5 < this.lines.Count)
{
gameObject = this.lines[num5];
}
else
{
gameObject = Links.x.cellar.GetPooledGameObject(this.linenum);
this.lines.Add(gameObject);
gameObject.SetActive(true);
}
gameObject.transform.position = vector;
gameObject.transform.rotation = quaternion;
num5++;
one.z = Vector3.Distance(vector4, vector);
gameObject.transform.localScale = one;
}
vector4 = vector;
}
}
}
if (num5 < this.lines.Count)
{
for (int l = num5; l < this.lines.Count; l++)
{
Links.x.cellar.ReturnPooledGameObject(this.linenum, this.lines[l]);
this.lines[l] = null;
}
this.lines.RemoveAll((GameObject item) => item == null);
}
}
// Token: 0x060006C7 RID: 1735 RVA: 0x00092798 File Offset: 0x00090998
private void PlaceStamina()
{
float num = 8f;
int num2 = 20;
Vector3 vector = Vector3.zero;
Vector3 vector2 = Vector3.up * -1f;
Vector3 forward = Vector3.forward;
Vector3 zero = Vector3.zero;
float num3 = 0.25f;
197120;
Quaternion identity = Quaternion.identity;
Vector3 vector3 = this.centroid;
if (!this.useCenterLinking)
{
vector3 = (Vector3)this.centerNode.position;
}
Vector3 vector4 = vector3;
Vector3 one = Vector3.one;
this.positions.Clear();
this.fxPositions.Clear();
for (int i = 0; i < this.linkedTiles.Count; i++)
{
int num4 = 15;
float num5 = 6.2831855f / (float)num4;
float num6 = 1.8f;
for (int j = 0; j < num4; j++)
{
float num7 = (float)j * num5;
float num8 = num6 * Mathf.Cos(num7);
float num9 = num6 * Mathf.Sin(num7);
vector = this.linkedTiles[i];
vector.x += num8;
vector.z += num9;
this.positions.Add(vector);
}
}
float num10 = 6.2831855f / (float)num2;
for (int k = 0; k < num2 + 1; k++)
{
int num11 = k;
if (k == num2)
{
num11 = 0;
}
float num7 = (float)num11 * num10;
float num8 = num * Mathf.Cos(num7);
float num9 = num * Mathf.Sin(num7);
vector = vector3;
vector.x += num8;
vector.z += num9;
float num12 = 200f;
int num13 = -1;
for (int l = 0; l < this.positions.Count; l++)
{
this.positions[l].y = vector.y;
float sqrMagnitude = (this.positions[l] - vector).sqrMagnitude;
if (sqrMagnitude < num12)
{
num12 = sqrMagnitude;
num13 = l;
}
}
if (num13 > -1)
{
vector = this.positions[num13];
}
else
{
vector = Vector3.zero;
}
if (vector.x != 0f && vector.z != 0f)
{
float y = vector.y;
vector.y += 3f;
RaycastHit raycastHit;
if (Physics.Raycast(vector, vector2, out raycastHit, 8f, Links.x.floor))
{
vector.y = raycastHit.point.y + num3;
}
else
{
vector.y = y + num3;
}
if (vector4 != vector)
{
Quaternion.LookRotation(vector4 - vector);
if (k > 0)
{
this.fxPositions.Add(vector);
}
vector4 = vector;
}
}
}
if (this.fxPositions.Count > 0)
{
int num14 = Random.Range(0, this.fxPositions.Count);
this.staminaRecover.transform.position = this.fxPositions[num14] + new Vector3(0f, 0.25f, 0f);
this.staminaRecover.SetActive(true);
}
}
// Token: 0x060006C8 RID: 1736 RVA: 0x00092AE8 File Offset: 0x00090CE8
public void CheckIfMovingInFormation(Character character, string type)
{
if (character.moving)
{
return;
}
if (Records.x.pocketPause)
{
return;
}
if (character.NodesCount() > 0)
{
return;
}
if (character.waitingForPath == 1 || character.waitingForPath == -1)
{
return;
}
if (character.blockedTime > 0f)
{
return;
}
if (character.isHit)
{
return;
}
if (character.inAction)
{
return;
}
if (!this.checkingFormation)
{
this.FormationPoints(false, character, this.savedEndPoint, type);
}
}
// Token: 0x060006C9 RID: 1737 RVA: 0x00092B60 File Offset: 0x00090D60
public bool CanEndFormation(string type, out int nearCount)
{
nearCount = 0;
bool flag = true;
bool flag2 = false;
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character && this.SubtractVectors(this.moveTo, character.tr.position).sqrMagnitude < 25f)
{
if (!this.movingTogether)
{
this.canShowLine = true;
}
flag2 = true;
break;
}
}
for (int j = 0; j < this.allCharacters.Count; j++)
{
Character character2 = this.allCharacters[j];
if (character2 && this.allCharactersFormation[j] == 1)
{
if (character2.IsSentient())
{
bool flag3 = false;
if (flag2)
{
if (type == "Swarm" && character2.hasActions && this.savedTarget)
{
float num = 0f;
float num2 = 0f;
float num3;
character2.actions.ai.GetDistances(character2, this.savedTarget, out num3, out num, out num2, false, false);
float sqrMagnitude = this.SubtractVectors(this.savedTarget.currentPosition, character2.currentPosition).sqrMagnitude;
if (sqrMagnitude <= num && sqrMagnitude >= num2 && !character2.actions.ai.CheckSight(character2.raycastPosition, this.savedTarget.currentPosition, false))
{
flag3 = true;
}
}
if (!flag3)
{
if (this.useCenterLinking)
{
if (this.LinkedToNewPoint(this.moveTo, character2))
{
flag3 = true;
}
}
else if (this.InCircle(character2.currentPosition, true, true, character2))
{
flag3 = true;
}
}
}
if (!flag3)
{
flag = false;
if (character2.moving)
{
character2.ignoreNodeIDs = true;
}
this.CheckIfMovingInFormation(character2, type);
}
else
{
nearCount++;
character2.ignoreNodeIDs = false;
this.allCharactersFormation[j] = 0;
if (character2.actions)
{
character2.actions.ai.circleMovement = false;
if (this.inSwarm)
{
if (character2.IsSentient())
{
character2.actions.ai.UpdateCircleTiles();
character2.actions.CheckIfRunningAI();
character2.ClearNodePath();
this.Attack(character2, false);
}
}
else if (this.staminaFilling)
{
this.Rest(character2);
}
}
}
}
}
else
{
nearCount++;
}
}
if (type == "Swarm")
{
if (!flag2)
{
flag = false;
}
return flag;
}
return flag;
}
// Token: 0x060006CA RID: 1738 RVA: 0x00092DF8 File Offset: 0x00090FF8
private bool Attack(Character c, bool special)
{
c.attackTime = 1f;
c.ignoreNodeIDs = true;
c.actions.ai.circleMovement = false;
if (this.savedTarget)
{
c.SetRotation(Quaternion.LookRotation(this.savedTarget.currentPosition - c.currentPosition), true, false);
c.actions.SetSelectedTarget(true, this.savedTarget, null, null);
}
if (!special)
{
if (!c.actions.ai.busy)
{
c.actions.ChooseAction();
}
return true;
}
if (!c.body.IsHit() && c.IsSentient() && !c.stats.pinned && !c.stats.pinning)
{
c.actions.SetSelectedTarget(false, null, null, null);
return c.actions.ai.SpecialAttack(true);
}
return false;
}
// Token: 0x060006CB RID: 1739 RVA: 0x00092EE0 File Offset: 0x000910E0
private void RemoveAllMovementFlags()
{
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character)
{
character.ignoreNodeIDs = false;
if (character.actions)
{
character.actions.ai.circleMovement = false;
}
}
}
}
// Token: 0x060006CC RID: 1740 RVA: 0x00092F40 File Offset: 0x00091140
public Character GetMiddleFormationCharacter()
{
this.nearCharacters.Clear();
for (int i = 0; i < this.allCharacters.Count; i++)
{
Character character = this.allCharacters[i];
if (character && character.IsSentient())
{
if (this.LinkedToNewPoint(this.moveTo, character))
{
return character;
}
this.nearCharacters.Add(character);
}
}
float num = 1000000f;
Character character2 = null;
for (int j = 0; j < this.nearCharacters.Count; j++)
{
Character character3 = this.nearCharacters[j];
float sqrMagnitude = this.SubtractVectors(character3.currentPosition, this.moveTo).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
character2 = character3;
}
}
return character2;
}
// Token: 0x060006CD RID: 1741 RVA: 0x00093003 File Offset: 0x00091203
public void FindFormationPoint(string type)
{
if (this.formationCoroutine == null && this.centerCharacter)
{
this.formationCoroutine = this.Formation(type);
base.StartCoroutine(this.formationCoroutine);
}
}
// Token: 0x060006CE RID: 1742 RVA: 0x00093034 File Offset: 0x00091234
public IEnumerator Formation(string type)
{
GraphNode endPoint = null;
GraphNode graphNode = Links.x.main.node;
if (graphNode == null)
{
graphNode = this.centerCharacter.node;
}
ConstantPath constPath = ConstantPath.ConstructFast(graphNode, Records.x.GetConstantPathRadius(9), null);
this.nodeConstraint.constrainWalkability = false;
this.nodeConstraint.walkable = true;
this.nodeConstraint.constrainPenalty = 0;
this.nodeConstraint.constrainTags = false;
this.nodeConstraint.checkCircleID = 0;
this.nodeConstraint.passID = 0;
this.nodeConstraint.passID2 = 0;
this.nodeConstraint.checkConnections = 0;
this.nodeConstraint.constrainToEnvironment = 1;
if (this.centerCharacter.ghost)
{
this.nodeConstraint.constrainToEnvironment = 0;
}
if (this.centerCharacter.movesOnWater)
{
this.nodeConstraint.constrainToEnvironment = 2;
}
this.nodeConstraint.constrainDistance = false;
this.nodeConstraint.constrainToArea = -1;
constPath.nnConstraint = this.nodeConstraint;
AstarPath.StartPath(constPath, false);
yield return base.StartCoroutine(constPath.WaitForPath());
constPath.Claim(this);
this.allNodes = constPath.allNodes;
this.nearNodes.Clear();
int x = this.allNodes.Count;
this.nodeConstraint.constrainTags = true;
if (this.centerCharacter)
{
this.nodeConstraint.passID = this.centerCharacter.nodeStationaryID;
this.nodeConstraint.passID2 = this.centerCharacter.nodeMovingID;
}
this.nodeConstraint.checkCircleID = this.groupID;
this.nodeConstraint.checkConnections = 8;
this.nodeConstraint.constrainWalkability = true;
Vector3 vector = this.centroid;
if (!this.useCenterLinking)
{
vector = Links.x.main.currentPosition;
}
Vector3 currentPosition = Links.x.main.currentPosition;
float num = 2500f;
float num2 = 225f;
bool flag = false;
bool flag2 = false;
if (type == "Swarm")
{
this.formationSwarmTries++;
num2 = 4f;
flag = true;
}
else
{
this.formationFlankTries++;
flag2 = true;
}
int count = this.dioramaCharacters.Count;
this.nearCharacters.Clear();
this.nearTargets.Clear();
for (int j = 0; j < count; j++)
{
Character character = this.dioramaCharacters[j];
if (character && !character.inactive && character.IsSentient())
{
if (character.party)
{
this.nearCharacters.Add(character);
this.nearTargets.Add(character);
}
else if (character.npc)
{
bool flag3 = false;
if (this.centerCharacter)
{
this.centerCharacter.stats.IsTargetAnEnemy(character.stats.allegiance);
}
if (character.hostility == 2 || flag3)
{
if (!character.inCircle)
{
this.nearCharacters.Add(character);
}
else if (character.group != this)
{
this.nearCharacters.Add(character);
}
}
if (flag3)
{
this.nearTargets.Add(character);
}
}
}
}
int count2 = this.nearTargets.Count;
float num3 = float.PositiveInfinity;
Character character2 = null;
for (int k = 0; k < count2; k++)
{
Character character3 = this.nearTargets[k];
float sqrMagnitude = this.SubtractVectors(character3.currentPosition, this.centroid).sqrMagnitude;
if (sqrMagnitude < num3)
{
character2 = character3;
num3 = sqrMagnitude;
}
}
if (character2 && count2 > 0)
{
int num4 = this.nearTargets.IndexOf(character2);
if (num4 > -1)
{
this.nearTargets.RemoveAt(num4);
this.nearTargets.Insert(0, character2);
}
}
float num5 = 400f;
for (int l = x - 1; l >= 0; l--)
{
graphNode = this.allNodes[l];
float num6 = this.SubtractVectors((Vector3)graphNode.position, this.centroid).sqrMagnitude;
if (num6 <= num && num6 > num2)
{
num6 = this.SubtractVectors((Vector3)graphNode.position, currentPosition).sqrMagnitude;
if (num6 < num5)
{
bool flag4 = false;
if (flag2)
{
if (graphNode.ConnectionCountCircleFree(this.groupID) >= 8)
{
flag4 = true;
}
}
else if (graphNode.ConnectionCountCircleFree(this.groupID) >= 8)
{
flag4 = true;
}
if (flag4 && this.nodeConstraint.Suitable(graphNode))
{
bool flag5 = false;
for (int m = 0; m < this.nearTargets.Count; m++)
{
if (!flag5 && !Physics.Linecast(this.nearTargets[m].torsoPosition, (Vector3)graphNode.position + new Vector3(0f, 3f, 0f), 66304))
{
flag5 = true;
}
}
if (flag5)
{
this.nearNodes.Add(graphNode);
}
}
}
}
}
constPath.Release(this, false);
x = this.nearNodes.Count;
int num7 = this.nearCharacters.Count;
int count3 = this.nearTargets.Count;
this.nearNodes2.Clear();
this.nearNodes3.Clear();
Vector3 vector2 = Vector3.zero;
float num8 = 36f;
float num9 = 144f;
if (this.movingTogether && type == "Flank")
{
num8 = 16f;
num9 = 49f;
}
if (flag2)
{
for (int n = 0; n < x; n++)
{
graphNode = this.nearNodes[n];
vector2 = (Vector3)graphNode.position;
bool flag6 = true;
for (int num10 = 0; num10 < num7; num10++)
{
if (flag6)
{
float num6 = this.SubtractVectors(vector2, this.nearCharacters[num10].currentPosition).sqrMagnitude;
if (num6 < num8)
{
flag6 = false;
}
}
}
if (flag6)
{
for (int num11 = 0; num11 < count3; num11++)
{
if (flag6)
{
float num6 = this.SubtractVectors(vector2, this.nearTargets[num11].currentPosition).sqrMagnitude;
if (num6 < num9)
{
flag6 = false;
}
}
}
if (flag6)
{
for (int num12 = 0; num12 < count3; num12++)
{
if (flag6)
{
Vector3 vector3 = Quaternion.LookRotation(vector2 - new Vector3(this.centroid.x, vector2.y, this.centroid.z)) * Vector3.forward;
Vector3 vector4 = Vector3.Normalize(this.nearTargets[num12].currentPosition - new Vector3(this.centroid.x, this.nearTargets[num12].currentPosition.y, this.centroid.z));
if (Vector3.Dot(vector3, vector4) < 0.25f)
{
flag6 = false;
}
}
}
if (flag6)
{
this.nearNodes2.Add(graphNode);
}
}
}
}
}
this.bestNodes.Clear();
if (flag2)
{
num8 = 625f;
if (this.movingTogether)
{
num8 = 324f;
}
num7 = this.nearTargets.Count;
x = this.nearNodes2.Count;
this.nearNodesTargets.Clear();
for (int num13 = 0; num13 < x; num13++)
{
graphNode = this.nearNodes2[num13];
vector2 = (Vector3)graphNode.position;
float num14 = num8;
Character character4 = null;
for (int num15 = 0; num15 < num7; num15++)
{
float num6 = this.SubtractVectors(vector2, this.nearTargets[num15].currentPosition).sqrMagnitude;
if (num6 < num14)
{
num14 = num6;
character4 = this.nearTargets[num15];
}
}
if (character4)
{
this.nearNodes3.Add(graphNode);
this.nearNodesTargets.Add(character4);
}
}
x = this.nearNodes3.Count;
this.tested.Clear();
for (int num16 = 0; num16 < x; num16++)
{
this.tested.Add(0);
}
for (int num17 = 0; num17 < 10; num17++)
{
float num14 = float.PositiveInfinity;
int num18 = -1;
for (int num19 = 0; num19 < x; num19++)
{
if (this.tested[num19] == 0)
{
graphNode = this.nearNodes3[num19];
vector2 = (Vector3)graphNode.position;
float num6 = this.SubtractVectors(vector2, this.centroid).sqrMagnitude;
if (num6 < num14)
{
num14 = num6;
num18 = num19;
}
}
}
if (num18 > -1)
{
this.tested[num18] = 1;
this.bestNodes.Add(this.nearNodes3[num18]);
this.nearNodesTargets.Add(this.nearNodesTargets[num18]);
}
}
}
if (flag)
{
num7 = this.nearTargets.Count;
x = this.nearNodes.Count;
this.nearNodesTargets.Clear();
this.tested.Clear();
for (int num20 = 0; num20 < x; num20++)
{
this.tested.Add(0);
}
Vector3 currentPosition2 = this.centroid;
for (int num21 = 0; num21 < this.allCharacters.Count; num21++)
{
if (this.allCharacters[num21].hasCreatureBuff)
{
currentPosition2 = this.allCharacters[num21].currentPosition;
}
}
for (int num22 = 0; num22 < 3; num22++)
{
for (int num23 = 0; num23 < num7; num23++)
{
Character character5 = this.nearTargets[num23];
Vector3 vector5 = character5.currentPosition + Quaternion.LookRotation(currentPosition2 - character5.currentPosition) * Vector3.forward * 2f;
if (character5.inCircle)
{
num8 = 121f;
}
else
{
num8 = 64f;
}
float num24 = num8;
int num25 = -1;
for (int num26 = 0; num26 < x; num26++)
{
if (this.tested[num26] == 0)
{
graphNode = this.nearNodes[num26];
vector2 = (Vector3)graphNode.position;
float num6 = this.SubtractVectors(vector2, vector5).sqrMagnitude;
if (num6 < num24)
{
num24 = num6;
num25 = num26;
}
}
}
if (num25 > -1)
{
this.tested[num25] = 1;
this.bestNodes.Add(this.nearNodes[num25]);
this.nearNodesTargets.Add(character5);
}
}
}
}
x = this.bestNodes.Count;
bool foundPath = false;
GraphNode g = null;
GraphNode middleNode = null;
float num27 = float.PositiveInfinity;
for (int num28 = 0; num28 < this.circleTiles.Count; num28++)
{
float num6 = ((Vector3)this.circleTiles[num28].position - this.centroid).sqrMagnitude;
if (num6 < num27)
{
num27 = num6;
middleNode = this.circleTiles[num28];
}
}
if (middleNode == null && this.centerCharacter)
{
middleNode = this.centerCharacter.node;
}
if (middleNode != null)
{
this.nodeConstraint.constrainTags = false;
this.nodeConstraint.checkCircleID = this.groupID;
this.nodeConstraint.checkConnections = 0;
int num29;
for (int i = 0; i < x; i = num29 + 1)
{
if (!foundPath)
{
g = this.bestNodes[i];
ABPath p = ABPath.ConstructFast(middleNode, g, null);
p.nnConstraint = this.nodeConstraint;
AstarPath.StartPath(p, false);
yield return base.StartCoroutine(p.WaitForPath());
p.Claim(this);
if (!p.error)
{
bool flag7 = true;
this.tempPath = p.path;
foreach (GraphNode graphNode2 in this.tempPath)
{
if (graphNode2.circle != this.groupID && graphNode2.circle > 0)
{
flag7 = false;
}
}
if (flag7)
{
endPoint = g;
this.savedTarget = this.nearNodesTargets[i];
p.Release(this, false);
foundPath = true;
break;
}
p.Release(this, false);
}
else
{
p.Release(this, false);
}
p = null;
}
num29 = i;
}
}
if (this.debugConsole)
{
string[] array = new string[17];
array[0] = this.groupID.ToString();
array[1] = " ";
array[2] = foundPath.ToString();
array[3] = " for ";
array[4] = type;
array[5] = " suitable nodes ";
array[6] = this.nearNodes.Count.ToString();
array[7] = " away from people ";
array[8] = this.nearNodes2.Count.ToString();
array[9] = " within target range ";
array[10] = this.nearNodes3.Count.ToString();
array[11] = " best nodes ";
array[12] = this.bestNodes.Count.ToString();
array[13] = " nearby targets ";
array[14] = this.nearTargets.Count.ToString();
array[15] = " saved target ";
int num30 = 16;
Character character6 = this.savedTarget;
array[num30] = ((character6 != null) ? character6.ToString() : null);
Debug.Log(string.Concat(array));
}
if (endPoint != null)
{
constPath = ConstantPath.ConstructFast(endPoint, Records.x.GetConstantPathRadius(7), null);
this.nodeConstraint.constrainTags = false;
this.nodeConstraint.checkCircleID = this.groupID;
this.nodeConstraint.passID = 0;
this.nodeConstraint.passID2 = 0;
this.nodeConstraint.checkConnections = 0;
this.nodeConstraint.constrainWalkability = false;
constPath.nnConstraint = this.nodeConstraint;
AstarPath.StartPath(constPath, false);
yield return base.StartCoroutine(constPath.WaitForPath());
constPath.Claim(this);
this.allNodes = constPath.allNodes;
this.nearNodes.Clear();
x = this.allNodes.Count;
this.nodeConstraint.constrainWalkability = true;
if (type == "Flank")
{
this.nodeConstraint.constrainTags = true;
if (this.centerCharacter)
{
this.nodeConstraint.passID = this.centerCharacter.nodeStationaryID;
this.nodeConstraint.passID2 = this.centerCharacter.nodeMovingID;
}
}
vector = (Vector3)endPoint.position;
for (int num31 = x - 1; num31 >= 0; num31--)
{
graphNode = this.allNodes[num31];
float num6 = this.SubtractVectors((Vector3)graphNode.position, vector).sqrMagnitude;
if (num6 <= 150f && this.nodeConstraint.Suitable(graphNode))
{
this.nearNodes.Add(graphNode);
}
}
constPath.Release(this, false);
this.savedEndPoint = endPoint;
this.centerNode = endPoint;
this.moveTo = (Vector3)endPoint.position;
for (int num32 = 0; num32 < this.allCharactersFormation.Count; num32++)
{
if (type == "Flank" || this.allCharacters[num32].hasCreatureBuff)
{
this.allCharactersFormation[num32] = 1;
}
else if (type == "Swarm" && !this.allCharacters[num32].hasCreatureBuff)
{
this.allCharactersFormation[num32] = -1;
}
}
if (type == "Flank")
{
this.inFormationMovement = true;
this.inSwarmWait = false;
this.timeSinceFormation = Links.x.gameplay.seconds;
}
else
{
if (!this.useCenterLinking && this.needsFadeOut)
{
this.StartCircleFade(true);
this.needsFadeOut = false;
}
this.timeSinceSwarm = Links.x.gameplay.seconds;
this.inSwarm = true;
this.inFormationWait = false;
for (int num33 = 0; num33 < this.allCharacters.Count; num33++)
{
Character character = this.allCharacters[num33];
if (character.inCircle && character.hasCreatureBuff && !this.movingTogether)
{
if (character.resting)
{
character.resting = false;
character.PlayIdle();
}
Effects effects = character.gameObject.AddComponent<Effects>();
Links.x.cellar.AddEffects(effects);
effects.gameObject.SetActive(true);
effects.source = character;
effects.target = character;
effects.sourceLevel = (float)character.stats.characterRow._Level;
effects.effectName = "CircleOffense";
effects.Inflicted(false);
}
if (character.actions)
{
character.actions.ReturnChargeUpFX();
}
}
}
float positiveInfinity = float.PositiveInfinity;
Vector3 vector6 = (Vector3)endPoint.position;
Vector3 vector7 = vector6;
float num34 = float.PositiveInfinity;
if (this.useCenterLinking)
{
for (int num35 = 0; num35 < this.linkedTiles.Count; num35++)
{
Vector3 vector8 = this.linkedTiles[num35];
float num6 = (this.linkedTiles[num35] - vector6).sqrMagnitude;
if (num6 < num34)
{
num34 = num6;
vector7 = this.linkedTiles[num35];
}
}
}
else
{
for (int num36 = 0; num36 < this.circleTiles.Count; num36++)
{
if (this.circleTiles[num36] != null)
{
float num6 = ((Vector3)this.circleTiles[num36].position - vector6).sqrMagnitude;
if (num6 < num34)
{
num34 = num6;
vector7 = (Vector3)this.circleTiles[num36].position;
}
}
}
}
for (int num37 = 0; num37 < this.allCharacters.Count; num37++)
{
Character character = this.allCharacters[num37];
if (character.inCircle)
{
float num6 = (character.currentPosition - vector7).sqrMagnitude;
if (num6 < positiveInfinity)
{
this.centerCharacter = character;
}
}
}
this.FormationPoints(true, this.centerCharacter, endPoint, type);
}
this.formationCoroutine = null;
yield break;
}
// Token: 0x060006CF RID: 1743 RVA: 0x0009304C File Offset: 0x0009124C
private void FormationPoints(bool all, Character onlyCharacter, GraphNode endPoint, string type)
{
this.checkingFormation = true;
Vector3 vector = (Vector3)this.savedEndPoint.position;
if (!this.savedTarget)
{
this.savedTarget = Links.x.main;
}
Quaternion quaternion = Quaternion.LookRotation((Vector3)this.savedEndPoint.position - this.savedTarget.currentPosition);
Vector3 vector2 = quaternion * Vector3.forward;
Vector3 vector3 = quaternion * Vector3.right;
this.move.Clear();
if (all && this.debug)
{
for (int i = 0; i < this.spheres.Count; i++)
{
this.spheres[i].SetActive(false);
this.openSpheres.Add(this.spheres[i]);
}
this.spheres.Clear();
}
for (int j = 0; j < this.allCharacters.Count; j++)
{
Character character = this.allCharacters[j];
if (character && character.IsSentient() && this.allCharactersFormation[j] != -1)
{
this.move.Add(character);
}
}
int count = this.nearNodes.Count;
int num = 9;
if (this.allCharacters.Count <= 6)
{
num = 6;
}
if (this.allCharacters.Count <= 4)
{
num = 4;
}
if (this.allCharacters.Count <= 3)
{
num = 3;
}
if (all)
{
for (int k = 0; k < this.circleTiles.Count; k++)
{
if (this.circleTiles[k].circle == this.groupID)
{
this.circleTiles[k].circle = 0;
}
}
this.circleTiles.Clear();
}
for (int l = 0; l < this.move.Count; l++)
{
if (all || onlyCharacter == this.move[l])
{
int num2 = l;
int num3 = 0;
bool flag = false;
bool flag2 = false;
if (num == 9 || num == 6)
{
if (l == 0)
{
num2 = 0;
flag = false;
flag2 = false;
}
if (l == 1)
{
num2 = 0;
flag = true;
flag2 = false;
num3 = 1;
}
if (l == 2)
{
num2 = 0;
flag = false;
flag2 = true;
num3 = 0;
}
if (l == 3)
{
num2 = 1;
flag = false;
flag2 = false;
num3 = 4;
}
if (l == 4)
{
num2 = 1;
flag = true;
flag2 = false;
num3 = 7;
}
if (l == 5)
{
num2 = 1;
flag = false;
flag2 = true;
num3 = 3;
}
if (l == 6)
{
num2 = 2;
flag = false;
flag2 = false;
num3 = 2;
}
if (l == 7)
{
num2 = 2;
flag = true;
flag2 = false;
num3 = 5;
}
if (l == 8)
{
num2 = 2;
flag = false;
flag2 = true;
num3 = 6;
}
}
else if (num == 4)
{
if (l == 0)
{
num2 = 0;
flag = false;
flag2 = false;
}
if (l == 1)
{
num2 = 0;
flag = true;
flag2 = false;
num3 = 1;
}
if (l == 2)
{
num2 = 1;
flag = false;
flag2 = false;
num3 = 0;
}
if (l == 3)
{
num2 = 1;
flag = true;
flag2 = false;
num3 = 4;
}
}
else if (num == 3)
{
if (l == 0)
{
num2 = 0;
flag = false;
flag2 = false;
}
if (l == 1)
{
num2 = 0;
flag = true;
flag2 = false;
num3 = 1;
}
if (l == 2)
{
num2 = 1;
flag = false;
flag2 = false;
num3 = 0;
}
}
GraphNode graphNode = null;
float num4 = 1f;
if (flag)
{
vector3 *= -1f;
}
if (!flag2 && !flag)
{
num4 = 0f;
}
Vector3 vector4 = vector2 * (float)num2 * -2.5f + vector3 * 2.5f * num4 + vector;
float num5 = float.PositiveInfinity;
bool flag3 = false;
if (l > 0)
{
graphNode = endPoint.GetConnectionAtIndex(num3);
if (graphNode != null)
{
flag3 = true;
}
}
if (l == 0)
{
graphNode = endPoint;
}
else if (!flag3)
{
for (int m = 0; m < count; m++)
{
GraphNode graphNode2 = this.nearNodes[m];
if (graphNode2.planningA == 0)
{
float sqrMagnitude = this.SubtractVectors((Vector3)graphNode2.position, vector4).sqrMagnitude;
if (sqrMagnitude < num5)
{
bool flag4 = false;
for (int n = 0; n < this.circleTiles.Count; n++)
{
if (this.SubtractVectors((Vector3)graphNode2.position, (Vector3)this.circleTiles[n].position).sqrMagnitude < 13.690001f)
{
flag4 = true;
}
}
if (flag4)
{
num5 = sqrMagnitude;
graphNode = graphNode2;
}
}
}
}
}
if (graphNode != null)
{
Character character2 = this.move[l];
graphNode.planningA = 1;
character2.ClearPathUpdates();
character2.ClearCurrentPathNodes();
bool flag5 = false;
if (character2.resting)
{
character2.resting = false;
character2.PlayIdle();
}
if (character2.actions)
{
character2.actions.ai.StopAI();
character2.actions.ai.circleMovement = true;
character2.actions.savedEnemy = this.savedTarget;
character2.inRecovery = false;
flag5 = character2.actions.ai.busy;
}
if (all)
{
character2.checkForLeaderPath = true;
}
if (character2.stats.animal && !this.movingTogether)
{
character2.running = true;
}
if (!flag5)
{
character2.ignoreNodeIDs = true;
character2.pathTargPosition = (Vector3)graphNode.position;
character2.MakePath(graphNode, 500, false, false, true);
character2.savedPathTarget = graphNode;
}
if (all && this.debug)
{
GameObject gameObject;
if (this.openSpheres.Count > 0)
{
gameObject = this.openSpheres[0];
this.openSpheres.RemoveAt(0);
}
else
{
gameObject = this.centerCharacter.CreateSphere((Vector3)graphNode.position, 0.25f);
}
this.spheres.Add(gameObject);
gameObject.transform.position = (Vector3)graphNode.position;
gameObject.SetActive(true);
}
}
}
}
if (all)
{
this.circleTiles.Add(endPoint);
for (int num6 = 1; num6 < 9; num6++)
{
int num7 = -1;
if (num == 9 || num == 6)
{
if (num6 == 1)
{
num7 = 1;
}
if (num6 == 2)
{
num7 = 0;
}
if (num6 == 3)
{
num7 = 4;
}
if (num6 == 4)
{
num7 = 7;
}
if (num6 == 5)
{
num7 = 3;
}
if (num6 == 6)
{
num7 = 2;
}
if (num6 == 7)
{
num7 = 5;
}
if (num6 == 8)
{
num7 = 6;
}
}
else if (num == 4)
{
if (num6 == 1)
{
num7 = 1;
}
if (num6 == 2)
{
num7 = 0;
}
if (num6 == 3)
{
num7 = 4;
}
}
else if (num == 3)
{
if (num6 == 1)
{
num7 = 1;
}
if (num6 == 2)
{
num7 = 0;
}
}
if (num7 > -1)
{
GraphNode connectionAtIndex = endPoint.GetConnectionAtIndex(num7);
if (connectionAtIndex != null && !this.circleTiles.Contains(connectionAtIndex))
{
this.circleTiles.Add(connectionAtIndex);
}
}
}
if (this.centerCharacter && this.centerCharacter.stats.isFishMonster)
{
if (!this.inSwarm && !this.inSwarmWait)
{
this.AddEffect("Acid");
}
else
{
this.RemoveEffect();
}
}
}
if (!this.movingTogether)
{
for (int num8 = 0; num8 < this.circleTiles.Count; num8++)
{
if (this.circleTiles[num8].circle == 0)
{
this.circleTiles[num8].circle = this.groupID;
}
}
}
for (int num9 = 0; num9 < count; num9++)
{
this.nearNodes[num9].planningA = 0;
}
this.checkingFormation = false;
}
// Token: 0x060006D0 RID: 1744 RVA: 0x00093804 File Offset: 0x00091A04
public bool AnyoneHasLKP()
{
bool flag = false;
foreach (Character character in this.allCharacters)
{
if (character && character.inCircle && character.hasActions && character.actions.ai.seenCount > 0)
{
flag = true;
break;
}
}
return flag;
}
// Token: 0x060006D1 RID: 1745 RVA: 0x00093884 File Offset: 0x00091A84
public float FormationSpeed(Character c)
{
return 1f;
}
// Token: 0x060006D2 RID: 1746 RVA: 0x0009388C File Offset: 0x00091A8C
public bool OutsideCircleStatus(Character c)
{
int num = this.originalCharacters.IndexOf(c);
if (num > -1)
{
float num2 = this.timeOutsideCircle[num];
return num2 == -1f || num2 > 20f;
}
return true;
}
// Token: 0x060006D3 RID: 1747 RVA: 0x000938D0 File Offset: 0x00091AD0
private void SetCircleTiles(bool removeAll)
{
if (this.useCenterLinking)
{
for (int i = 0; i < this.setTiles.Count; i++)
{
if (this.setTiles[i].circle == this.groupID)
{
this.setTiles[i].circle = 0;
}
}
this.setTiles.Clear();
if (!removeAll)
{
for (int j = 0; j < this.allCharacters.Count; j++)
{
Character character = this.allCharacters[j];
bool flag = character.hasCreatureBuff;
GraphNode node = character.node;
if (!flag)
{
int num = this.originalCharacters.IndexOf(character);
if (num > -1)
{
float num2 = this.timeOutsideCircle[num];
if (num2 > -1f && num2 < 10f)
{
flag = true;
}
}
}
if (flag && node != null)
{
if (node.circle == 0)
{
node.circle = this.groupID;
this.setTiles.Add(node);
}
if (!this.inSwarm && !this.inFormationMovement)
{
for (int k = 0; k < 8; k++)
{
if (node.ConnectionFromIndex(k) != null && node.circle == 0)
{
node.circle = this.groupID;
this.setTiles.Add(node);
}
}
}
}
}
return;
}
for (int l = 0; l < this.circleTiles.Count; l++)
{
if (this.circleTiles[l].circle == this.groupID)
{
this.circleTiles[l].circle = 0;
}
}
}
}
// Token: 0x060006D4 RID: 1748 RVA: 0x00093A6C File Offset: 0x00091C6C
public void JoinCirclePath(GraphNode n, Character c)
{
bool flag = true;
if (this.inFormationMovement || this.inSwarm)
{
int num = this.allCharacters.IndexOf(c);
if (this.allCharactersFormation[num] == 0)
{
flag = true;
}
if (c.actions && (c.actions.ai.jumping || c.actions.ai.busy))
{
flag = false;
}
}
if (!c.IsSentient() || c.waitingForPath == 1 || c.waitingForPath == -1)
{
flag = false;
}
if (flag)
{
c.ignoreNodeIDs = true;
c.running = true;
c.MakePath(n, 50, false, false, true);
}
}
// Token: 0x060006D5 RID: 1749 RVA: 0x00093B14 File Offset: 0x00091D14
public float GetRotationAngle(Quaternion r1, Quaternion r2)
{
Vector3 eulerAngles = r1.eulerAngles;
eulerAngles.x = 0f;
eulerAngles.z = 0f;
r1 = Quaternion.Euler(eulerAngles);
Vector3 eulerAngles2 = r2.eulerAngles;
eulerAngles.x = 0f;
eulerAngles.z = 0f;
r2 = Quaternion.Euler(eulerAngles2);
return Quaternion.Angle(r1, r2);
}
// Token: 0x060006D6 RID: 1750 RVA: 0x00093B78 File Offset: 0x00091D78
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: 0x060006D7 RID: 1751 RVA: 0x00093BC4 File Offset: 0x00091DC4
private bool CharacterNeedsToBeDefended(Character c)
{
return c.protectMe || c.stats.needsDefending || (c.stats.canCastSpells && c.hasActions && (c.actions.ai.rangeWeaponIndex == 0 || !c.actions.ai.canMeleeRangeAttack));
}
// Token: 0x060006D8 RID: 1752 RVA: 0x00093C24 File Offset: 0x00091E24
public void StartPulse(bool first)
{
if (!first)
{
this.startPulseDither = 1f;
this.endPulseDither = 0f;
}
else
{
this.startPulseDither = 0f;
this.endPulseDither = 1f;
}
if (this.pulsing)
{
this.pulse = this.startPulseDither;
}
this.pulseAmount = 0f;
this.pulsing = true;
}
// Token: 0x060006D9 RID: 1753 RVA: 0x00093C88 File Offset: 0x00091E88
public void StartCircleFade(bool fadeOut)
{
this.pulsing = false;
if (fadeOut)
{
this.startDither = 0f;
this.endDither = 1f;
}
else
{
this.startDither = 1f;
this.endDither = 0f;
}
this.currentDither = this.startDither;
this.fadeAmount = 0f;
this.fading = true;
}
// Token: 0x060006DA RID: 1754 RVA: 0x00093CEC File Offset: 0x00091EEC
private void AddEffect(string n)
{
if (this.effect)
{
this.effect.Remove();
}
this.effect = Links.x.tileEffects.AddComponent<TileEffects>();
this.effect.gameObject.SetActive(true);
Library.Effects effectRow = Links.x.library.GetEffectRow(n);
this.effect.fromGroup = true;
this.effect.group = this;
this.effect.Setup(null, effectRow, null, null, null, this.centerCharacter);
}
// Token: 0x060006DB RID: 1755 RVA: 0x00093D76 File Offset: 0x00091F76
private void RemoveEffect()
{
if (this.effect)
{
this.effect.Remove();
}
}
// Token: 0x0400098A RID: 2442
[Header("Info")]
public int groupID;
// Token: 0x0400098B RID: 2443
public int dangerLevel;
// Token: 0x0400098C RID: 2444
public int maxCharacters;
// Token: 0x0400098D RID: 2445
public bool circleIsActive;
// Token: 0x0400098E RID: 2446
public Vector3 center;
// Token: 0x0400098F RID: 2447
public Character centerCharacter;
// Token: 0x04000990 RID: 2448
public GraphNode centerNode;
// Token: 0x04000991 RID: 2449
public Vector3 frontOfCircle;
// Token: 0x04000992 RID: 2450
public Vector3 middleCircle;
// Token: 0x04000993 RID: 2451
public Vector3 backOfCircle;
// Token: 0x04000994 RID: 2452
public Quaternion targetRotation;
// Token: 0x04000995 RID: 2453
public bool aggressive;
// Token: 0x04000996 RID: 2454
public bool staminaFilling;
// Token: 0x04000997 RID: 2455
public bool movingTogether;
// Token: 0x04000998 RID: 2456
public bool defensive;
// Token: 0x04000999 RID: 2457
public int morale;
// Token: 0x0400099A RID: 2458
public int inCircleCount;
// Token: 0x0400099B RID: 2459
public Vector3 centroid;
// Token: 0x0400099C RID: 2460
public bool useCenterLinking;
// Token: 0x0400099D RID: 2461
public bool doFade;
// Token: 0x0400099E RID: 2462
public float pulse;
// Token: 0x0400099F RID: 2463
public float fade;
// Token: 0x040009A0 RID: 2464
public bool isBreaking;
// Token: 0x040009A1 RID: 2465
public int canBeInCircle;
// Token: 0x040009A2 RID: 2466
private List<Vector3> positions = new List<Vector3>();
// Token: 0x040009A3 RID: 2467
public List<GameObject> lines = new List<GameObject>();
// Token: 0x040009A4 RID: 2468
public int linenum;
// Token: 0x040009A5 RID: 2469
private List<Vector3> linkedTiles = new List<Vector3>();
// Token: 0x040009A6 RID: 2470
public List<Character> allCharacters = new List<Character>();
// Token: 0x040009A7 RID: 2471
public List<int> allCharactersFormation = new List<int>();
// Token: 0x040009A8 RID: 2472
public List<Character> inCircleCharacters = new List<Character>();
// Token: 0x040009A9 RID: 2473
public List<GraphNode> circleTiles = new List<GraphNode>();
// Token: 0x040009AA RID: 2474
public List<Character> originalCharacters = new List<Character>();
// Token: 0x040009AB RID: 2475
public List<float> timeOutsideCircle = new List<float>();
// Token: 0x040009AC RID: 2476
private List<Character> dioramaCharacters;
// Token: 0x040009AD RID: 2477
private List<Character> nearCharacters = new List<Character>();
// Token: 0x040009AE RID: 2478
private List<Character> nearTargets = new List<Character>();
// Token: 0x040009AF RID: 2479
private List<Character> nearNodesTargets = new List<Character>();
// Token: 0x040009B0 RID: 2480
private List<Character> intruders = new List<Character>();
// Token: 0x040009B1 RID: 2481
private List<float> intruderTime = new List<float>();
// Token: 0x040009B2 RID: 2482
private List<Character> intruderTemp = new List<Character>();
// Token: 0x040009B3 RID: 2483
private List<float> intruderTimeTemp = new List<float>();
// Token: 0x040009B4 RID: 2484
private List<Vector3> fxPositions = new List<Vector3>();
// Token: 0x040009B5 RID: 2485
private NNConstraint nodeConstraintFormation = new NNConstraint();
// Token: 0x040009B6 RID: 2486
private List<GraphNode> openTiles = new List<GraphNode>();
// Token: 0x040009B7 RID: 2487
private GraphNode savedEndPoint;
// Token: 0x040009B8 RID: 2488
private List<Character> move = new List<Character>();
// Token: 0x040009B9 RID: 2489
private NNConstraint nodeConstraint = new NNConstraint();
// Token: 0x040009BA RID: 2490
private List<GameObject> spheres = new List<GameObject>();
// Token: 0x040009BB RID: 2491
private List<GameObject> openSpheres = new List<GameObject>();
// Token: 0x040009BC RID: 2492
public IEnumerator formationCoroutine;
// Token: 0x040009BD RID: 2493
private List<GraphNode> allNodes;
// Token: 0x040009BE RID: 2494
private List<GraphNode> nearNodes = new List<GraphNode>();
// Token: 0x040009BF RID: 2495
private List<GraphNode> nearNodes2 = new List<GraphNode>();
// Token: 0x040009C0 RID: 2496
private List<GraphNode> nearNodes3 = new List<GraphNode>();
// Token: 0x040009C1 RID: 2497
private List<GraphNode> bestNodes = new List<GraphNode>();
// Token: 0x040009C2 RID: 2498
private List<GraphNode> setTiles = new List<GraphNode>();
// Token: 0x040009C3 RID: 2499
private List<GraphNode> tempPath;
// Token: 0x040009C4 RID: 2500
private List<int> tested = new List<int>();
// Token: 0x040009C5 RID: 2501
private bool debug;
// Token: 0x040009C6 RID: 2502
private bool debugConsole;
// Token: 0x040009C7 RID: 2503
private GameObject sphere;
// Token: 0x040009C8 RID: 2504
public bool inFormationMovement;
// Token: 0x040009C9 RID: 2505
public bool inSwarm;
// Token: 0x040009CA RID: 2506
public bool inFormationWait;
// Token: 0x040009CB RID: 2507
public bool inSwarmWait;
// Token: 0x040009CC RID: 2508
public float timeSinceFormation;
// Token: 0x040009CD RID: 2509
public float timeSinceSwarm;
// Token: 0x040009CE RID: 2510
public float timeSinceGather;
// Token: 0x040009CF RID: 2511
public float timeSinceFormationWait;
// Token: 0x040009D0 RID: 2512
public float timeSinceSwarmWait;
// Token: 0x040009D1 RID: 2513
private Vector3 moveTo;
// Token: 0x040009D2 RID: 2514
public bool canShowLine;
// Token: 0x040009D3 RID: 2515
public bool checkingFormation;
// Token: 0x040009D4 RID: 2516
public bool needsFade;
// Token: 0x040009D5 RID: 2517
public bool needsFadeOut;
// Token: 0x040009D6 RID: 2518
private Character savedTarget;
// Token: 0x040009D7 RID: 2519
public float currentDither;
// Token: 0x040009D8 RID: 2520
private float startDither;
// Token: 0x040009D9 RID: 2521
private float endDither;
// Token: 0x040009DA RID: 2522
private float fadeAmount;
// Token: 0x040009DB RID: 2523
private float staminaRecoverTime;
// Token: 0x040009DC RID: 2524
private float staminaFillTime;
// Token: 0x040009DD RID: 2525
public bool fading;
// Token: 0x040009DE RID: 2526
private GameObject staminaRecover;
// Token: 0x040009DF RID: 2527
private float startPulseDither;
// Token: 0x040009E0 RID: 2528
private float endPulseDither;
// Token: 0x040009E1 RID: 2529
private float pulseAmount;
// Token: 0x040009E2 RID: 2530
public bool pulsing;
// Token: 0x040009E3 RID: 2531
private float updateTime;
// Token: 0x040009E4 RID: 2532
private float checkDirectionTime;
// Token: 0x040009E5 RID: 2533
private int formationFlankTries;
// Token: 0x040009E6 RID: 2534
private int formationSwarmTries;
// Token: 0x040009E7 RID: 2535
private TileEffects effect;
}