Skip to content

Commit

Permalink
fixed issue involving cooldown not working properly for weapons with …
Browse files Browse the repository at this point in the history
…long bursts
  • Loading branch information
rheirman committed Feb 19, 2019
1 parent 40e7176 commit ea8dca2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
Binary file modified Assemblies/DualWield.dll
Binary file not shown.
4 changes: 3 additions & 1 deletion Source/DualWield/Harmony/Jobdriver_Wait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace DualWield.Harmony
{

[HarmonyPatch(typeof(JobDriver_Wait), "CheckForAutoAttack")]
public class Jobdriver_Wait_CheckForAutoAttack
{
Expand All @@ -30,12 +31,13 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
}
public static bool FullBodyAndOffHandBusy(Pawn_StanceTracker instance)
{
if(instance.pawn.GetStancesOffHand() is Pawn_StanceTracker stOffHand)
if(instance.pawn.GetStancesOffHand() is Pawn_StanceTracker stOffHand && instance.pawn.equipment != null && instance.pawn.equipment.TryGetOffHandEquipment(out ThingWithComps twc))
{
return stOffHand.FullBodyBusy && instance.FullBodyBusy;
}
return instance.FullBodyBusy;
}
}


}
22 changes: 0 additions & 22 deletions Source/DualWield/Harmony/RunAndGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,6 @@ static void Postfix(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance)
//SetStanceOffHand(stanceTracker, stance);
Verb_TryCastNextBurstShot.SetStanceOffHand(stanceTracker, stance);
}
/*
static void SetStanceOffHand(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance)
{
ThingWithComps offHandEquip = null;
CompEquippable compEquippable = null;
Log.Message("calling RunAndGun.SetStanceOffHand");
if (stanceTracker.pawn.equipment != null && stanceTracker.pawn.equipment.TryGetOffHandEquipment(out ThingWithComps result) && result != stanceTracker.pawn.equipment.Primary)
{
offHandEquip = result;
compEquippable = offHandEquip.TryGetComp<CompEquippable>();
}
//Check if verb is one from a offhand weapon.
if (compEquippable != null && stance.verb == compEquippable.PrimaryVerb && stanceTracker.pawn.GetStancesOffHand().curStance is Stance_Warmup_DW)
{
Log.Message("found offhand verb!, setting offhand stance cooldown");
Log.Message("Stance.type: " + stance.GetType().Name);
Log.Message("Stance.ticks: " + stance.ticksLeft);
stanceTracker.pawn.GetStancesOffHand().SetStance(stance);
}
}
*/


//When Run and Gun or the to be patched method isn't found, patch this stub method so no error is thrown.
public static void Stub(Pawn_StanceTracker stanceTracker, Stance_Cooldown stance)
Expand Down
2 changes: 1 addition & 1 deletion Source/DualWield/Harmony/Verb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void SetStanceOffHand(Pawn_StanceTracker stanceTracker, Stance_Co
{
stanceTracker.pawn.GetStancesOffHand().SetStance(stance);
}
else if (!(stanceTracker.curStance is Stance_Cooldown) && stanceTracker.curStance.GetType().Name != "Stance_RunAndGun_Cooldown")
else if (stanceTracker.curStance.GetType().Name != "Stance_RunAndGun_Cooldown")
{
stanceTracker.SetStance(stance);
}
Expand Down

0 comments on commit ea8dca2

Please sign in to comment.