Skip to content

Commit

Permalink
1.17.5.0
Browse files Browse the repository at this point in the history
Updated for AI profile capabilities and new PawnAbility (from JecsTools)
support. Improved cooldown tracking.
  • Loading branch information
jecrell committed Oct 19, 2017
1 parent 061f5ab commit a4f97d7
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 27 deletions.
Binary file modified Assemblies/ProjectJedi.dll
Binary file not shown.
1 change: 1 addition & 0 deletions Source/ProjectJedi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Compile Include="ProjectJedi\Building_ForceMeditationPad.cs" />
<Compile Include="ProjectJedi\ForcePower.cs" />
<Compile Include="ProjectJedi\ForceSkill.cs" />
<Compile Include="ProjectJedi\ForceUserUtility.cs" />
<Compile Include="ProjectJedi\HarmonyPatches.cs" />
<Compile Include="ProjectJedi\HediffComp_Shield.cs" />
<Compile Include="ProjectJedi\Gizmo_HediffShieldStatus.cs" />
Expand Down
14 changes: 7 additions & 7 deletions Source/ProjectJedi/CompForceUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ public List<ForcePower> ForcePowersLight
// }
//}

//public override IEnumerable<Gizmo> CompGetGizmosExtra()
//{
// for (int i = 0; i < AllForceAbilities.Count; i++)
// {
// yield return AllForceAbilities[i].GetGizmo();
// }
public override IEnumerable<Gizmo> CompGetGizmosExtra()
{
for (int i = 0; i < this.AllPowers.Count; i++)
{
if (this.AllPowers[i] is ForceAbility p) yield return p.GetGizmo();
}

//}
}

