public void GetCurrentData() { foreach (MobileParty mb in MobileParty.All) { if (mb == null) { return; } foreach (var dat in dataManager.Data) { if (CampaignUtils.IsolateMobilePartyStringID(mb) == dat.PartyTemplate.StringId) //TODO could deal with sub parties in the future as well! { //this be a custom spawns party :O DynamicSpawnData.AddDynamicSpawnData(mb, new CSPartyData(dat, null)); dat.IncrementNumberSpawned(); UpdateDynamicData(mb); UpdateRedundantDynamicData(mb); } } } }
private void RegularSpawn() { try { var list = dataManager.Data; Random rand = new Random(); var isSpawnSoundPlaying = false; foreach (Data.SpawnData data in list) { int j = 0; for (int i = 0; i < data.RepeatSpawnRolls; i++) { if (data.CanSpawn() && (data.MinimumNumberOfDaysUntilSpawn < (int)Math.Ceiling(Campaign.Current.CampaignStartTime.ElapsedDaysUntilNow))) { if (CsSettings.IsAllSpawnMode || (float)rand.NextDouble() < data.ChanceOfSpawn) { var spawnSettlement = Spawner.GetSpawnSettlement(data, rand); //spawn nao! MobileParty spawnedParty = Spawner.SpawnParty(spawnSettlement, data.SpawnClan, data.PartyTemplate, data.PartyType, new TextObject(data.Name), data.PartyTemplatePrisoner, data.InheritClanFromSettlement); data.IncrementNumberSpawned(); //increment for can spawn and chance modifications //dynamic data registration DynamicSpawnData.AddDynamicSpawnData(spawnedParty, new CSPartyData(data, spawnSettlement)); j++; //AI Checks! Spawner.HandleAIChecks(spawnedParty, data, spawnSettlement); //accompanying spawns foreach (var accomp in data.SpawnAlongWith) { MobileParty juniorParty = Spawner.SpawnParty(spawnSettlement, data.SpawnClan, accomp.templateObject, data.PartyType, new TextObject(accomp.name), data.PartyTemplatePrisoner, data.InheritClanFromSettlement); Spawner.HandleAIChecks(juniorParty, data, spawnSettlement); //junior party has same AI behaviour as main party. TODO in future add some junior party AI and reconstruction. } //message if available if (data.spawnMessage != null && data.inquiryMessage == null) { UX.ShowParseSpawnMessage(data.spawnMessage, spawnSettlement.Name.ToString()); if (data.SoundEvent != -1 && !isSpawnSoundPlaying && CsSettings.SpawnSoundEnabled) { var sceneEmpty = Scene.CreateNewScene(false); SoundEvent sound = SoundEvent.CreateEvent(data.SoundEvent, sceneEmpty); sound.Play(); isSpawnSoundPlaying = true; } } //default spawn message type always takes priority over the inquiry type if they're both present else if (data.spawnMessage != null && data.inquiryMessage != null) { UX.ShowParseSpawnMessage(data.spawnMessage, spawnSettlement.Name.ToString()); } //only if the spawn message EXPLICITLY doesn't exist does it choose the inquiry message else if (data.spawnMessage == null && data.inquiryMessage != null) { UX.ShowParseSpawnInquiryMessage(data.inquiryMessage, spawnSettlement.Name.ToString(), data.inquiryPause); } } } else { break; } } } } catch (Exception e) { ErrorHandler.HandleException(e); } }
private void RegularSpawn() { try { var list = dataManager.Data; Random rand = new Random(); var isSpawnSoundPlaying = false; foreach (Data.SpawnData data in list) { int j = 0; for (int i = 0; i < data.RepeatSpawnRolls; i++) { if (data.CanSpawn() && (data.MinimumNumberOfDaysUntilSpawn < (int)Math.Ceiling(Campaign.Current.CampaignStartTime.ElapsedDaysUntilNow))) { float currentChanceOfSpawn = data.ChanceOfSpawn; if (!ConfigLoader.Instance.Config.IsAllSpawnMode && (float)rand.NextDouble() >= currentChanceOfSpawn * ConfigLoader.Instance.Config.SpawnChanceFlatMultiplier) { continue; } var spawnSettlement = Spawner.GetSpawnSettlement(data, (s => data.MinimumDevestationToSpawn > DevestationMetricData.Singleton.GetDevestation(s)), rand); //spawn nao! if (spawnSettlement == null) { //no valid spawn settlement break; } MobileParty spawnedParty = Spawner.SpawnParty(spawnSettlement, data.SpawnClan, data.PartyTemplate, data.PartyType, new TextObject(data.Name)); if (spawnedParty == null) { return; } data.IncrementNumberSpawned(); //increment for can spawn and chance modifications //dynamic data registration DynamicSpawnData.AddDynamicSpawnData(spawnedParty, new CSPartyData(data, spawnSettlement)); j++; //AI Checks! Spawner.HandleAIChecks(spawnedParty, data, spawnSettlement); //accompanying spawns foreach (var accomp in data.SpawnAlongWith) { MobileParty juniorParty = Spawner.SpawnParty(spawnSettlement, data.SpawnClan, accomp.templateObject, data.PartyType, new TextObject(accomp.name)); if (juniorParty == null) { continue; } Spawner.HandleAIChecks(juniorParty, data, spawnSettlement); //junior party has same AI behaviour as main party. TODO in future add some junior party AI and reconstruction. } //message if available if (data.spawnMessage != null) { UX.ShowParseSpawnMessage(data.spawnMessage, spawnSettlement.Name.ToString()); //if (data.SoundEvent != -1 && !isSpawnSoundPlaying && ConfigLoader.Instance.Config.SpawnSoundEnabled) //{ // var sceneEmpty = Scene.CreateNewScene(false); // SoundEvent sound = SoundEvent.CreateEvent(data.SoundEvent, sceneEmpty); // sound.Play(); // isSpawnSoundPlaying = true; //} } DailyLogger.ReportSpawn(spawnedParty, currentChanceOfSpawn); } else { break; } } } } catch (Exception e) { ErrorHandler.HandleException(e); } }