Skip to content

Commit

Permalink
VPE collision improvment (for recent commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDorob committed Oct 10, 2023
1 parent 832706c commit d0d16cb
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Source/CombatExtended/Compatibility/VanillaPsycastExpanded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ public IEnumerable<string> GetCompatList()
}
public void Install()
{
//BlockerRegistry.RegisterImpactSomethingCallback(ImpactSomething); //temp commented
BlockerRegistry.RegisterImpactSomethingCallback(ImpactSomething); //temp commented
BlockerRegistry.RegisterBeforeCollideWithCallback(BeforeCollideWith);
BlockerRegistry.RegisterCheckForCollisionCallback(Hediff_Overshield_InterceptCheck);
BlockerRegistry.RegisterCheckForCollisionBetweenCallback(AOE_CheckIntercept);
}

private static bool BeforeCollideWith(ProjectileCE projectile, Thing collideWith)
{
if (collideWith is Pawn pawn)
{
var interceptor = pawn.health.hediffSet.hediffs.FirstOrDefault(x => x.GetType() == typeof(Hediff_Overshield)) as Hediff_Overshield;
if (interceptor != null)
{
OnIntercepted(interceptor, projectile);
return true;
}
}
return false;
}
private static bool ImpactSomething(ProjectileCE projectile, Thing launcher)
{
return Hediff_Overshield_InterceptCheck(projectile, projectile.ExactPosition.ToIntVec3(), launcher);
Expand All @@ -41,11 +55,8 @@ public static bool Hediff_Overshield_InterceptCheck(ProjectileCE projectile, Int
.SelectMany(x => x.health.hediffSet.hediffs)
.Where(x => x.GetType() == typeof(Hediff_Overshield)).Cast<Hediff_Overshield>())
{

var def = projectile.def;
Vector3 lastExactPos = projectile.LastPos;
var newExactPos = projectile.ExactPosition;
var result = interceptor.pawn != launcher && (interceptor.pawn.Position == cell || PreventTryColideWithPawn(projectile, interceptor.pawn, newExactPos));
var result = interceptor.pawn != launcher && (interceptor.pawn.Position == cell);
if (result)
{
OnIntercepted(interceptor, projectile);
Expand Down

0 comments on commit d0d16cb

Please sign in to comment.