static private Kingmaker.UnitLogic.Feature maybeAddFact(UnitDescriptor descriptor, BlueprintUnitFact feature, MechanicsContext context, FeatureParam param)
 {
     if (descriptor.Progression.Features.Enumerable.Where <Kingmaker.UnitLogic.Feature>(p => p.Blueprint == feature).Any(a => a.Param == param))
     {
         return(null);
     }
     return(descriptor.AddFact <Kingmaker.UnitLogic.Feature>(feature, context, param));
 }
예제 #2
0
        static void Postfix(UnitDescriptor __instance)
        {
            var action = library.Get <BlueprintAbility>(DropHeldWeaponsAbility.Data.Guid);

            if (action != null)
            {
                __instance.AddFact(action);
            }
        }
        public static void GiveFeat(UnitDescriptor unit, string Guid, WeaponCategory category)
        {
            BlueprintFeature feature = Kingmaker.Cheats.Utilities.GetBlueprintByGuid <BlueprintFeature>(Guid);
            FeatureParam     param   = new FeatureParam(new WeaponCategory?(category));

            if (unit.GetFeature(feature, param) == null)
            {
                unit.AddFact(Kingmaker.Cheats.Utilities.GetBlueprintByGuid <BlueprintFeature>(Guid), null, param);
            }
        }
예제 #4
0
        static void Postfix(UnitDescriptor __instance)
        {
            var action = library.Get <BlueprintAbility>(CombatManeuverData.combatManeuverActionIds[CombatManeuver.Disarm]);

            if (action != null && __instance.HasFact(action))
            {
                __instance.RemoveFact(action);
            }

            var disarmToggle = library.Get <BlueprintActivatableAbility>(DisarmToggleAbility.Data.Guid);

            if (disarmToggle != null && !__instance.HasFact(disarmToggle))
            {
                __instance.AddFact(disarmToggle);
            }
        }
예제 #5
0
        static void Postfix(UnitDescriptor __instance)
        {
            foreach (var maneuver in new CombatManeuver[] { CombatManeuver.BullRush, CombatManeuver.DirtyTrickBlind, CombatManeuver.DirtyTrickEntangle, CombatManeuver.DirtyTrickSickened })
            {
                var action = library.Get <BlueprintAbility>(CombatManeuverData.combatManeuverActionIds[maneuver]);
                if (action != null && __instance.HasFact(action))
                {
                    __instance.RemoveFact(action);
                }
            }
            var groupAction = library.Get <BlueprintAbility>(CombatManeuversStandardAbility.Data.Guid);

            if (groupAction != null && !__instance.HasFact(groupAction))
            {
                __instance.AddFact(groupAction);
            }
        }
예제 #6
0
파일: LevelUp.cs 프로젝트: ThyWoof/ToyBox
            public static bool Prefix([NotNull] LevelUpState state, [NotNull] UnitDescriptor unit, [NotNull] IList <BlueprintFeatureBase> features, [CanBeNull] FeatureSource source, int level)
            {
                if (!Main.IsInGame)
                {
                    return(false);
                }
#if true
                //Logger.Log($"feature count = {features.ToArray().Count()} ");
                var description = source.Blueprint.GetDescription() ?? "nil";
                //Logger.Log($"source: {source.Blueprint.name} - {description}");
                foreach (BlueprintFeature blueprintFeature in features.OfType <BlueprintFeature>())
                {
                    if (blueprintFeature.MeetsPrerequisites((FeatureSelectionState)null, unit, state, true))
                    {
                        //Logger.Log($"    name: {blueprintFeature.Name} : {blueprintFeature.GetType()}");
                        if (blueprintFeature is IFeatureSelection selection)
                        {
                            // Bug Fix - due to issues in the implementation of FeatureSelectionState.CanSelectAnything we can get level up blocked so this is an attempt to work around for that
                            var numToAdd = settings.featsMultiplier;
                            if (selection is BlueprintFeatureSelection bpFS)
                            {
                                var bpFeatures = bpFS;
                                var items      = bpFS.ExtractSelectionItems(unit, null);
                                //Logger.Log($"        items: {items.Count()}");
                                var availableCount = 0;
                                foreach (var item in items)
                                {
#if false
                                    if (bpFS.is BlueprintParametrizedFeature bppF)
                                    {
                                        Logger.Log($"checking parameterized feature {bppF.Name}");
                                        if (selection.CanSelect(unit, state, null, item))
                                        {
                                            Logger.Log($"        {item.Feature.name}  is avaiable");
                                            availableCount++;
                                        }
                                    }
                                    else
#endif
                                    if (!unit.Progression.Features.HasFact(item.Feature))
                                    {
                                        availableCount++;
                                        //                                        Logger.Log($"        {item.Feature.name}  is avaiable");
                                    }
#if false
                                    if (selection.CanSelect(unit, state, null, item))
                                    {
                                        Logger.Log($"        {item.Feature.name}  is avaiable");
                                        availableCount++;
                                    }
                                    else
                                    {
                                        Logger.Log($"        {item.Feature.name}  is NOT avaiable");
                                    }
                                    if (!unit.Progression.Features.HasFact(item.Feature))
                                    {
                                        if (item.Feature.MeetsPrerequisites(null, unit, state, true))
                                        {
                                            Logger.Log($"        {item.Feature.name}  is avaiable");
                                            availableCount++;
                                        }
                                    }
                                    else
                                    {
                                        Logger.Log($"        has Fact {item.Feature.Name}");
                                    }
#endif
                                }
                                if (numToAdd > availableCount)
                                {
                                    Logger.Log($"reduced numToAdd: {numToAdd} -> {availableCount}");
                                    numToAdd = availableCount;
                                }
                            }
                            //Logger.Log($"        IFeatureSelection: {selection} adding: {numToAdd}");
                            for (int i = 0; i < numToAdd; ++i)
                            {
                                state.AddSelection((FeatureSelectionState)null, source, selection, level);
                            }
                        }
                        Kingmaker.UnitLogic.Feature feature     = (Kingmaker.UnitLogic.Feature)unit.AddFact((BlueprintUnitFact)blueprintFeature);
                        BlueprintProgression        progression = blueprintFeature as BlueprintProgression;
                        if ((UnityEngine.Object)progression != (UnityEngine.Object)null)
                        {
                            //Logger.Log($"        BlueprintProgression: {progression}");
                            LevelUpHelper.UpdateProgression(state, unit, progression);
                        }
                        FeatureSource source1 = source;
                        int           level1  = level;
                        feature.SetSource(source1, level1);
                    }