public virtual void mod_Start(bool raiseEvent = true) { if (!KingmakerPatchSettings.CurrencyFallback.Enabled) { this.source_Start(raiseEvent); return; } this.alias_IsStarted = true; this.alias_StartedOn = KingdomState.Instance.CurrentDay; KingdomCurrencyFallback.SpendPoints(this.OneTimeBPCost); if (raiseEvent) { this.alias_OnTaskChanged(); } EventBus.RaiseEvent((IKingdomTaskEventsHandler h) => h.OnTaskStarted(this)); if (this.SkipPlayerTime <= 0) { return; } Kingmaker.Game.Instance.AdvanceGameTime(TimeSpan.FromDays(this.SkipPlayerTime)); foreach (UnitEntityData unitEntityData in Kingmaker.Game.Instance.Player.AllCharacters) { RestController.ApplyRest(unitEntityData.Descriptor); } new KingdomTimelineManager().UpdateTimeline(); }
public void mod_ClaimResource() { if (!KingmakerPatchSettings.CurrencyFallback.Enabled) { this.source_ClaimResource(); return; } if (this.Resource != ResourceStateType.CanClaim) { return; } KingdomCurrencyFallback.SpendPoints(KingdomRoot.Instance.DefaultMapResourceCost); KingdomState.Instance.Resources.Add(this.Blueprint); this.Blueprint.ResourceStats.Apply(); if (GlobalMapRules.Instance && GlobalMapRules.Instance.ClaimedResourceVisual) { GlobalMapLocation locationObject = GlobalMapRules.Instance.GetLocationObject(this.Blueprint); if (locationObject) { Object.Instantiate(GlobalMapRules.Instance.ClaimedResourceVisual, locationObject.transform, false); } } if (KingdomRoot.Instance.Locations.Count(l => l.HasKingdomResource) == KingdomState.Instance.Resources.Count) { Kingmaker.Game.Instance.Player.Achievements.Unlock(AchievementType.IntensiveDevelopment); } }
public SettlementBuilding mod_UpgradeBuilding(SettlementBuilding building) { if (!KingmakerPatchSettings.CurrencyFallback.Enabled) { return(this.source_UpgradeBuilding(building)); } if (!building.IsFinished || !this.alias_m_Buildings.HasFact(building) || !building.Blueprint.UpgradesTo) { return(null); } if (!KingdomCurrencyFallback.CanSpend(this.GetActualCost(building.Blueprint.UpgradesTo))) { UberDebug.LogWarning("Cannot upgrade " + building.Blueprint + ": not enough BP"); return(null); } KingdomCurrencyFallback.SpendPoints(this.GetActualCost(building.Blueprint)); SettlementBuilding result = this.alias_m_Buildings.Upgrade(building); this.Update(); EventBus.RaiseEvent((ISettlementBuildUpdate h) => h.OnBuildUpdate(building)); return(result); }
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)); }
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); }