diff --git a/Assemblies/CombatExtended.dll b/Assemblies/CombatExtended.dll index d3b9786b6a..72aa5ac301 100644 Binary files a/Assemblies/CombatExtended.dll and b/Assemblies/CombatExtended.dll differ diff --git a/Royalty/Patches/ThingDefs_Buildings/Buildings_Mechanoid.xml b/Royalty/Patches/ThingDefs_Buildings/Buildings_Mechanoid.xml index 1766257662..110a6ecc7d 100644 --- a/Royalty/Patches/ThingDefs_Buildings/Buildings_Mechanoid.xml +++ b/Royalty/Patches/ThingDefs_Buildings/Buildings_Mechanoid.xml @@ -7,9 +7,9 @@ Defs/ThingDef[defName="Defoliator"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks - 180 - 240 - + 180 + 240 + @@ -17,9 +17,9 @@ Defs/ThingDef[defName="UnstablePowerCell"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks - 180 - 300 - + 180 + 300 + @@ -27,9 +27,9 @@ Defs/ThingDef[defName="Turret_AutoMortar"]/comps/li[@Class="CompProperties_Explosive"]/wickTicks - 180 - 240 - + 180 + 240 + @@ -229,12 +229,12 @@ Defs/ThingDef[defName="Turret_AutoMortar"]/comps -
  • - - 5 - 20 - -
  • +
  • + + 5 + 20 + +
  • @@ -253,15 +253,16 @@ Defs/ThingDef[defName = "Artillery_AutoMortar"] -
  • - -
  • 30
  • -
  • 50
  • -
  • 70
  • -
  • 90
  • - - -
    +
  • + +
  • 30
  • +
  • 50
  • +
  • 70
  • +
  • 90
  • + + +
  • + @@ -276,26 +277,26 @@ Defs/ThingDef[defName = "Artillery_AutoMortar"]/verbs -
  • - CombatExtended.Verb_ShootMortarCE - false - true - Bullet_ChargeMortarShell - 11 - 32 - 700 - 1 - Mortar_LaunchA - 16 - 3 - 0.4 - - true - -
  • +
  • + CombatExtended.Verb_ShootMortarCE + false + true + Bullet_ChargeMortarShell + 11 + 32 + 700 + 1 + Mortar_LaunchA + 16 + 3 + 0.4 + + true + +
  • - + \ No newline at end of file diff --git a/Source/CombatExtended/CombatExtended/Jobs/Utils/JobGiverUtils_Reload.cs b/Source/CombatExtended/CombatExtended/Jobs/Utils/JobGiverUtils_Reload.cs index 34d796e88c..174e24daa6 100644 --- a/Source/CombatExtended/CombatExtended/Jobs/Utils/JobGiverUtils_Reload.cs +++ b/Source/CombatExtended/CombatExtended/Jobs/Utils/JobGiverUtils_Reload.cs @@ -110,7 +110,7 @@ public static bool CanReload(Pawn pawn, Thing hopefullyTurret, bool forced = fal CELogger.Message($"{pawn} could not reload {turret} because turret is manned (or was recently manned) by someone else."); return false; } - if (FindBestAmmo(pawn, turret) == null) + if (compAmmo.UseAmmo && FindBestAmmo(pawn, turret) == null) { JobFailReason.Is("CE_NoAmmoAvailable".Translate()); return false; diff --git a/Source/CombatExtended/CombatExtended/Jobs/WorkGiver_ReloadTurret.cs b/Source/CombatExtended/CombatExtended/Jobs/WorkGiver_ReloadTurret.cs index 803a162d0f..a9cc601bf8 100644 --- a/Source/CombatExtended/CombatExtended/Jobs/WorkGiver_ReloadTurret.cs +++ b/Source/CombatExtended/CombatExtended/Jobs/WorkGiver_ReloadTurret.cs @@ -68,15 +68,10 @@ public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) if (!(t is Building_TurretGunCE)) { return false; } - var priority = GetThingPriority(pawn, t, forced); - CELogger.Message($"Priority check completed. Got {priority}"); Building_TurretGunCE turret = t as Building_TurretGunCE; - CELogger.Message($"Turret uses ammo? {turret.CompAmmo.UseAmmo}"); - if (!turret.CompAmmo.UseAmmo) - return true; - CELogger.Message($"Total magazine size: {turret.CompAmmo.Props.magazineSize}. Needed: {turret.CompAmmo.MissingToFullMagazine}"); + CELogger.Message($"Total magazine size: {turret.CompAmmo?.Props.magazineSize.ToString() ?? "null"}. Needed: {turret.CompAmmo?.MissingToFullMagazine.ToString() ?? "null"}"); return JobGiverUtils_Reload.CanReload(pawn, turret, forced); } diff --git a/Source/CombatExtended/CombatExtended/StatWorkers/StatWorker_AmmoConsumedPerShotCount.cs b/Source/CombatExtended/CombatExtended/StatWorkers/StatWorker_AmmoConsumedPerShotCount.cs index 5c64dc439b..93e6f0b7d3 100644 --- a/Source/CombatExtended/CombatExtended/StatWorkers/StatWorker_AmmoConsumedPerShotCount.cs +++ b/Source/CombatExtended/CombatExtended/StatWorkers/StatWorker_AmmoConsumedPerShotCount.cs @@ -19,11 +19,6 @@ private ThingDef GunDef(StatRequest req) return def; } - private Thing Gun(StatRequest req) - { - return (req.Thing as Building_TurretGunCE)?.Gun ?? req.Thing; - } - public override bool ShouldShowFor(StatRequest req) { return base.ShouldShowFor(req) && (GunDef(req)?.Verbs? diff --git a/Source/CombatExtended/CombatExtended/Things/Building_TurretGunCE.cs b/Source/CombatExtended/CombatExtended/Things/Building_TurretGunCE.cs index 41aad73f5e..7d68cfa6c1 100644 --- a/Source/CombatExtended/CombatExtended/Things/Building_TurretGunCE.cs +++ b/Source/CombatExtended/CombatExtended/Things/Building_TurretGunCE.cs @@ -76,22 +76,19 @@ public Thing Gun { get { - if (this.gunInt == null && Map != null) + if (gunInt == null && Map != null) { - this.gunInt = ThingMaker.MakeThing(this.def.building.turretGunDef, null); - this.compAmmo = gunInt.TryGetComp(); + GetOrCreateGunInt(); InitGun(); // FIXME: Hack to make player-crafted turrets spawn unloaded - if (//Map != null && !Map.IsPlayerHome - //!Faction.IsPlayer - (!Map.IsPlayerHome || Faction != Faction.OfPlayer) && compAmmo != null) + if (!Map.IsPlayerHome || Faction != Faction.OfPlayer) { - compAmmo.ResetAmmoCount(); + compAmmo?.ResetAmmoCount(); } } - return this.gunInt; + return gunInt; } } public ThingDef Projectile @@ -643,6 +640,7 @@ private void InitGun() CompAmmo.turret = this; //if (def.building.turretShellDef != null && def.building.turretShellDef is AmmoDef) CompAmmo.selectedAmmo = (AmmoDef)def.building.turretShellDef; } + gunInt = GetOrCreateGunInt(); List allVerbs = this.gunInt.TryGetComp().AllVerbs; for (int i = 0; i < allVerbs.Count; i++) { @@ -652,6 +650,15 @@ private void InitGun() } } + private Thing GetOrCreateGunInt() + { + this.gunInt = this.gunInt ?? ThingMaker.MakeThing(this.def.building.turretGunDef, null); + this.compAmmo = this.compAmmo ?? gunInt.TryGetComp(); + + return gunInt; + + } + public void TryForceReload() { TryOrderReload(true);