This repository was archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- CE_StatsReport_LoadedAmmo added to language keys (needs translation) - Stats.xml patched to add CombatExtended.StatPart_LoadedAmmo to Mass stat - Added file StatPart_LoadedAmmo - CompAmmoUser now immediately calls UpdateInventory WHENEVER CurMagCount is changed, as it should be - CompInventory stopped looking at loaded ammo for weight/bulk - StatPart_LoadedAmmo was added, which does everything previously done in CompInventory, but which is common in current RimWorld versions - Bulk StatDef now uses StatPart_LoadedAmmo - AmmoUser CompProperties include a loadedAmmoBulkFactor with default value 0f. This allows RPG-7 and similar weapons to have a higher bulkiness (volume) when loaded. - StatPart_LoadedAmmo multiplies by loadedAmmoBulkFactor when parentStat is Bulk
- Loading branch information
1 parent
dbd81b8
commit cf11995
Showing
8 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Source/CombatExtended/CombatExtended/StatParts/StatPart_LoadedAmmo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Verse; | ||
using RimWorld; | ||
|
||
namespace CombatExtended | ||
{ | ||
public class StatPart_LoadedAmmo : StatPart | ||
{ | ||
public override void TransformValue(StatRequest req, ref float val) | ||
{ | ||
if (TryGetValue(req, out float num)) | ||
val += num; | ||
} | ||
|
||
public override string ExplanationPart(StatRequest req) | ||
{ | ||
return TryGetValue(req, out float num) | ||
? "CE_StatsReport_LoadedAmmo".Translate() + ": " + parentStat.ValueToString(num) | ||
: null; | ||
} | ||
|
||
public bool TryGetValue(StatRequest req, out float num) | ||
{ | ||
num = 0f; | ||
if (req.HasThing) | ||
{ | ||
var ammoUser = req.Thing.TryGetComp<CompAmmoUser>(); | ||
if (ammoUser != null && ammoUser.CurrentAmmo != null) | ||
{ | ||
num = ammoUser.CurrentAmmo.GetStatValueAbstract(parentStat) * ammoUser.CurMagCount; | ||
|
||
if (parentStat == CE_StatDefOf.Bulk) | ||
num *= ammoUser.Props.loadedAmmoBulkFactor; | ||
} | ||
} | ||
return num != 0f; | ||
} | ||
} | ||
} |