forked from mipen/BannerlordTweaks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweakedSettlementMilitiaModel.cs
50 lines (46 loc) · 2.09 KB
/
TweakedSettlementMilitiaModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;
using TaleWorlds.Localization;
using System.Linq;
using System.Windows.Forms;
using System;
using BannerlordTweaks.Lib;
namespace BannerlordTweaks
{
public class TweakedSettlementMilitiaModel : DefaultSettlementMilitiaModel
{
public override float CalculateMilitiaChange(Settlement settlement, StatExplainer explanation = null)
{
float baseVal = base.CalculateMilitiaChange(settlement, explanation);
ExplainedNumber en = new ExplainedNumber(0f, explanation);
en.Add(baseVal);
try
{
if (Settings.Instance.SettlementMilitiaBonusEnabled)
{
if (settlement.IsCastle)
en.Add(Settings.Instance.CastleMilitiaBonus, new TextObject("Recruitment drive"));
if (settlement.IsTown)
en.Add(Settings.Instance.TownMilitiaBonus, new TextObject("Citizen militia"));
}
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred in TweakedSettlementMilitiaModule:\n\n{ex.ToStringFull()}");
}
return en.ResultNumber;
}
public override void CalculateMilitiaSpawnRate(Settlement settlement, out float meleeTroopRate, out float rangedTroopRate, out float meleeEliteTroopRate, out float rangedEliteTroopRate)
{
float _meleeEliteTroopRate, _rangedEliteTroopRate;
base.CalculateMilitiaSpawnRate(settlement, out meleeTroopRate, out rangedTroopRate, out _meleeEliteTroopRate, out _rangedEliteTroopRate);
if (Settings.Instance.SettlementMilitiaEliteSpawnRateBonusEnabled)
{
_meleeEliteTroopRate += Settings.Instance.SettlementEliteMeleeSpawnRateBonus;
_rangedEliteTroopRate += Settings.Instance.SettlementEliteRangedSpawnRateBonus;
}
meleeEliteTroopRate = _meleeEliteTroopRate;
rangedEliteTroopRate = _rangedEliteTroopRate;
}
}
}