Beispiel #1
0
        //static bool Prefix(DynamicBodyCampaignBehavior __instance, ref Dictionary<Hero, object> ____heroBehaviorsDictionary)
        static bool Prefix(DynamicBodyCampaignBehavior __instance)
        {
            if (DCCSettings.Instance != null && DCCSettings.Instance.IgnoreDailyTick)
            {
                IDictionary dictionary = (IDictionary)AccessTools.Field(typeof(DynamicBodyCampaignBehavior), "_heroBehaviorsDictionary").GetValue(__instance);

                CampaignTime deltaTime    = CampaignTime.Now - SubModule.TimeSinceLastSave;
                double       yearsElapsed = deltaTime.ToYears;
                SubModule.TimeSinceLastSave = CampaignTime.Now;

                foreach (DictionaryEntry heroBehaviors in dictionary)
                {
                    Hero hero = (Hero)heroBehaviors.Key;

                    if (!DCCSettings.Instance.DisableAutoAging)
                    {
                        if (hero.IsHumanPlayerCharacter && DCCSettings.Instance.DebugMode)
                        {
                            InformationManager.DisplayMessage(new InformationMessage(DebugSetAppearanceMsg.ToString() + hero.Name, ColorManager.Red));
                            var test = new DynamicBodyProperties(hero.DynamicBodyProperties.Age + 12f, hero.DynamicBodyProperties.Weight, hero.DynamicBodyProperties.Build);
                            InformationManager.DisplayMessage(new InformationMessage(DebugResultMsg.ToString() + test, ColorManager.Red));
                            hero.DynamicBodyProperties.Equals(test);

                            // TODO: Get access to keyValuePair w/ Reflection

                            /*float weight = hero.DynamicBodyProperties.Weight;
                             * float build = hero.DynamicBodyProperties.Build;
                             * ____heroBehaviorsDictionary.Key.DynamicBodyProperties = new DynamicBodyProperties(____heroBehaviorsDictionary.Key.Age, weight, build;*/
                        }

                        double newAge = hero.DynamicBodyProperties.Age + yearsElapsed;
                        DynamicBodyProperties bodyProperties = new DynamicBodyProperties((float)newAge, hero.DynamicBodyProperties.Weight, hero.DynamicBodyProperties.Build);
                        hero.DynamicBodyProperties = bodyProperties;

                        if (hero.IsHumanPlayerCharacter && DCCSettings.Instance.DebugMode)
                        {
                            InformationManager.DisplayMessage(new InformationMessage(SubModule.GetFormattedAgeDebugMessage(hero, hero.DynamicBodyProperties.Age), ColorManager.Red));
                        }
                    }
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #2
0
        //static bool Prefix(DynamicBodyCampaignBehavior __instance, ref Dictionary<Hero, object> ____heroBehaviorsDictionary)
        static bool Prefix(DynamicBodyCampaignBehavior __instance)
        {
            if (!DCCSettingsUtil.Instance.IgnoreDailyTick)
            {
                return(true);
            }

            //CampaignTime deltaTime = CampaignTime.Now - SubModule.TimeSinceLastSave;
            CampaignTime deltaTime    = SubModule.GetDeltaTime(true);
            double       yearsElapsed = deltaTime.ToYears;

            //SubModule.TimeSinceLastSave = CampaignTime.Now;

            if (!DCCSettingsUtil.Instance.DisableAutoAging)
            {
                IDictionary dictionary = (IDictionary)AccessTools.Field(typeof(DynamicBodyCampaignBehavior), "_heroBehaviorsDictionary").GetValue(__instance);
                foreach (var hero in dictionary.Keys.Cast <Hero>())
                {
                    if (hero.IsHumanPlayerCharacter && DCCSettingsUtil.Instance.DebugMode)
                    {
                        InformationManager.DisplayMessage(new InformationMessage(DebugSetAppearanceMsg.ToString() + hero.Name, ColorManager.Red));
                        var test = new DynamicBodyProperties(hero.Age, hero.Weight, hero.Build);
                        InformationManager.DisplayMessage(new InformationMessage(DebugResultMsg.ToString() + test, ColorManager.Red));
                        hero.BodyProperties.DynamicProperties.Equals(test);
                    }

                    // TODO:: Why is this conflicting now???

                    /*double 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 && DCCSettingsUtil.Instance.DebugMode)
                    {
                        InformationManager.DisplayMessage(new InformationMessage(SubModule.GetFormattedAgeDebugMessage(hero, hero.Age), ColorManager.Red));
                    }
                }
            }

            return(false);
        }