public override void OnBeforeSave() { if (Game.Current == null || !(Game.Current.GameType is Campaign)) { return; } //CampaignTime deltaTime = CampaignTime.Now - TimeSinceLastSave; CampaignTime deltaTime = GetDeltaTime(true); //double yearsElapsed = deltaTime.ToYears; //TimeSinceLastSave = CampaignTime.Now; foreach (Hero hero in Game.Current.ObjectManager.GetObjectTypeList <Hero>()) { //TODO:: Why is this conflicting now??? /*ddouble newAge = hero.Age + yearsElapsed; * DynamicBodyProperties dynamicBodyProperties = new DynamicBodyProperties((float)newAge, hero.Weight, hero.Build);*/ DynamicBodyProperties dynamicBodyProperties = new DynamicBodyProperties(hero.Age, hero.Weight, hero.Build); BodyProperties heroBodyProperties = new BodyProperties(dynamicBodyProperties, hero.BodyProperties.StaticProperties); //BodyProperties heroBodyProperties = hero.BodyProperties; //CharacterBodyManager.CopyDynamicBodyProperties(dynamicBodyProperties, heroBodyProperties.DynamicProperties); hero.CharacterObject.UpdatePlayerCharacterBodyProperties(heroBodyProperties, hero.IsFemale); if (hero.IsHumanPlayerCharacter && DCCSettings.Instance != null && DCCSettings.Instance.DebugMode) { InformationManager.DisplayMessage(new InformationMessage(GetFormattedAgeDebugMessage(hero, hero.Age), ColorManager.Red)); } } }
static bool Prefix(PregnancyCampaignBehavior __instance, Hero mother) { if (mother.IsFemale && mother.Age > 18 && (Hero.MainHero.ExSpouses.Contains(mother) || mother == Hero.MainHero.Spouse)) { CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = __instance.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(__instance); object[] parameters = new object[3] { mother, Hero.MainHero, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } return(false); } return(true); }
private bool CheckTimeElapsedMoreThanHours(CampaignTime eventBeginTime, float hoursToWait) { float elapsedHoursUntilNow = eventBeginTime.ElapsedHoursUntilNow; float randomNumber = PlayerCaptivity.RandomNumber; return(hoursToWait * (0.5 + randomNumber) < elapsedHoursUntilNow); }
private static Hero DealNPC(CharacterObject target, CampaignGameStarter campaignGameStarter) { Hero hero = null; if (null != target) { CharacterObject character = CharacterObject.OneToOneConversationCharacter; hero = HeroCreator.CreateSpecialHero(character, null, Clan.PlayerClan, Clan.PlayerClan); // hero.StringId = "sms_npc_" + System.Enum.GetName(typeof(Occupation), character.Occupation) + hero.StringId; hero.ChangeState(Hero.CharacterStates.Active); hero.CacheLastSeenInformation(hero.HomeSettlement, true); hero.SyncLastSeenInformation(); HeroInitPropertyUtils.InitHeroForNPC(hero); AddHeroToPartyAction.Apply(hero, MobileParty.MainParty, true); CampaignEventDispatcher.Instance.OnHeroCreated(hero, false); ConversationUtils.ChangeCurrentCharaObject(campaignGameStarter, hero); if (hero.Age > 30) { CampaignTime newBirthDay = HeroHelper.GetRandomBirthDayForAge((float)22); hero.SetBirthDay(newBirthDay); } } return(hero); }
private void ExtendDeadline() { if (Campaign.Current != null && Campaign.Current.QuestManager != null) { foreach (QuestBase questBase in Campaign.Current.QuestManager.Quests) { bool flag2 = questBase.GetName().ToString().StartsWith("stop_conspiracy_") && questBase.QuestDueTime < CampaignTime.DaysFromNow(5f); if (flag2) { DebugHelpers.ColorGreenMessage("Extending Stop the Conspiracy quest by 1 year."); questBase.ChangeQuestDueTime(CampaignTime.YearsFromNow(1f)); DebugHelpers.ColorGreenMessage("New quest deadline: " + questBase.QuestDueTime.ToString()); } bool flag3 = questBase.StringId.StartsWith("conspiracy_quest_") && questBase.QuestDueTime < CampaignTime.DaysFromNow(7f); if (flag3) { questBase.ChangeQuestDueTime(CampaignTime.WeeksFromNow(3f)); DebugHelpers.ColorGreenMessage("BT Extend Conspiracy Tweak: Extended conspiracy quest."); float cStrngth = SecondPhase.Instance.ConspiracyStrength; if (cStrngth > 1000 && cStrngth > 250) { SecondPhase.Instance.DecreaseConspiracyStrength(150); DebugHelpers.ColorGreenMessage("BT Extend Conspiracy Tweak: Reduced conspiracy strength."); } } } } }
public static void wait_menu_settlement_wait_on_tick(MenuCallbackArgs args, CampaignTime dt) { int captiveTimeInDays = PlayerCaptivity.CaptiveTimeInDays; if (captiveTimeInDays == 0) { return; } TextObject variable = null; if (Hero.MainHero.IsPrisoner && Hero.MainHero.PartyBelongedToAsPrisoner.Settlement != null) { variable = Hero.MainHero.PartyBelongedToAsPrisoner.Settlement.Name; } if (variable == null) { variable = Settlement.CurrentSettlement.Name; } TextObject text = args.MenuContext.GameMenu.GetText(); TextObject textObject = GameTexts.FindText("str_prisoner_of_settlement_for_days_menu_text", null); textObject.SetTextVariable("NUMBER_OF_DAYS", captiveTimeInDays); textObject.SetTextVariable("PLURAL", (captiveTimeInDays > 1) ? 1 : 0); textObject.SetTextVariable("SETTLEMENT_NAME", variable); text.SetTextVariable("CAPTIVITY_TEXT", textObject); }
protected SaveIdTypeMissingQuest(string questId, Hero questGiver, CampaignTime duration, int rewardGold, string saveId) : base(questId, questGiver, duration, rewardGold) { var msg = FormattableString.Invariant($"Missing SaveId {saveId} for Quest: {questId}."); Title = new TextObject($"<{msg}>"); }
private void DoTellStories(ToldStoriesTo village) { if (village._battleStoriesTold < _notableBattlesWon) { float _renownToGive = CalculateRenownToGive(); GainRenownAction.Apply(Hero.MainHero, _renownToGive, true); InformationManager.DisplayMessage(new InformationMessage("You told the villagers a story about a notable battle, gained " + _renownToGive + " renown.")); village._daysToResetStories = CampaignTime.DaysFromNow(RandomizeDays()); village._hasToldStories = true; village._battleStoriesTold++; Hero.MainHero.AddSkillXp(DefaultSkills.Charm, MBRandom.RandomInt(1, 3)); if (_renownToGive >= 0.9) { if (Settlement.CurrentSettlement.Notables.Count >= 1) { InformationManager.DisplayMessage(new InformationMessage("Notable people in village were impressed by your feats and like you more.")); foreach (Hero notablePerson in Settlement.CurrentSettlement.Notables) { ChangeRelationAction.ApplyPlayerRelation(notablePerson, +1, false, true); } } } } else { InformationManager.DisplayMessage(new InformationMessage("You do not have new stories to tell to these villagers.")); } }
/// <summary> /// Show an text popup listing Hero current loans. /// </summary> private void ShowLoans() { string text = ""; foreach (var loan in BankAccount.Loans) { text += $"~ Loan took on {CampaignTime.Days(loan.Date)} for <b>{loan.Amount}</b><img src=\"Icons\\Coin@2x\">\n"; text += (loan.Remaining == loan.Total) ? $"Daily payments will start on {CampaignTime.Days(loan.PaymentsStartDate)}\n" : $"Daily payments started on {CampaignTime.Days(loan.PaymentsStartDate)}\n"; text += $"Daily payments will end on {CampaignTime.Days(loan.PaymentsEndDate)}\n"; text += $"Daily payments: <b>{loan.Payments * -1}</b><img src=\"Icons\\Coin@2x\">\n"; text += $"Remaining to pay: <b>{loan.Remaining}</b><img src=\"Icons\\Coin@2x\">\n"; text += $" \n"; text += $" \n"; } InformationManager.ShowInquiry(new InquiryData( titleText: $"Your current loans.", text: text, isAffirmativeOptionShown: true, isNegativeOptionShown: false, affirmativeText: "Ok", negativeText: "Back", affirmativeAction: new Action(() => { }), negativeAction: new Action(() => { }) ), true); }
public static void GetPregnancyForHero(Hero father, Hero mother) { MakePregnantAction.Apply(mother); PregnancyCampaignBehavior pregnancyCampaignBehavior = Campaign.Current.GetCampaignBehavior <PregnancyCampaignBehavior>(); CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = pregnancyCampaignBehavior.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(pregnancyCampaignBehavior); object[] parameters = new object[3] { mother, father, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } }
private void _maintainPrePregnanciesInfo() { List <Hero> heroList = new List <Hero>(); using (Dictionary <Hero, PregnancyControlBehavior.PrePregnancyInfo> .Enumerator enumerator = this.m_prePregnancyInfoMap.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <Hero, PregnancyControlBehavior.PrePregnancyInfo> current = enumerator.Current; if (!current.Key.IsDead && current.Key.IsPregnant == false) { CampaignTime pregnantDate = current.Value.m_pregnantDate; } else { heroList.Add(current.Key); } } } using (List <Hero> .Enumerator enumerator = heroList.GetEnumerator()) { while (enumerator.MoveNext()) { Hero current = enumerator.Current; this.m_prePregnancyInfoMap.Remove(current); Utillty.DebugDisplayMessage("_checkAddNewPregnancies Remove! Mother : " + ((object)current.Name).ToString()); } } }
public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject textObject, bool forcePlayerCharacterCosts = false) { textObject = null; IEnumerable <LogEntry> gameActionLogs = Campaign.Current.LogEntryHistory.GameActionLogs; CampaignTime lastPeaceTime = CampaignTime.Never; foreach (LogEntry logEntry in gameActionLogs) { if (logEntry is MakePeaceLogEntry && ((((MakePeaceLogEntry)logEntry).Faction1 == kingdom.MapFaction && ((MakePeaceLogEntry)logEntry).Faction2 == otherKingdom.MapFaction) || (((MakePeaceLogEntry)logEntry).Faction1 == otherKingdom.MapFaction && ((MakePeaceLogEntry)logEntry).Faction2 == kingdom.MapFaction))) { lastPeaceTime = logEntry.GameTime; break; } } double daysSinceLastWar = CampaignTime.Now.ToDays - lastPeaceTime.ToDays; bool hasEnoughTimeElapsed = lastPeaceTime == CampaignTime.Never || daysSinceLastWar > MinimumTimeFromLastWar; if (!hasEnoughTimeElapsed) { textObject = new TextObject(TOO_SOON); textObject.SetTextVariable("ELAPSED_DAYS", (int)daysSinceLastWar); textObject.SetTextVariable("REQUIRED_DAYS", (int)MinimumTimeFromLastWar); } return(hasEnoughTimeElapsed); }
static void Postfix(ref AgingCampaignBehavior __instance, Hero current) { if (!current.IsTemplate && current.IsAlive) { if ((int)current.BirthDay.ElapsedDaysUntilNow == (int)CampaignTime.Years((float)Campaign.Current.Models.AgeModel.HeroComesOfAge).ToDays) { if (current.HeroState != Hero.CharacterStates.Active) { CampaignEventDispatcher dispatcher = GameComponent.CampaignEventDispatcher(); if (null != dispatcher) { ReflectUtils.ReflectMethodAndInvoke("OnHeroComesOfAge", dispatcher, new Object[] { current }); } } } else if ((int)current.BirthDay.ElapsedDaysUntilNow == (int)CampaignTime.Years((float)Campaign.Current.Models.AgeModel.BecomeTeenagerAge).ToDays) { // CampaignEventDispatcher.Instance.OnHeroReachesTeenAge(current); } else if ((int)current.BirthDay.ElapsedDaysUntilNow == (int)CampaignTime.Years((float)Campaign.Current.Models.AgeModel.BecomeChildAge).ToDays) { // CampaignEventDispatcher.Instance.OnHeroGrowsOutOfInfancy(current); } } }
public Messenger(Hero targetHero, CampaignTime dispatchTime) { this.TargetHero = targetHero; this.DispatchTime = dispatchTime; this.CurrentPosition = Hero.MainHero.GetMapPoint().Position2D; this.Arrived = false; }
private static void conversation_set_up_safe_passage_barter_on_consequence(DialogueParams param) { BarterManager instance = BarterManager.Instance; Hero oneToOneConversationHero = Hero.OneToOneConversationHero; PartyBase mainParty = PartyBase.MainParty; PartyBase otherParty = MobileParty.ConversationParty?.Party; BarterManager.BarterContextInitializer initContext = new BarterManager.BarterContextInitializer(BarterManager.Instance.InitializeSafePassageBarterContext); int persuasionCostReduction = 0; bool isAIBarter = false; if (Hero.OneToOneConversationHero == null) { Barterable[] array = new Barterable[1]; array[0] = new SafePassageBarterable(null, Hero.MainHero, otherParty, PartyBase.MainParty); instance.StartBarterOffer(Hero.MainHero, oneToOneConversationHero, mainParty, otherParty, null, initContext, persuasionCostReduction, isAIBarter, array); } else { Barterable[] array = new Barterable[2]; array[0] = new SafePassageBarterable(oneToOneConversationHero, Hero.MainHero, otherParty, PartyBase.MainParty); array[1] = new NoAttackBarterable(Hero.MainHero, oneToOneConversationHero, mainParty, otherParty, CampaignTime.Days(5f)); instance.StartBarterOffer(Hero.MainHero, oneToOneConversationHero, mainParty, otherParty, null, initContext, persuasionCostReduction, isAIBarter, array); } }
public Pregnancy(Hero pregnantHero, Hero father, CampaignTime dueDate) { Mother = pregnantHero; Father = father; DueDate = dueDate; AlreadyOccured = false; }
// Token: 0x0600000C RID: 12 RVA: 0x0000244C File Offset: 0x0000064C public void OnNewGameCreated(CampaignGameStarter campaignGameStarter) { this._companionTemplates = new List <CharacterObject>(from x in CharacterObject.Templates where x.Occupation == Occupation.Wanderer select x); this._nextRandomCompanionSpawnDate = CampaignTime.WeeksFromNow(this._randomCompanionSpawnFrequencyInWeeks); this.SetNumber(); }
public BattleHistoryEntry(MapEvent battle, CampaignTime endTime) { Attacker = battle.GetLeaderParty(BattleSideEnum.Attacker); Defender = battle.GetLeaderParty(BattleSideEnum.Defender); Type = battle.EventType; State = battle.BattleState; Time = endTime; }
private bool game_menu_steal_wait_on_condition(MenuCallbackArgs args) { args.MenuContext.GameMenu.AllowWaitingAutomatically(); GoalStealTime = CampaignTime.HoursFromNow(KleptomaniaSubModule.settings.HoursWaitingToSteal); //Goal time is 4 hours wait by default return(true); }
public static void SetPregnancyDueDate(object pregnancyObj, CampaignTime newDueDate) { if (PregCampHelper.m_pregnancyDueDateField == (FieldInfo)null) { return; } PregCampHelper.m_pregnancyDueDateField.SetValue(pregnancyObj, (object)newDueDate); }
private void Produce2() { int RidingSkill = Hero.MainHero.GetSkillValue(DefaultSkills.Riding); _startTime = CampaignTime.Now; _Duration = instance.BreedingTime / ((100 + RidingSkill) / 100); GameMenu.SwitchToMenu("breeding_wait2"); }
public static CampaignTime CreateCampaignTime(long ticks) { ConstructorInfo ctor = typeof(CampaignTime).GetConstructor (BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(long) }, null); CampaignTime time = (CampaignTime)ctor.Invoke(new object[] { ticks }); return(time); }
public MissiveSyncData(IMissive missive) { TypeName = missive.GetType().Name; CampaignTimeSent = missive.CampaignTimeSent; CampaignTimeArrival = missive.CampaignTimeArrival; RecipientId = missive.Recipient.StringId; SenderId = missive.Sender.StringId; Text = missive.Text; }
private static void Postfix2(ref CampaignTime __result) { ISettingsProvider settings = new MASettings(); if (settings.RetryCourtship) { __result = CampaignTime.DaysFromNow(1f); } }
public CEWhereAreMyThingsIssueQuest(string questId, Hero giverHero, CampaignTime duration, int rewardGold, Equipment stolenBattleEquipment, Equipment stolenCivilianEquipment) : base(questId, giverHero, duration, rewardGold) { _stolenBattleEquipment = stolenBattleEquipment; _stolenCivilianEquipment = stolenCivilianEquipment; AddTrackedObject(QuestGiver); SetDialogs(); InitializeQuestOnCreation(); OnQuestAccepted(); }
public DailyLog(int slavesDied, int goodsProduced, int toolsUsed) { day = CampaignTime.Now; _slavesDied = slavesDied; _goodsProduced = goodsProduced; _toolsUsed = toolsUsed; _nextDay = null; _previousDay = null; }
public static string Time(List <string> strings) { //CampaignTime deltaTime = CampaignTime.Now - SubModule.TimeSinceLastSave; CampaignTime deltaTime = SubModule.GetDeltaTime(); //double yearsElapsed = deltaTime.ToYears; //SubModule.TimeSinceLastSave = CampaignTime.Zero; return(deltaTime.ToYears.ToString()); }
public static CampaignTime GetDeltaTime(bool update = false) { CampaignTime deltaTime = CampaignTime.Now - TimeSinceLastSave; if (update) { TimeSinceLastSave = CampaignTime.Now; } return(deltaTime); }
private void OnDailyTick() { bool adultAafEnabled = Main.Settings !.AdultAgeFactor > 1.02f; bool childAafEnabled = Main.Settings !.ChildAgeFactor > 1.02f; if (CampaignOptions.IsLifeDeathCycleDisabled) { return; } PeriodicDeathProbabilityUpdate(adultAafEnabled); /* Send childhood growth stage transition events & perform AAF if enabled */ // Subtract 1 for the daily tick's implicitly-aged day & the rest is // explicit, incremental age to add. var adultAgeDelta = CampaignTime.Days(Main.Settings.AdultAgeFactor - 1f); var childAgeDelta = CampaignTime.Days(Main.Settings.ChildAgeFactor - 1f); var oneDay = CampaignTime.Days(1f); foreach (var hero in Hero.All) { if (!hero.IsAlive) { continue; } // When calculating the prevAge, we must take care to include the day // which the daily tick implicitly aged us since we last did this, or // else we could miss age transitions. Ergo, prevAge is the age we // were as if we were one day younger than our current BirthDay. int prevAge = (int)(hero.BirthDay + oneDay).ElapsedYearsUntilNow; if (adultAafEnabled && !hero.IsChild) { hero.SetBirthDay(hero.BirthDay - adultAgeDelta); } else if (childAafEnabled && hero.IsChild) { hero.SetBirthDay(hero.BirthDay - childAgeDelta); } hero.CharacterObject.Age = hero.Age; // And our new age, if different. int newAge = (int)hero.Age; // Did a relevant transition in age(s) occur? if (newAge > prevAge && prevAge < adultAge && !hero.IsTemplate) { ProcessAgeTransition(hero, prevAge, newAge); } } }
public static long GetTicks(this CampaignTime time) { System.Type c = typeof(CampaignTime); System.Reflection.PropertyInfo ticksInfo = c.GetProperty("NumTicks", BindingFlags.NonPublic | BindingFlags.Instance); if (ticksInfo != null) { long ticks = (long)ticksInfo.GetValue(time); return(ticks); } return(0); }