Add R_CustomShadowZ, Obj_FakeShadowZ, Obj_HyudoroShadowZ; let Hyudoro shadow float while patrolling

This commit is contained in:
James R. 2023-09-17 21:44:42 -07:00
parent 25837afc8c
commit 5c1332f977
6 changed files with 97 additions and 0 deletions

View file

@ -17,6 +17,7 @@ void Obj_HyudoroDeploy(mobj_t *master);
void Obj_HyudoroThink(mobj_t *actor);
void Obj_HyudoroCenterThink(mobj_t *actor);
void Obj_HyudoroCollide(mobj_t *special, mobj_t *toucher);
boolean Obj_HyudoroShadowZ(mobj_t *actor, fixed_t *return_z, pslope_t **return_slope);
/* Garden Top */
void Obj_GardenTopDeploy(mobj_t *rider);
@ -218,6 +219,7 @@ void Obj_SetEmeraldAwardee(mobj_t *emerald, mobj_t *awardee);
/* Fake Shadow */
mobj_t *Obj_SpawnFakeShadow(mobj_t *from);
void Obj_FakeShadowThink(mobj_t *shadow);
boolean Obj_FakeShadowZ(const mobj_t *shadow, fixed_t *return_z, pslope_t **return_slope);
/* Checkpoints */
void Obj_ResetCheckpoints(void);

View file

@ -882,3 +882,21 @@ Obj_HyudoroCollide
break;
}
}
boolean
Obj_HyudoroShadowZ
( mobj_t * hyu,
fixed_t * return_z,
pslope_t ** return_slope)
{
if (hyudoro_mode(hyu) != HYU_PATROL)
return false;
if (P_MobjWasRemoved(hyudoro_center(hyu)))
return false;
*return_z = hyu->z;
*return_slope = hyudoro_center(hyu)->standingslope;
return true;
}

View file

@ -1,3 +1,6 @@
#include <optional>
#include <utility>
#include "../info.h"
#include "../k_objects.h"
#include "../p_local.h"
@ -19,6 +22,28 @@ struct Shadow : mobj_t
bool valid() const { return !P_MobjWasRemoved(this) && !P_MobjWasRemoved(follow()); }
std::optional<std::pair<fixed_t, pslope_t*>> z_position() const
{
switch (follow()->type)
{
case MT_HYUDORO: {
fixed_t z;
pslope_t* slope;
if (Obj_HyudoroShadowZ(follow(), &z, &slope))
{
return {{z, slope}};
}
break;
}
default:
break;
}
return {};
}
void destroy() { P_RemoveMobj(this); }
void move()
@ -58,3 +83,27 @@ void Obj_FakeShadowThink(mobj_t* shadow)
x->move();
}
boolean Obj_FakeShadowZ(const mobj_t* shadow, fixed_t* return_z, pslope_t** return_slope)
{
auto x = static_cast<const Shadow*>(shadow);
if (!x->valid())
{
return false;
}
auto pair = x->z_position();
if (!pair)
{
return false;
}
auto [z, slope] = *pair;
*return_z = z;
*return_slope = slope;
return true;
}

View file

@ -10,6 +10,7 @@
#include "d_player.h"
#include "info.h"
#include "k_objects.h"
#include "p_tick.h"
#include "r_splats.h"
#include "r_things.h"
@ -59,3 +60,21 @@ boolean R_SplatSlope(mobj_t* mobj, vector3_t position, pslope_t* slope)
return false;
}
boolean R_CustomShadowZ(mobj_t* thing, fixed_t *z, pslope_t** slope)
{
switch (thing->type)
{
case MT_SHADOW:
if (Obj_FakeShadowZ(thing, z, slope))
{
return true;
}
break;
default:
break;
}
return false;
}

View file

@ -1315,6 +1315,14 @@ fixed_t R_GetShadowZ(
sector_t *sector;
ffloor_t *rover;
if (R_CustomShadowZ(thing, &groundz, &groundslope))
{
if (shadowslope != NULL)
*shadowslope = groundslope;
return groundz;
}
// for frame interpolation
interpmobjstate_t interp = {0};

View file

@ -95,6 +95,7 @@ boolean R_ThingIsFlashing(mobj_t *thing);
INT32 R_ThingLightLevel(mobj_t *thing);
boolean R_SplatSlope(mobj_t *thing, vector3_t position, pslope_t *slope);
boolean R_CustomShadowZ(mobj_t *thing, fixed_t *return_z, pslope_t **return_slope);
// --------------
// MASKED DRAWING