Added CanCrossLine virtual for actors.

- Called last after all other line checks occur. Returning false means the actor cannot cross that line.
This commit is contained in:
Major Cooke 2020-09-27 16:15:58 -05:00 committed by Christoph Oelckers
parent a98c1efc26
commit b5b2dd0903
2 changed files with 45 additions and 0 deletions

View file

@ -155,6 +155,38 @@ bool P_CanCollideWith(AActor *tmthing, AActor *thing)
return true;
}
//==========================================================================
//
// CanCrossLine
//
// Checks if an actor can cross a line after all checks are processed.
// If false, the line blocks them.
//==========================================================================
bool P_CanCrossLine(AActor *mo, line_t *line, int side)
{
static unsigned VIndex = ~0u;
if (VIndex == ~0u)
{
VIndex = GetVirtualIndex(RUNTIME_CLASS(AActor), "CanCrossLine");
assert(VIndex != ~0u);
}
VMValue params[4] = { mo, line, side, false };
VMReturn ret;
int retval;
ret.IntAt(&retval);
auto clss = mo->GetClass();
VMFunction *func = clss->Virtuals.Size() > VIndex ? clss->Virtuals[VIndex] : nullptr;
if (func != nullptr)
{
VMCall(func, params, 4, &ret, 1);
return retval;
}
return true;
}
//==========================================================================
//
// FindRefPoint
@ -953,6 +985,13 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
}
}
if (!P_CanCrossLine(tm.thing, ld, P_PointOnLineSide(cres.Position, ld)))
{
if (wasfit)
tm.thing->BlockingLine = ld;
return false;
}
// If the floor planes on both sides match we should recalculate open.bottom at the actual position we are checking
// This is to avoid bumpy movement when crossing a linedef with the same slope on both sides.
// This should never narrow down the opening, though, only widen it.

View file

@ -502,6 +502,12 @@ class Actor : Thinker native
return true;
}
// Called by PIT_CheckLine to check if an actor can cross a line.
virtual bool CanCrossLine(Line crossing, int side)
{
return true;
}
// Called by revival/resurrection to check if one can resurrect the other.
// "other" can be null when not passive.
virtual bool CanResurrect(Actor other, bool passive)