NSClient: add new method Transport(vector newPos, vector newAngles) and null out .customphysics when an NSEntity gets Destroy()d

This commit is contained in:
Marco Cawthorne 2023-04-18 14:47:39 -07:00
parent 7f55f1c868
commit 97a5d9d2cd
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 19 additions and 0 deletions

View File

@ -361,6 +361,8 @@ public:
/** Returns the absolute timestamp of when the entity had been spawned. */
nonvirtual float GetSpawnTime(void);
/** Move the entity to a new position, with updated angles. */
nonvirtual void Transport(vector, vector);
};
#ifdef CLIENT

View File

@ -798,6 +798,7 @@ void NSEntity::OnRemoveEntity( void ) {
void NSEntity::Destroy( void ) {
removed = 1; /* mark this as cleanly removed */
OnRemoveEntity();
customphysics = __NULL__;
ScheduleThink(Util_Destroy, 0.0f );
}
@ -912,6 +913,22 @@ NSEntity::GetSpawnTime(void)
return m_flSpawnTime;
}
void
NSEntity::Transport(vector new_pos, vector new_ang)
{
float flSpeed = vlen(this.GetVelocity());
makevectors(new_ang);
SetVelocity(v_forward * flSpeed);
SetOrigin(new_pos);
SetAngles(new_ang);
#ifdef SERVER
if (flags & FL_CLIENT)
Client_FixAngle(this, new_ang);
#endif
}
#ifdef CLIENT
void
NSEntity_ReadEntity(bool new)