/// <summary> /// Whether a player has a mission that has the provided id as mission id. /// </summary> /// <param name="id">The id of the mission to find in the mission inventory</param> /// <returns><c>true</c> if the player has a mission with the given id, <c>false</c> otherwise</returns> public bool HasMission(int id) { lock (Missions) { return(Missions.Any(m => m.MissionId == id)); } }
/// <summary> /// Whether a player has completed a mission that has the provided id as mission id. /// </summary> /// <param name="id">The id of the mission to find in the mission inventory</param> /// <returns><c>true</c> if the player has a completed mission with the given id, <c>false</c> otherwise</returns> public bool HasCompleted(int id) { lock (Missions) { return(Missions.Any(m => m.MissionId == id && m.State >= MissionState.Completed)); } }
public override void AddExtraMissions(LevelData levelData) { extraMissions.Clear(); var currentLocation = Map.CurrentLocation; if (levelData.Type == LevelData.LevelType.Outpost) { //if there's an available mission that takes place in the outpost, select it var availableMissionsInLocation = currentLocation.AvailableMissions.Where(m => m.Locations[0] == currentLocation && m.Locations[1] == currentLocation); if (availableMissionsInLocation.Any()) { currentLocation.SelectedMission = availableMissionsInLocation.FirstOrDefault(); } else { currentLocation.SelectedMission = null; } } else { //if we had selected a mission that takes place in the outpost, deselect it when leaving the outpost if (currentLocation.SelectedMission?.Locations[0] == currentLocation && currentLocation.SelectedMission?.Locations[1] == currentLocation) { currentLocation.SelectedMission = null; } if (levelData.HasBeaconStation && !levelData.IsBeaconActive) { var beaconMissionPrefabs = MissionPrefab.List.FindAll(m => m.Tags.Any(t => t.Equals("beaconnoreward", StringComparison.OrdinalIgnoreCase))); if (beaconMissionPrefabs.Any()) { Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed)); var beaconMissionPrefab = beaconMissionPrefabs.GetRandom(rand); if (!Missions.Any(m => m.Prefab.Type == beaconMissionPrefab.Type)) { extraMissions.Add(beaconMissionPrefab.Instantiate(Map.SelectedConnection.Locations)); } } } if (levelData.HasHuntingGrounds) { var huntingGroundsMissionPrefabs = MissionPrefab.List.FindAll(m => m.Tags.Any(t => t.Equals("huntinggroundsnoreward", StringComparison.OrdinalIgnoreCase))); if (!huntingGroundsMissionPrefabs.Any()) { DebugConsole.AddWarning("Could not find a hunting grounds mission for the level. No mission with the tag \"huntinggroundsnoreward\" found."); } else { Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed)); var huntingGroundsMissionPrefab = huntingGroundsMissionPrefabs.GetRandom(rand); if (!Missions.Any(m => m.Prefab.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase)))) { extraMissions.Add(huntingGroundsMissionPrefab.Instantiate(Map.SelectedConnection.Locations)); } } } } }
public override void AddExtraMissions(LevelData levelData) { extraMissions.Clear(); var currentLocation = Map.CurrentLocation; if (levelData.Type == LevelData.LevelType.Outpost) { //if there's an available mission that takes place in the outpost, select it foreach (var availableMission in currentLocation.AvailableMissions) { if (availableMission.Locations[0] == currentLocation && availableMission.Locations[1] == currentLocation) { currentLocation.SelectMission(availableMission); } } } else { foreach (Mission mission in currentLocation.SelectedMissions.ToList()) { //if we had selected a mission that takes place in the outpost, deselect it when leaving the outpost if (mission.Locations[0] == currentLocation && mission.Locations[1] == currentLocation) { currentLocation.DeselectMission(mission); } } if (levelData.HasBeaconStation && !levelData.IsBeaconActive) { var beaconMissionPrefabs = MissionPrefab.List.FindAll(m => m.Tags.Any(t => t.Equals("beaconnoreward", StringComparison.OrdinalIgnoreCase))); if (beaconMissionPrefabs.Any()) { Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed)); var beaconMissionPrefab = ToolBox.SelectWeightedRandom(beaconMissionPrefabs, beaconMissionPrefabs.Select(p => (float)p.Commonness).ToList(), rand); if (!Missions.Any(m => m.Prefab.Type == beaconMissionPrefab.Type)) { extraMissions.Add(beaconMissionPrefab.Instantiate(Map.SelectedConnection.Locations, Submarine.MainSub)); } } } if (levelData.HasHuntingGrounds) { var huntingGroundsMissionPrefabs = MissionPrefab.List.FindAll(m => m.Tags.Any(t => t.Equals("huntinggroundsnoreward", StringComparison.OrdinalIgnoreCase))); if (!huntingGroundsMissionPrefabs.Any()) { DebugConsole.AddWarning("Could not find a hunting grounds mission for the level. No mission with the tag \"huntinggroundsnoreward\" found."); } else { Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed)); var huntingGroundsMissionPrefab = ToolBox.SelectWeightedRandom(huntingGroundsMissionPrefabs, huntingGroundsMissionPrefabs.Select(p => (float)Math.Max(p.Commonness, 0.1f)).ToList(), rand); if (!Missions.Any(m => m.Prefab.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase)))) { extraMissions.Add(huntingGroundsMissionPrefab.Instantiate(Map.SelectedConnection.Locations, Submarine.MainSub)); } } } } }