NSMoverEntity: add 'movedir' key support for Source Engine based maps

This commit is contained in:
Marco Cawthorne 2023-09-26 22:24:13 -07:00
parent 01a7ffa56f
commit 49408b1342
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 38 additions and 8 deletions

View file

@ -103,6 +103,7 @@ public:
#ifdef SERVER #ifdef SERVER
virtual void Save(float); virtual void Save(float);
virtual void Restore(string, string); virtual void Restore(string, string);
virtual void SpawnKey(string, string);
#endif #endif
private: private:
@ -113,6 +114,8 @@ private:
moverState_t m_moverState; moverState_t m_moverState;
moverType_t m_moverType; moverType_t m_moverType;
int m_iPortalState; int m_iPortalState;
vector m_vecMoveDir; /* movedir override from Source */
bool m_bUseMoveDir;
nonvirtual void _PortalOpen(void); nonvirtual void _PortalOpen(void);
nonvirtual void _PortalClose(void); nonvirtual void _PortalClose(void);

View file

@ -24,9 +24,23 @@ NSMoverEntity::NSMoverEntity(void)
m_moverState = MOVER_POS1; m_moverState = MOVER_POS1;
m_moverType = MOVERTYPE_LINEAR; m_moverType = MOVERTYPE_LINEAR;
m_iPortalState = 0i; m_iPortalState = 0i;
m_bUseMoveDir = false;
} }
#ifdef SERVER #ifdef SERVER
void
NSMoverEntity::SpawnKey(string strKey, string strValue)
{
switch (strKey) {
case "movedir":
m_vecMoveDir = ReadVector(strValue);
m_bUseMoveDir = true;
break;
default:
super::Restore(strKey, strValue);
}
}
void void
NSMoverEntity::Save(float handle) NSMoverEntity::Save(float handle)
{ {
@ -39,6 +53,8 @@ NSMoverEntity::Save(float handle)
SaveFloat(handle, "m_moverState", m_moverState); SaveFloat(handle, "m_moverState", m_moverState);
SaveFloat(handle, "m_moverType", m_moverType); SaveFloat(handle, "m_moverType", m_moverType);
SaveInt(handle, "m_iPortalState", m_iPortalState); SaveInt(handle, "m_iPortalState", m_iPortalState);
SaveVector(handle, "m_vecMoveDir", m_vecMoveDir);
SaveBool(handle, "m_bUseMoveDir", m_bUseMoveDir);
} }
void void
@ -66,6 +82,12 @@ NSMoverEntity::Restore(string strKey, string strValue)
case "m_iPortalState": case "m_iPortalState":
m_iPortalState = ReadInt(strValue); m_iPortalState = ReadInt(strValue);
break; break;
case "m_vecMoveDir":
m_vecMoveDir = ReadVector(strValue);
break;
case "m_bUseMoveDir":
m_bUseMoveDir = ReadBool(strValue);
break;
default: default:
super::Restore(strKey, strValue); super::Restore(strKey, strValue);
} }
@ -78,6 +100,10 @@ NSMoverEntity::GetDirectionalPosition(vector vecAngle, float flLip)
vector vecMoveDir = g_vec_null; vector vecMoveDir = g_vec_null;
vector vecPos = g_vec_null; vector vecPos = g_vec_null;
if (m_bUseMoveDir == true) {
makevectors(m_vecMoveDir);
vecMoveDir = v_forward;
} else {
/* editor angle */ /* editor angle */
if (vecAngle == [0,-1,0]) { if (vecAngle == [0,-1,0]) {
vecMoveDir = [0,0,1]; vecMoveDir = [0,0,1];
@ -88,6 +114,7 @@ NSMoverEntity::GetDirectionalPosition(vector vecAngle, float flLip)
makevectors(vecAngle); makevectors(vecAngle);
vecMoveDir = v_forward; vecMoveDir = v_forward;
} }
}
vecPos = (GetOrigin() + vecMoveDir * (fabs(vecMoveDir * size) - flLip)); vecPos = (GetOrigin() + vecMoveDir * (fabs(vecMoveDir * size) - flLip));
return vecPos; return vecPos;