forked from Vek17/TabletopTweaks-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to supported Mixed blood bloodrager
- Loading branch information
Showing
5 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
TabletopTweaks/NewComponents/Properties/CompositeCustomPropertyGetter.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,45 @@ | ||
using Kingmaker.Blueprints.JsonSystem; | ||
using Kingmaker.EntitySystem.Entities; | ||
using Kingmaker.UnitLogic.Mechanics.Properties; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace TabletopTweaks.NewComponents.Properties { | ||
[TypeId("762c31d6c5284ff5964a4af007ec5325")] | ||
class CompositeCustomPropertyGetter : PropertyValueGetter { | ||
public override int GetBaseValue(UnitEntityData unit) { | ||
switch (CalculationMode) { | ||
case Mode.Sum: | ||
return Properties.Select(property => property.Calculate(unit)).Sum(); | ||
case Mode.Highest: | ||
return Properties.Select(property => property.Calculate(unit)).Max(); | ||
case Mode.Lowest: | ||
return Properties.Select(property => property.Calculate(unit)).Min(); | ||
default: | ||
return 0; | ||
} | ||
} | ||
|
||
public ComplexCustomProperty[] Properties = new ComplexCustomProperty[0]; | ||
public Mode CalculationMode; | ||
|
||
public enum Mode : int { | ||
Sum, | ||
Highest, | ||
Lowest | ||
} | ||
|
||
public class ComplexCustomProperty { | ||
public ComplexCustomProperty() { } | ||
|
||
public int Calculate(UnitEntityData unit) { | ||
return Bonus + Mathf.FloorToInt((Numerator / Denominator) * Property.GetBaseValue(unit)); | ||
} | ||
|
||
public PropertyValueGetter Property; | ||
public int Bonus; | ||
public float Numerator = 1; | ||
public float Denominator = 1; | ||
} | ||
} | ||
} |
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