AutoMiner Token 0x0600236D RID 9069 RVA 0x000C0224 File Offset 0x000BE424private void RefreshDiggableCell CellOffset rotatedCellOffset = thisvision_offset; if thisrotatable rotatedCellOffset = thisr
// 自动挖掘机 // 令牌:0x0600236D RID: 9069 RVA: 0x000C0224 File Offset: 0x000BE424 private void RefreshDiggableCell() { // 获取视野偏移量 CellOffset rotatedCellOffset = this.vision_offset; if (this.rotatable) { rotatedCellOffset = this.rotatable.GetRotatedCellOffset(this.vision_offset); }
// 获取当前位置和偏移后的位置
int cell = Grid.PosToCell(base.transform.gameObject);
int cell2 = Grid.OffsetCell(cell, rotatedCellOffset);
int num;
int num2;
Grid.CellToXY(cell2, out num, out num2);
float num3 = float.MaxValue;
int num4 = Grid.InvalidCell;
Vector3 a = Grid.CellToPos(cell2);
bool flag = false;
// 遍历所有的挖掘区域
for (int i = 0; i < this.height; i++)
{
for (int j = 0; j < this.width; j++)
{
// 获取偏移量
CellOffset rotatedCellOffset2 = new CellOffset(this.x + j, this.y + i);
if (this.rotatable)
{
rotatedCellOffset2 = this.rotatable.GetRotatedCellOffset(rotatedCellOffset2);
}
// 获取当前位置
int num5 = Grid.OffsetCell(cell, rotatedCellOffset2);
if (Grid.IsValidCell(num5))
{
int x;
int y;
Grid.CellToXY(num5, out x, out y);
// 判断是否为有效的挖掘区域并且有通视
if (Grid.IsValidCell(num5) && AutoMiner.ValidDigCell(num5) && Grid.TestLineOfSight(num, num2, x, y, new Func<int, bool>(AutoMiner.DigBlockingCB), false, false))
{
// 如果当前位置为目标位置,则标记找到了该位置
if (num5 == this.dig_cell)
{
flag = true;
}
// 计算距离,找到距离最近的目标位置
Vector3 b = Grid.CellToPos(num5);
float num6 = Vector3.Distance(a, b);
if (num6 < num3)
{
num3 = num6;
num4 = num5;
}
}
}
}
}
// 如果找到了新的目标位置,则标记为未完成旋转
if (!flag && this.dig_cell != num4)
{
this.dig_cell = num4;
this.rotation_complete = false;
}
原文地址: https://www.cveoy.top/t/topic/hpDC 著作权归作者所有。请勿转载和采集!