public static PlayerState GetStateWithItems(Randomiser world, List <Item> currentItems) { PlayerState state = new PlayerState(world); if (currentItems != null) { foreach (var item in currentItems) { state.CollectItem(item); } } List <Location> requiredLocations = world.GetPlacedRequiredItemLocations(); List <Location> reachableLocations; do { reachableLocations = state.GetReachableLocations(requiredLocations); foreach (var location in reachableLocations) { state.CollectItem(location.item); state.collectedLocations.Add(location.name, true); } state.ResetCheckedAreasAndEntrances(); } while (reachableLocations.Count > 0); return(state); }