#region Levels
public int ForceUserLevel
Expand Down
53 changes: 36 additions & 17 deletions Source/ProjectJedi/ForceAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ProjectJedi
{
public class ForceAbility : PawnAbility
{
public CompForceUser ForceUser => AbilityUser as CompForceUser;
public CompForceUser ForceUser => ForceUserUtility.GetForceUser(this.Pawn);
public ForceAbilityDef ForceDef => Def as ForceAbilityDef;

public ForceAbility() : base()
Expand Down Expand Up @@ -51,31 +51,44 @@ public override void PostAbilityAttempt()
/// <returns></returns>
public override string PostAbilityVerbCompDesc(VerbProperties_Ability verbDef)
{
//Log.Message("1");
string result = "";
StringBuilder postDesc = new StringBuilder();
ForceAbilityDef forceDef = (ForceAbilityDef)verbDef.abilityDef;
if (forceDef != null)
if (verbDef == null) return result;
if (verbDef?.abilityDef is ForceAbilityDef forceDef)
{
//Log.Message("2");

StringBuilder postDesc = new StringBuilder();
string alignDesc = "";
string changeDesc = "";
string pointsDesc = "";
if (forceDef.changedAlignmentType != ForceAlignmentType.None)
//Log.Message("3");

if (forceDef?.changedAlignmentType != ForceAlignmentType.None)
{
//Log.Message("3a");

alignDesc = "ForceAbilityDescAlign".Translate(new object[]
{
forceDef.requiredAlignmentType.ToString(),
});
}
if (forceDef.changedAlignmentType != ForceAlignmentType.None)
//Log.Message("4");

if (forceDef?.changedAlignmentType != ForceAlignmentType.None)
{
//Log.Message("4a");
changeDesc = "ForceAbilityDescChange".Translate(new object[]
{
forceDef.changedAlignmentType.ToString(),
Mathf.Abs(forceDef.changedAlignmentRate).ToString("0.##")
});
}
if (ForceUser.ForceSkillLevel("PJ_ForcePool") > 0)
//Log.Message("5");

if (ForceUser?.ForceSkillLevel("PJ_ForcePool") > 0)
{
//Log.Message("5a");
float poolCost = 0f;
//Log.Message("PC" + forceDef.forcePoolCost.ToString());
poolCost = forceDef.forcePoolCost - (forceDef.forcePoolCost * (0.15f * (float)ForceUser.ForceSkillLevel("PJ_ForcePool")));
Expand All @@ -94,15 +107,21 @@ public override string PostAbilityVerbCompDesc(VerbProperties_Ability verbDef)
}
else
{
//Log.Message("6");

pointsDesc = "ForceAbilityDescPoints".Translate(new object[]
{
Mathf.Abs(forceDef.forcePoolCost).ToString("0.##")
});
}
//Log.Message("7");

if (alignDesc != "") postDesc.AppendLine(alignDesc);
if (changeDesc != "") postDesc.AppendLine(changeDesc);
if (pointsDesc != "") postDesc.AppendLine(pointsDesc);
result = postDesc.ToString();
//Log.Message("8");

}
return result;
}
Expand All @@ -112,32 +131,32 @@ public override bool CanCastPowerCheck(AbilityContext context, out string reason
if (base.CanCastPowerCheck(context, out reason))
{
reason = "";
if (ForceDef != null)
if (this.Def != null && this.Def is ForceAbilityDef forceDef)
{
if (ForceDef.requiredAlignmentType != ForceAlignmentType.None)
if (forceDef?.requiredAlignmentType != ForceAlignmentType.None)
{
if (ForceDef.requiredAlignmentType != ForceUser.ForceAlignmentType)
if (forceDef?.requiredAlignmentType != ForceUserUtility.GetForceAlignmentType(Pawn))
{
reason = "PJ_WrongAlignment".Translate(this.Pawn.LabelShort);
return false;
}
}
if (ForceUser.ForcePool != null)
if (ForceUser?.ForcePool != null)
{
if (ForceDef.forcePoolCost > 0 &&
ActualForceCost > ForceUser.ForcePool.CurLevel)
if (forceDef?.forcePoolCost > 0 &&
ActualForceCost > ForceUserUtility.GetForcePool(this.Pawn)?.CurLevel)
{
reason = "PJ_DrainedForcePool".Translate(this.Pawn.LabelShort);
return false;
}
}
if (this.AbilityUser.AbilityUser != null)
if (this.AbilityUser?.AbilityUser != null)
{
if (this.AbilityUser.AbilityUser.apparel != null)
if (this.AbilityUser?.AbilityUser?.apparel != null)
{
if (this.AbilityUser.AbilityUser.apparel.WornApparel != null && this.AbilityUser.AbilityUser.apparel.WornApparelCount > 0)
if (this.AbilityUser?.AbilityUser?.apparel?.WornApparel != null && this.AbilityUser?.AbilityUser?.apparel?.WornApparelCount > 0)
{
if (this.AbilityUser.AbilityUser.apparel.WornApparel.FirstOrDefault((Apparel x) => x.def == ThingDefOf.Apparel_ShieldBelt) != null)
if (this.AbilityUser?.AbilityUser?.apparel?.WornApparel?.FirstOrDefault((Apparel x) => x.def == ThingDefOf.Apparel_ShieldBelt) != null)
{
reason = "PJ_UsingShieldBelt".Translate(this.Pawn.LabelShort);
return false;
Expand Down
38 changes: 38 additions & 0 deletions Source/ProjectJedi/ForceUserUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;

namespace ProjectJedi
{
static class ForceUserUtility
{
public static ForceAlignmentType GetForceAlignmentType(Pawn pawn)
{
if (pawn.GetComp<CompForceUser>() is CompForceUser forceUser)
{
return forceUser.ForceAlignmentType;
}
return ForceAlignmentType.None;
}

public static Need_ForcePool GetForcePool(Pawn pawn)
{
if (pawn.GetComp<CompForceUser>() is CompForceUser forceUser)
{
return forceUser.ForcePool;
}
return null;
}

public static CompForceUser GetForceUser(Pawn pawn)
{
if (pawn.GetComp<CompForceUser>() is CompForceUser forceUser)
{
return forceUser;
}
return null;
}
}
}
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@

[assembly: Guid("a8e081b6-8768-4fe9-817f-f0ee42cf13ef")]

[assembly: AssemblyVersion("1.17.4.1")]
[assembly: AssemblyFileVersion("1.17.4.1")]
[assembly: AssemblyVersion("1.17.5.0")]
[assembly: AssemblyFileVersion("1.17.5.0")]
2 changes: 1 addition & 1 deletion Source/obj/Debug/CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
713d26f9b754e8053dca6bab05e353da8b4845bc
73818957258032a2f06ef1db41d0b61652f9432e
Binary file not shown.
Binary file modified Source/obj/Debug/ProjectJedi.dll
Binary file not shown.

0 comments on commit a4f97d7

Please sign in to comment.