public override void Update() { cell = Grid.InvalidCell; int num = 2147483647; ListPool <int, MingleCellSensor> .PooledList pooledList = ListPool <int, MingleCellSensor> .Allocate(); int num2 = 50; foreach (int mingleCell in Game.Instance.mingleCellTracker.mingleCells) { if (brain.IsCellClear(mingleCell)) { int navigationCost = navigator.GetNavigationCost(mingleCell); if (navigationCost != -1) { if (mingleCell == Grid.InvalidCell || navigationCost < num) { cell = mingleCell; num = navigationCost; } if (navigationCost < num2) { pooledList.Add(mingleCell); } } } } if (pooledList.Count > 0) { cell = pooledList[Random.Range(0, pooledList.Count)]; } pooledList.Recycle(); }
public static SafeFlags GetFlags(int cell, MinionBrain brain, bool avoid_light = false) { int num = Grid.CellAbove(cell); if (!Grid.IsValidCell(num)) { return((SafeFlags)0); } if (Grid.Solid[cell] || Grid.Solid[num]) { return((SafeFlags)0); } if (Grid.IsTileUnderConstruction[cell] || Grid.IsTileUnderConstruction[num]) { return((SafeFlags)0); } bool flag = brain.IsCellClear(cell); bool flag2 = !Grid.Element[cell].IsLiquid; bool flag3 = !Grid.Element[num].IsLiquid; bool flag4 = Grid.Temperature[cell] > 285.15f && Grid.Temperature[cell] < 303.15f; bool flag5 = brain.OxygenBreather.IsBreathableElementAtCell(cell, Grid.DefaultOffset); bool flag6 = !brain.Navigator.NavGrid.NavTable.IsValid(cell, NavType.Ladder) && !brain.Navigator.NavGrid.NavTable.IsValid(cell, NavType.Pole); bool flag7 = !brain.Navigator.NavGrid.NavTable.IsValid(cell, NavType.Tube); bool flag8 = !avoid_light || SleepChore.IsLightLevelOk(cell); if (cell == Grid.PosToCell(brain)) { flag5 = !brain.OxygenBreather.IsSuffocating; } SafeFlags safeFlags = (SafeFlags)0; if (flag) { safeFlags |= SafeFlags.IsClear; } if (flag4) { safeFlags |= SafeFlags.CorrectTemperature; } if (flag5) { safeFlags |= SafeFlags.IsBreathable; } if (flag6) { safeFlags |= SafeFlags.IsNotLadder; } if (flag7) { safeFlags |= SafeFlags.IsNotTube; } if (flag2) { safeFlags |= SafeFlags.IsNotLiquid; } if (flag3) { safeFlags |= SafeFlags.IsNotLiquidOnMyFace; } if (flag8) { safeFlags |= SafeFlags.IsLightOk; } return(safeFlags); }