GS-EntBase: add PortalOpen/Close methods to func_door and func_door_rotating
which keeps track of our areaportal state more reliably.
This commit is contained in:
parent
8bfd7d24ec
commit
fe15241b2d
3 changed files with 91 additions and 37 deletions
|
@ -85,6 +85,7 @@ class func_door:NSRenderableEntity
|
|||
float m_flDelay;
|
||||
int m_iDamage;
|
||||
int m_iLocked;
|
||||
int m_iPortalState;
|
||||
|
||||
float m_flSoundWait;
|
||||
string m_strLockedSfx;
|
||||
|
@ -96,6 +97,8 @@ class func_door:NSRenderableEntity
|
|||
|
||||
void(void) func_door;
|
||||
|
||||
virtual void(void) PortalOpen;
|
||||
virtual void(void) PortalClose;
|
||||
virtual void(void) SetMovementDirection;
|
||||
virtual void(vector, void(void) func) MoveToDestination;
|
||||
virtual void(void) MoveAway;
|
||||
|
@ -110,6 +113,27 @@ class func_door:NSRenderableEntity
|
|||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
void
|
||||
func_door::PortalOpen(void)
|
||||
{
|
||||
if (m_iPortalState == 1)
|
||||
return;
|
||||
|
||||
m_iPortalState = 1;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
}
|
||||
void
|
||||
func_door::PortalClose(void)
|
||||
{
|
||||
if (m_iPortalState == 0)
|
||||
return;
|
||||
|
||||
m_iPortalState = 0;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
}
|
||||
|
||||
void
|
||||
func_door::Use(void)
|
||||
{
|
||||
|
@ -171,9 +195,7 @@ func_door::Returned(void)
|
|||
}
|
||||
|
||||
m_iState = DOORSTATE_LOWERED;
|
||||
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
PortalClose();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -217,8 +239,7 @@ func_door::MoveAway(void)
|
|||
m_iValue = 1;
|
||||
m_iState = DOORSTATE_UP;
|
||||
MoveToDestination(m_vecPos2, Arrived);
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
PortalOpen();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -399,11 +420,9 @@ func_door::Respawn(void)
|
|||
m_vecPos2 = m_vecPos1;
|
||||
m_vecPos1 = origin;
|
||||
m_iValue = 1;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
PortalOpen();
|
||||
} else {
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
PortalClose();
|
||||
}
|
||||
|
||||
if (targetname) {
|
||||
|
|
|
@ -90,8 +90,12 @@ class func_door_rotating:NSRenderableEntity
|
|||
vector m_vecPos1;
|
||||
vector m_vecPos2;
|
||||
vector m_vecMoveDir;
|
||||
int m_iPortalState;
|
||||
|
||||
void(void) func_door_rotating;
|
||||
|
||||
virtual void(void) PortalOpen;
|
||||
virtual void(void) PortalClose;
|
||||
virtual void(void) Respawn;
|
||||
virtual void(void) Arrived;
|
||||
virtual void(void) Returned;
|
||||
|
@ -110,8 +114,30 @@ class func_door_rotating:NSRenderableEntity
|
|||
#endif
|
||||
};
|
||||
|
||||
void
|
||||
func_door_rotating::PortalOpen(void)
|
||||
{
|
||||
if (m_iPortalState == 1)
|
||||
return;
|
||||
|
||||
m_iPortalState = 1;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
}
|
||||
void
|
||||
func_door_rotating::PortalClose(void)
|
||||
{
|
||||
if (m_iPortalState == 0)
|
||||
return;
|
||||
|
||||
m_iPortalState = 0;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
}
|
||||
|
||||
#ifdef GS_PHYSICS
|
||||
void func_door_rotating::Unhinge(void)
|
||||
void
|
||||
func_door_rotating::Unhinge(void)
|
||||
{
|
||||
takedamage = DAMAGE_NO;
|
||||
touch = think = __NULL__;
|
||||
|
@ -121,7 +147,8 @@ void func_door_rotating::Unhinge(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void func_door_rotating::Arrived(void)
|
||||
void
|
||||
func_door_rotating::Arrived(void)
|
||||
{
|
||||
SetAngles(m_vecDest);
|
||||
avelocity = [0,0,0];
|
||||
|
@ -146,7 +173,8 @@ void func_door_rotating::Arrived(void)
|
|||
nextthink = (ltime + m_flWait);
|
||||
}
|
||||
|
||||
void func_door_rotating::Returned(void)
|
||||
void
|
||||
func_door_rotating::Returned(void)
|
||||
{
|
||||
SetAngles(m_vecDest);
|
||||
avelocity = [0,0,0];
|
||||
|
@ -172,11 +200,11 @@ void func_door_rotating::Returned(void)
|
|||
|
||||
m_iState = STATE_LOWERED;
|
||||
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
PortalClose();
|
||||
}
|
||||
|
||||
void func_door_rotating::Back(void)
|
||||
void
|
||||
func_door_rotating::Back(void)
|
||||
{
|
||||
if (!(spawnflags & SF_DOOR_SILENT)) {
|
||||
|
||||
|
@ -195,7 +223,8 @@ void func_door_rotating::Back(void)
|
|||
RotToDest(m_vecPos1, Returned);
|
||||
}
|
||||
|
||||
void func_door_rotating::Away(void)
|
||||
void
|
||||
func_door_rotating::Away(void)
|
||||
{
|
||||
float fDirection = 1.0;
|
||||
|
||||
|
@ -235,11 +264,11 @@ void func_door_rotating::Away(void)
|
|||
}
|
||||
RotToDest(m_vecPos2 * fDirection, Arrived);
|
||||
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
PortalOpen();
|
||||
}
|
||||
|
||||
void func_door_rotating::Trigger(entity act, int state)
|
||||
void
|
||||
func_door_rotating::Trigger(entity act, int state)
|
||||
{
|
||||
if (GetMaster() == FALSE) {
|
||||
return;
|
||||
|
@ -267,13 +296,15 @@ void func_door_rotating::Trigger(entity act, int state)
|
|||
UseTargets(act, TRIG_TOGGLE, m_flDelay);
|
||||
}
|
||||
|
||||
void func_door_rotating::Use(void)
|
||||
void
|
||||
func_door_rotating::Use(void)
|
||||
{
|
||||
eActivator.flags &= ~FL_USE_RELEASED;
|
||||
Trigger(eActivator, TRIG_TOGGLE);
|
||||
}
|
||||
|
||||
void func_door_rotating::Touch(void)
|
||||
void
|
||||
func_door_rotating::Touch(void)
|
||||
{
|
||||
if (m_iLocked || !GetMaster()) {
|
||||
if (m_flSoundWait < time)
|
||||
|
@ -295,7 +326,8 @@ void func_door_rotating::Touch(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::Blocked(void)
|
||||
void
|
||||
func_door_rotating::Blocked(void)
|
||||
{
|
||||
if (m_iDamage) {
|
||||
Damage_Apply(other, this, m_iDamage, 0, DMG_CRUSH);
|
||||
|
@ -310,7 +342,8 @@ void func_door_rotating::Blocked(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::SetMovementDirection(void)
|
||||
void
|
||||
func_door_rotating::SetMovementDirection(void)
|
||||
{
|
||||
if (spawnflags & SF_ROT_ZAXIS) {
|
||||
m_vecMoveDir = [0,0,1];
|
||||
|
@ -321,7 +354,8 @@ void func_door_rotating::SetMovementDirection(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
|
||||
void
|
||||
func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
|
||||
{
|
||||
vector vecAngleDifference;
|
||||
float flTravelLength, flTravelTime;
|
||||
|
@ -348,7 +382,8 @@ void func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::Respawn(void)
|
||||
void
|
||||
func_door_rotating::Respawn(void)
|
||||
{
|
||||
func_door_rotating::SetMovementDirection();
|
||||
|
||||
|
@ -380,7 +415,6 @@ void func_door_rotating::Respawn(void)
|
|||
PlayerUse = __NULL__;
|
||||
}
|
||||
|
||||
m_iState = STATE_LOWERED;
|
||||
m_vecPos1 = GetSpawnAngles();
|
||||
|
||||
if (spawnflags & SF_ROT_BACKWARDS) {
|
||||
|
@ -394,11 +428,9 @@ void func_door_rotating::Respawn(void)
|
|||
m_vecPos2 = m_vecPos1;
|
||||
m_vecPos1 = vTemp;
|
||||
m_vecMoveDir = m_vecMoveDir * -1;
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_OPEN);
|
||||
PortalOpen();
|
||||
} else {
|
||||
setorigin(this, origin);
|
||||
openportal(this, AREAPORTAL_CLOSED);
|
||||
PortalClose();
|
||||
}
|
||||
|
||||
if (spawnflags & SF_ROT_PASSABLE) {
|
||||
|
@ -466,7 +498,8 @@ func_door_rotating::SpawnKey(string strKey, string strValue)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::func_door_rotating(void)
|
||||
void
|
||||
func_door_rotating::func_door_rotating(void)
|
||||
{
|
||||
m_flSpeed = 100;
|
||||
m_flDelay = 4;
|
||||
|
|
|
@ -351,16 +351,18 @@ NSEntity::Respawn(void)
|
|||
void
|
||||
NSEntity::Save(float handle)
|
||||
{
|
||||
SaveVector(handle, "origin", origin);
|
||||
SaveVector(handle, "absmin", absmin);
|
||||
SaveVector(handle, "absmax", absmax);
|
||||
SaveVector(handle, "mins", mins);
|
||||
SaveVector(handle, "maxs", maxs);
|
||||
SaveString(handle, "model", model);
|
||||
SaveVector(handle, "angles", angles);
|
||||
SaveFloat(handle, "solid", solid);
|
||||
SaveFloat(handle, "movetype", movetype);
|
||||
SaveFloat(handle, "health", health);
|
||||
SaveFloat(handle, "pvsflags", pvsflags);
|
||||
SaveVector(handle, "mins", mins);
|
||||
SaveVector(handle, "maxs", maxs);
|
||||
SaveVector(handle, "origin", origin);
|
||||
SaveVector(handle, "angles", angles);
|
||||
SaveString(handle, "parentname", m_parent);
|
||||
SaveString(handle, "model", model);
|
||||
SaveFloat(handle, "pvsflags", pvsflags);
|
||||
super::Save(handle);
|
||||
}
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue