Skip to content

Commit e0f274f

Browse files
authored
Merge pull request #987 from ReactiveDrop/doors-closing-on-face
make doors not try to close when something is in the door area
2 parents 09ba6a0 + fb8f237 commit e0f274f

6 files changed

Lines changed: 36 additions & 3 deletions

File tree

src/game/server/swarm/asw_door.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,13 @@ bool CASW_Door::CheckDoorClear()
605605
return false;
606606
}
607607

608+
// dont try to close when an entity is standing inside any trigger_asw_door_area's that would make the door open
609+
FOR_EACH_VEC( m_AttachedDoorAreas, i )
610+
{
611+
if ( m_AttachedDoorAreas[i]->GetNumTouching() != 0 )
612+
return false;
613+
}
614+
608615
if ( g_debug_doors.GetBool() )
609616
{
610617
NDebugOverlay::Box( vecClosed, m_vecBoundsMin, m_vecBoundsMax, 0, 255, 0, true, 10.0f );

src/game/server/swarm/asw_door.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "entityblocker.h"
55
#include "BasePropDoor.h"
6+
#include "asw_door_area.h"
67
#include "asw_shareddefs.h"
78

89
class CASW_Player;
@@ -152,6 +153,8 @@ class CASW_Door : public CBasePropDoor
152153

153154
void UpdateDoorHealthOnMissionStart( int iDifficulty );
154155

156+
CUtlVector<CASW_Door_Area *> m_AttachedDoorAreas;
157+
155158
private:
156159

157160
float m_fLastFullyWeldedSound;

src/game/server/swarm/asw_door_area.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ CASW_Door_Area::CASW_Door_Area()
2828
m_fNextCutCheck = 0;
2929
}
3030

31+
CASW_Door_Area::~CASW_Door_Area()
32+
{
33+
CASW_Door *pDoor = GetDoor();
34+
if ( pDoor )
35+
{
36+
pDoor->m_AttachedDoorAreas.FindAndRemove( this );
37+
}
38+
}
39+
40+
void CASW_Door_Area::Spawn( void )
41+
{
42+
BaseClass::Spawn();
43+
44+
CASW_Door *pDoor = GetDoor();
45+
if ( pDoor )
46+
{
47+
pDoor->m_AttachedDoorAreas.AddToTail( this );
48+
}
49+
}
50+
3151
bool CASW_Door_Area::HasWelder( CASW_Marine *pMarine )
3252
{
3353
CASW_Weapon *pExtra = pMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA );

src/game/server/swarm/asw_door_area.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class CASW_Door_Area : public CASW_Use_Area
1010
DECLARE_CLASS( CASW_Door_Area, CASW_Use_Area );
1111
public:
1212
CASW_Door_Area();
13+
~CASW_Door_Area();
14+
15+
virtual void Spawn( void );
1316
virtual void ActivateMultiTrigger( CBaseEntity *pActivator );
1417

1518
bool HasWelder( CASW_Marine *pMarine );

src/game/server/triggers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseTrigger, CBaseEntity, "Server-side trigger" )
139139
DEFINE_SCRIPTFUNC( Disable, "Disable the trigger" )
140140
DEFINE_SCRIPTFUNC( Enable, "Enable the trigger" )
141141
DEFINE_SCRIPTFUNC_NAMED( ScriptIsTouching, "IsTouching", "Checks whether the passed entity is touching the trigger." )
142-
DEFINE_SCRIPTFUNC_NAMED( ScriptGetNumTouching, "GetNumTouching", "Gets the number of entities currently touching the trigger." )
142+
DEFINE_SCRIPTFUNC( GetNumTouching, "Gets the number of entities currently touching the trigger." )
143143
DEFINE_SCRIPTFUNC_NAMED( ScriptGetTouching, "GetTouching", "Gets the i'th entity currently touching the trigger." )
144144
END_SCRIPTDESC();
145145

@@ -566,7 +566,7 @@ bool CBaseTrigger::ScriptIsTouching( HSCRIPT entity )
566566
return IsTouching( pOther );
567567
}
568568

569-
int CBaseTrigger::ScriptGetNumTouching()
569+
int CBaseTrigger::GetNumTouching()
570570
{
571571
return m_hTouchingEntities.Count();
572572
}

src/game/server/triggers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class CBaseTrigger : public CBaseToggle
5858

5959
bool IsTouching( CBaseEntity *pOther );
6060
bool ScriptIsTouching( HSCRIPT entity );
61-
int ScriptGetNumTouching();
61+
int GetNumTouching();
6262
HSCRIPT ScriptGetTouching( int i );
6363

6464
CBaseEntity *GetTouchedEntityOfType( const char *sClassName );

0 commit comments

Comments
 (0)