コード例 #1
0
        public void mod_FoundSettlement(RegionSettlementLocation settlementLocation, string name = null)
        {
            if (!KingmakerPatchSettings.CurrencyFallback.Enabled)
            {
                this.source_FoundSettlement(settlementLocation, name);
                return;
            }

            if (!this.Blueprint.SettlementBuildArea)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no building area set up", settlementLocation);
                return;
            }

            if (this.Settlement != null)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: already built", settlementLocation);
                return;
            }

            if (settlementLocation != null && settlementLocation.AssociatedLocation == null)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no globalmap location associated", settlementLocation);
                return;
            }

            if (settlementLocation == null && this.Blueprint.SettlementGlobalmapLocations.Length == 0)
            {
                UberDebug.LogError("Cannot found a settlement in {0}: no location specified and no default found", this.Blueprint);
                return;
            }

            KingdomCurrencyFallback.SpendPoints(KingdomRoot.Instance.SettlementBPCost);

            var settlementState = new SettlementState(SettlementState.LevelType.Village)
            {
                Region = this
            };

            SettlementState settlementState2 = settlementState;

            settlementState2.HasWaterSlot = settlementLocation?.HasWaterSlot == true;

            settlementState.Name = name ?? this.Blueprint.DefaultSettlementName;

            settlementState.Location = settlementLocation?.AssociatedLocation ?? this.Blueprint.SettlementGlobalmapLocations.FirstOrDefault();

            settlementState.SettlementLocation = settlementLocation;

            this.Settlement = settlementState;

            this.SetSettlementUIMarkers();

            EventBus.RaiseEvent((ISettlementFoundingHandler h) => h.OnSettlementFounded(this.Settlement));
        }
コード例 #2
0
            static bool Prefix(RegionState __instance, RegionSettlementLocation settlementLocation, string name)
            {
                try
                {
                    if (!Main.enabled)
                    {
                        return(true);
                    }
                    if (!Main.settings.currencyFallback)
                    {
                        return(true);
                    }
                    if (!__instance.Blueprint.SettlementBuildArea)
                    {
                        UberDebug.LogError("Cannot found a settlement in {0}: no building area set up", settlementLocation);
                        return(false);
                    }

                    if (__instance.Settlement != null)
                    {
                        UberDebug.LogError("Cannot found a settlement in {0}: already built", settlementLocation);
                        return(false);
                    }

                    if (settlementLocation != null && settlementLocation.AssociatedLocation == null)
                    {
                        UberDebug.LogError("Cannot found a settlement in {0}: no globalmap location associated", settlementLocation);
                        return(false);
                    }

                    if (settlementLocation == null && __instance.Blueprint.SettlementGlobalmapLocations.Length == 0)
                    {
                        UberDebug.LogError("Cannot found a settlement in {0}: no location specified and no default found", __instance.Blueprint);
                        return(false);
                    }

                    KingdomCurrencyFallback.SpendPoints(KingdomRoot.Instance.SettlementBPCost);

                    var settlementState = new SettlementState(SettlementState.LevelType.Village)
                    {
                        Region = __instance
                    };

                    SettlementState settlementState2 = settlementState;

                    settlementState2.HasWaterSlot = settlementLocation?.HasWaterSlot == true;

                    settlementState.Name = name ?? __instance.Blueprint.DefaultSettlementName;

                    settlementState.Location = settlementLocation?.AssociatedLocation ?? __instance.Blueprint.SettlementGlobalmapLocations.FirstOrDefault();

                    settlementState.SettlementLocation = settlementLocation;

                    __instance.Settlement = settlementState;

                    __instance.SetSettlementUIMarkers();

                    EventBus.RaiseEvent((ISettlementFoundingHandler h) => h.OnSettlementFounded(__instance.Settlement));
                    return(false);
                }
                catch (Exception ex)
                {
                    Main.Error(ex);
                    return(true);
                }
            }
コード例 #3
0
 public void source_FoundSettlement(RegionSettlementLocation settlementLocation, string name = null)
 {
     throw new DeadEndException("source_FoundSettlement");
 }