Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions RimWorldOfMagic/RimWorldOfMagic/CompAbilityUserMagic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9189,12 +9189,11 @@ public void RemoveAdvancedClass(TMDefs.TM_CustomClass ac)

public void UpdateAutocastDef()
{
IEnumerable<TM_CustomPowerDef> mpDefs = TM_Data.CustomMagePowerDefs();
if (this.IsMagicUser && this.MagicData != null && this.MagicData.MagicPowersCustom != null)
if (IsMagicUser && MagicData?.MagicPowersCustom != null)
{
foreach (MagicPower mp in this.MagicData.MagicPowersCustom)
foreach (MagicPower mp in MagicData.MagicPowersCustom)
{
foreach (TM_CustomPowerDef mpDef in mpDefs)
foreach (TM_CustomPowerDef mpDef in TM_Data.CustomMagePowerDefs())
{
if (mpDef.customPower.abilityDefs[0].ToString() == mp.GetAbilityDef(0).ToString())
{
Expand Down
6 changes: 0 additions & 6 deletions RimWorldOfMagic/RimWorldOfMagic/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,12 +1670,6 @@ public static void PawnEquipment_Add_Postfix(Pawn_EquipmentTracker __instance, T
CompAbilityUserMight comp = p.GetCompAbilityUserMight();
if (p != null && comp != null && (p.story.traits.HasTrait(TorannMagicDefOf.TM_SuperSoldier) || (comp.customClass != null)))
{
if (comp.equipmentContainer == null)
{
comp.equipmentContainer = new ThingOwner<ThingWithComps>();
comp.equipmentContainer.Clear();
}

if (newEq == p.equipment.Primary)
{
//Log.Message("adding primary weapon");
Expand Down
18 changes: 8 additions & 10 deletions RimWorldOfMagic/RimWorldOfMagic/MagicData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3586,17 +3586,16 @@ public MagicPowerSkill GetSkill_Versatility(TMAbilityDef ability)
}
if (!hasSkill) //check custom powers for different ability to skill names
{
List<TM_CustomPowerDef> customPowers = TM_Data.CustomMagePowerDefs().ToList();
for (int i = 0; i < customPowers.Count; i++)
foreach (TM_CustomPowerDef powerDef in TM_Data.CustomMagePowerDefs())
{
for (int j = 0; j < customPowers[i].customPower.abilityDefs.Count; j++)
for (int j = 0; j < powerDef.customPower.abilityDefs.Count; j++)
{
if (ability.defName == customPowers[i].customPower.abilityDefs[j].ToString())
if (ability.defName == powerDef.customPower.abilityDefs[j].ToString())
{
for (int k = 0; k < AllMagicPowerSkills.Count; k++)
{
MagicPowerSkill mps = AllMagicPowerSkills[k];
foreach (TM_CustomSkill cs in customPowers[i].customPower.skills)
foreach (TM_CustomSkill cs in powerDef.customPower.skills)
{
if (cs.label.Contains("_ver") && cs.label == mps.label)
{
Expand Down Expand Up @@ -3638,17 +3637,16 @@ public MagicPowerSkill GetSkill_Power(TMAbilityDef ability)
}
if (!hasSkill) //check custom powers for different ability to skill names
{
List<TM_CustomPowerDef> customPowers = TM_Data.CustomMagePowerDefs().ToList();
for (int i = 0; i < customPowers.Count; i++)
foreach (TM_CustomPowerDef powerDef in TM_Data.CustomMagePowerDefs())
{
for (int j = 0; j < customPowers[i].customPower.abilityDefs.Count; j++)
for (int j = 0; j < powerDef.customPower.abilityDefs.Count; j++)
{
if (ability.defName == customPowers[i].customPower.abilityDefs[j].ToString())
if (ability.defName == powerDef.customPower.abilityDefs[j].ToString())
{
for (int k = 0; k < AllMagicPowerSkills.Count; k++)
{
MagicPowerSkill mps = AllMagicPowerSkills[k];
foreach (TM_CustomSkill cs in customPowers[i].customPower.skills)
foreach (TM_CustomSkill cs in powerDef.customPower.skills)
{
if (cs.label.EndsWith("_pwr") && cs.label == mps.label)
{
Expand Down
45 changes: 16 additions & 29 deletions RimWorldOfMagic/RimWorldOfMagic/MightData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,15 @@ public class MightData : IExposable
private int ticksAffiliation = 0;
//public ThingOwner<ThingWithComps> equipmentContainer = new ThingOwner<ThingWithComps>();


public bool customPowersInitialized = false;
public List<MightPower> mightPowerCustom;
public List<MightPower> MightPowersCustom //supports customs abilities
{
get
{
bool flag = this.mightPowerCustom == null; // || !this.customPowersInitialized;
if (flag)
if (mightPowerCustom == null)
{
this.customPowersInitialized = true;
IEnumerable<TM_CustomPowerDef> enumerable = TM_Data.CustomFighterPowerDefs();

if (mightPowerCustom == null || mightPowerCustom.Count <= 0)
{
this.mightPowerCustom = new List<MightPower>();
this.mightPowerCustom.Clear();
}
foreach (TM_CustomPowerDef current in enumerable)
mightPowerCustom ??= new List<MightPower>();
foreach (TM_CustomPowerDef current in TM_Data.CustomFighterPowerDefs())
{
bool newPower = false;
List<AbilityUser.AbilityDef> abilityList = current.customPower.abilityDefs;
Expand Down Expand Up @@ -2147,17 +2137,16 @@ public MightPowerSkill GetSkill_Efficiency(TMAbilityDef ability)
}
if (!hasSkill) //check custom powers for different ability pairing for skill names
{
List<TM_CustomPowerDef> customPowers = TM_Data.CustomFighterPowerDefs().ToList();
for (int i = 0; i < customPowers.Count; i++)
foreach (TM_CustomPowerDef powerDef in TM_Data.CustomFighterPowerDefs())
{
for (int j = 0; j < customPowers[i].customPower.abilityDefs.Count; j++)
for (int j = 0; j < powerDef.customPower.abilityDefs.Count; j++)
{
if (ability.defName == customPowers[i].customPower.abilityDefs[j].ToString())
if (ability.defName == powerDef.customPower.abilityDefs[j].ToString())
{
for (int k = 0; k < AllMightPowerSkills.Count; k++)
{
MightPowerSkill mps = AllMightPowerSkills[k];
foreach (TM_CustomSkill cs in customPowers[i].customPower.skills)
foreach (TM_CustomSkill cs in powerDef.customPower.skills)
{
if (cs.label.EndsWith("_eff") && cs.label == mps.label)
{
Expand Down Expand Up @@ -2200,17 +2189,16 @@ public MightPowerSkill GetSkill_Versatility(TMAbilityDef ability)
}
if (!hasSkill) //check custom powers for different ability to skill names
{
List<TM_CustomPowerDef> customPowers = TM_Data.CustomFighterPowerDefs().ToList();
for (int i = 0; i < customPowers.Count; i++)
foreach (TM_CustomPowerDef powerDef in TM_Data.CustomFighterPowerDefs())
{
for (int j = 0; j < customPowers[i].customPower.abilityDefs.Count; j++)
for (int j = 0; j < powerDef.customPower.abilityDefs.Count; j++)
{
if (ability.defName == customPowers[i].customPower.abilityDefs[j].ToString())
if (ability.defName == powerDef.customPower.abilityDefs[j].ToString())
{
for (int k = 0; k < AllMightPowerSkills.Count; k++)
{
MightPowerSkill mps = AllMightPowerSkills[k];
foreach (TM_CustomSkill cs in customPowers[i].customPower.skills)
foreach (TM_CustomSkill cs in powerDef.customPower.skills)
{
if (cs.label.EndsWith("_ver") && cs.label == mps.label)
{
Expand Down Expand Up @@ -2253,17 +2241,16 @@ public MightPowerSkill GetSkill_Power(TMAbilityDef ability)
}
if(!hasSkill) //check custom powers for different ability to skill names
{
List<TM_CustomPowerDef> customPowers = TM_Data.CustomFighterPowerDefs().ToList();
for (int i = 0; i < customPowers.Count; i++)
foreach (TM_CustomPowerDef powerDef in TM_Data.CustomFighterPowerDefs())
{
for (int j = 0; j < customPowers[i].customPower.abilityDefs.Count; j++)
for (int j = 0; j < powerDef.customPower.abilityDefs.Count; j++)
{
if(ability.defName == customPowers[i].customPower.abilityDefs[j].ToString())
if(ability.defName == powerDef.customPower.abilityDefs[j].ToString())
{
for (int k = 0; k < AllMightPowerSkills.Count; k++)
{
MightPowerSkill mps = AllMightPowerSkills[k];
foreach(TM_CustomSkill cs in customPowers[i].customPower.skills)
foreach(TM_CustomSkill cs in powerDef.customPower.skills)
{
if(cs.label.EndsWith("_pwr") && cs.label == mps.label)
{
Expand Down Expand Up @@ -2489,4 +2476,4 @@ public void ExposeData()
Scribe_Collections.Look<MightPowerSkill>(ref this.mightPowerSkill_SoothingBalm, "mightPowerSkill_SoothingBalm", (LookMode)2, new object[0]);
}
}
}
}
1 change: 1 addition & 0 deletions RimWorldOfMagic/RimWorldOfMagic/RimWorldOfMagic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<LangVersion>10</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Loading