public bool mod_CheckRestrictions(SettlementState settlement, SettlementGridTopology.Slot slot)
        {
            if (KingmakerPatchSettings.Restrictions.IgnoreBuildingRestrictions)
            {
                return(true);
            }

            return(this.GetComponents <BuildingRestriction>().All(r => r.CanBuildHere(this, settlement, slot)));
        }
Пример #2
0
        public SettlementBuilding mod_Build(BlueprintSettlementBuilding building, SettlementGridTopology.Slot slot, bool force = false)
        {
            if (!KingmakerPatchSettings.CurrencyFallback.Enabled)
            {
                return(this.source_Build(building, slot, force));
            }

            var removedBuilding = true;

            if (!force)
            {
                if (!this.CanBuild(building))
                {
                    return(null);
                }

                BuildingSlot slotObject = slot.GetSlotObject();

                if (slotObject?.CanBuildHere(building) != true)
                {
                    return(null);
                }

                KingdomCurrencyFallback.SpendPoints(this.GetActualCost(building));

                removedBuilding = this.FreeBuildings.Remove(building) || KingdomState.Instance.FreeBuildings.Remove(building);
            }

            SettlementBuilding settlementBuilding = this.alias_m_Buildings.Build(building);

            settlementBuilding.BuildOnSlot(slot);

            if (building.SpecialSlot == SpecialSlotType.None)
            {
                this.alias_m_SlotsLeft -= building.SlotCount;
            }

            if (!force && !removedBuilding || this.alias_SellDiscountedBuilding != building)
            {
                this.alias_SellDiscountedBuilding = null;
            }

            this.Update();

            EventBus.RaiseEvent((ISettlementBuildingHandler h) => h.OnBuildingStarted(this, settlementBuilding));

            return(settlementBuilding);
        }
            static bool Prefix(SettlementState __instance, ref SettlementBuilding __result,
                               BlueprintSettlementBuilding building, SettlementGridTopology.Slot slot, bool force,
                               ref int ___m_SlotsLeft, BuildingsCollection ___m_Buildings)
            {
                try
                {
                    if (!Main.enabled)
                    {
                        return(true);
                    }
                    if (!Main.settings.currencyFallback)
                    {
                        return(true);
                    }

                    var removedBuilding = true;

                    if (!force)
                    {
                        if (!__instance.CanBuild(building))
                        {
                            __result = null;
                            return(false);
                        }

                        BuildingSlot slotObject = slot.GetSlotObject();

                        if (slotObject?.CanBuildHere(building) != true)
                        {
                            return(false);
                        }

                        KingdomCurrencyFallback.SpendPoints(__instance.GetActualCost(building));

                        removedBuilding = __instance.FreeBuildings.Remove(building) || KingdomState.Instance.FreeBuildings.Remove(building);
                    }

                    SettlementBuilding settlementBuilding = ___m_Buildings.Build(building);
                    settlementBuilding.BuildOnSlot(slot);

                    if (building.SpecialSlot == SpecialSlotType.None)
                    {
                        ___m_SlotsLeft -= building.SlotCount;
                    }

                    if (!force && !removedBuilding || SellDiscountedBuildingGetter(__instance) != building)
                    {
                        SellDiscountedBuildingSetter(__instance, null);
                    }

                    __instance.Update();

                    EventBus.RaiseEvent((ISettlementBuildingHandler h) => h.OnBuildingStarted(__instance, settlementBuilding));

                    __result = settlementBuilding;
                    return(false);
                }
                catch (Exception ex)
                {
                    Main.Error(ex);
                    return(true);
                }
            }
Пример #4
0
 public SettlementBuilding source_Build(BlueprintSettlementBuilding building, SettlementGridTopology.Slot slot, bool force = false)
 {
     throw new DeadEndException("source_Build");
 }