public static void Move(AOIEntity aoiEntity, Cell newCell, Cell preCell) { aoiEntity.Cell = newCell; preCell.Remove(aoiEntity); newCell.Add(aoiEntity); // 通知订阅该newCell Enter的Unit foreach (KeyValuePair <long, AOIEntity> kv in newCell.SubsEnterEntities) { if (kv.Value.SubEnterCells.Contains(preCell.Id)) { continue; } kv.Value.EnterSight(aoiEntity); } // 通知订阅preCell leave的Unit foreach (KeyValuePair <long, AOIEntity> kv in preCell.SubsLeaveEntities) { // 如果新的cell仍然在对方订阅的subleave中 if (kv.Value.SubLeaveCells.Contains(newCell.Id)) { continue; } kv.Value.LeaveSight(aoiEntity); } }