Move touch handlers into NSTrigger, remove trigger_multiple's own version of the team check.
This commit is contained in:
parent
31bb9b4042
commit
5a7d082af7
9 changed files with 162 additions and 159 deletions
|
@ -162,12 +162,6 @@ trigger_multiple::Touch(entity eToucher)
|
||||||
if (!HasSpawnFlags(TM_PUSHABLES) && eToucher.classname == "func_pushable")
|
if (!HasSpawnFlags(TM_PUSHABLES) && eToucher.classname == "func_pushable")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_grMode.IsTeamplay() == TRUE) {
|
|
||||||
if (m_iTeam > 0 && eActivator.team != m_iTeam + 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if the target key isn't used, assume we're using the new I/O system */
|
/* if the target key isn't used, assume we're using the new I/O system */
|
||||||
if (HasTriggerTarget() == false)
|
if (HasTriggerTarget() == false)
|
||||||
UseOutput(eToucher, m_strOnStartTouch);
|
UseOutput(eToucher, m_strOnStartTouch);
|
||||||
|
|
|
@ -738,15 +738,7 @@ func_vehicle::Physics(void)
|
||||||
//crossprint(sprintf("Driver: %s\n", GetDriver().classname));
|
//crossprint(sprintf("Driver: %s\n", GetDriver().classname));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SERVER
|
HandleThink();
|
||||||
/* support for think/nextthink */
|
|
||||||
if (think && nextthink > 0.0f) {
|
|
||||||
if (nextthink < time) {
|
|
||||||
nextthink = 0.0f;
|
|
||||||
think();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -153,15 +153,7 @@ prop_vehicle_driveable::Physics(void)
|
||||||
//crossprint(sprintf("Driver: %s\n", GetDriver().classname));
|
//crossprint(sprintf("Driver: %s\n", GetDriver().classname));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SERVER
|
HandleThink();
|
||||||
/* support for think/nextthink */
|
|
||||||
if (think && nextthink > 0.0f) {
|
|
||||||
if (nextthink < time) {
|
|
||||||
nextthink = 0.0f;
|
|
||||||
think();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -72,11 +72,6 @@ class NSEntity:NSTrigger
|
||||||
PREDICTED_VECTOR_N(velocity);
|
PREDICTED_VECTOR_N(velocity);
|
||||||
PREDICTED_VECTOR_N(avelocity);
|
PREDICTED_VECTOR_N(avelocity);
|
||||||
|
|
||||||
/* not needed to be saved right now */
|
|
||||||
float m_flTouchTime;
|
|
||||||
bool m_beingTouched;
|
|
||||||
entity m_eTouchLast;
|
|
||||||
|
|
||||||
virtual void(void) Spawned;
|
virtual void(void) Spawned;
|
||||||
|
|
||||||
#ifdef CLIENT
|
#ifdef CLIENT
|
||||||
|
@ -203,14 +198,7 @@ class NSEntity:NSTrigger
|
||||||
nonvirtual bool(string, float, float, bool) StartSound;
|
nonvirtual bool(string, float, float, bool) StartSound;
|
||||||
nonvirtual bool(string, float, bool) StartSoundDef;
|
nonvirtual bool(string, float, bool) StartSoundDef;
|
||||||
nonvirtual void(float, bool) StopSound;
|
nonvirtual void(float, bool) StopSound;
|
||||||
nonvirtual float(void) GetTime;
|
|
||||||
|
|
||||||
virtual void(entity) Blocked;
|
|
||||||
virtual void(entity) StartTouch;
|
|
||||||
virtual void(entity) Touch;
|
|
||||||
virtual void(entity) EndTouch;
|
|
||||||
nonvirtual void(void) _TouchHandler;
|
|
||||||
nonvirtual void(void) _BlockedHandler;
|
|
||||||
nonvirtual void(void) HandleThink;
|
nonvirtual void(void) HandleThink;
|
||||||
|
|
||||||
virtual void(void) OnRemoveEntity;
|
virtual void(void) OnRemoveEntity;
|
||||||
|
|
|
@ -24,9 +24,6 @@ client doesn't have to do a whole lot here
|
||||||
void
|
void
|
||||||
NSEntity::NSEntity(void)
|
NSEntity::NSEntity(void)
|
||||||
{
|
{
|
||||||
blocked = _BlockedHandler;
|
|
||||||
touch = _TouchHandler;
|
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
identity = 1;
|
identity = 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,7 +55,7 @@ NSEntity::Spawned(void)
|
||||||
float
|
float
|
||||||
NSEntity::EntIndex(void)
|
NSEntity::EntIndex(void)
|
||||||
{
|
{
|
||||||
return num_for_edict(this);
|
return (num_for_edict(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -80,21 +77,21 @@ vector
|
||||||
NSEntity::GetForward(void)
|
NSEntity::GetForward(void)
|
||||||
{
|
{
|
||||||
makevectors(angles);
|
makevectors(angles);
|
||||||
return v_forward;
|
return (v_forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetRight(void)
|
NSEntity::GetRight(void)
|
||||||
{
|
{
|
||||||
makevectors(angles);
|
makevectors(angles);
|
||||||
return v_right;
|
return (v_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetUp(void)
|
NSEntity::GetUp(void)
|
||||||
{
|
{
|
||||||
makevectors(angles);
|
makevectors(angles);
|
||||||
return v_up;
|
return (v_up);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -108,7 +105,7 @@ Useful on brush entities that have no real 'origin' defined.
|
||||||
vector
|
vector
|
||||||
NSEntity::WorldSpaceCenter(void)
|
NSEntity::WorldSpaceCenter(void)
|
||||||
{
|
{
|
||||||
return absmin + (0.5 * (absmax - absmin));
|
return (absmin + (0.5 * (absmax - absmin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -121,7 +118,7 @@ Returns whether or not the entity is able to see a given position
|
||||||
float
|
float
|
||||||
NSEntity::WaterLevel(void)
|
NSEntity::WaterLevel(void)
|
||||||
{
|
{
|
||||||
return waterlevel;
|
return (waterlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -200,66 +197,16 @@ NSEntity::IsSolid(void)
|
||||||
entity
|
entity
|
||||||
NSEntity::GetGroundEntity(void)
|
NSEntity::GetGroundEntity(void)
|
||||||
{
|
{
|
||||||
return groundentity;
|
return (groundentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NSEntity::CreatedByMap(void)
|
NSEntity::CreatedByMap(void)
|
||||||
{
|
{
|
||||||
return _mapspawned;
|
return (_mapspawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::Blocked(entity eBlocker)
|
|
||||||
{
|
|
||||||
/* To be handled by sub-classes */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::_BlockedHandler(void)
|
|
||||||
{
|
|
||||||
Blocked(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::Touch(entity eToucher)
|
|
||||||
{
|
|
||||||
/* To be handled by sub-classes */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::StartTouch(entity eToucher)
|
|
||||||
{
|
|
||||||
/* To be handled by sub-classes */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::EndTouch(entity eToucher)
|
|
||||||
{
|
|
||||||
/* To be handled by sub-classes */
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
NSEntity::_TouchHandler(void)
|
|
||||||
{
|
|
||||||
#ifdef SERVER
|
|
||||||
if (g_grMode.IsTeamplay())
|
|
||||||
if (m_iTeam > 0i)
|
|
||||||
if (m_iTeam != other.team) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* start touch in case we haven't */
|
|
||||||
if (m_beingTouched != true)
|
|
||||||
StartTouch(other);
|
|
||||||
|
|
||||||
Touch(other);
|
|
||||||
|
|
||||||
m_flTouchTime = GetTime();
|
|
||||||
m_beingTouched = true;
|
|
||||||
m_eTouchLast = other;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CLIENT
|
#ifdef CLIENT
|
||||||
/*
|
/*
|
||||||
|
@ -451,7 +398,7 @@ NSEntity::ParentUpdate(void)
|
||||||
entity
|
entity
|
||||||
NSEntity::GetParent(void)
|
NSEntity::GetParent(void)
|
||||||
{
|
{
|
||||||
return find(world, ::targetname, m_parent);
|
return (find(world, ::targetname, m_parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -680,11 +627,6 @@ NSEntity::SetThink(void(void) func)
|
||||||
think = func;
|
think = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Why do we need to declare this?! */
|
|
||||||
#ifdef CSQC
|
|
||||||
noref .float ltime;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NSEntity::SetNextThink(float fl)
|
NSEntity::SetNextThink(float fl)
|
||||||
{
|
{
|
||||||
|
@ -710,151 +652,151 @@ NSEntity::ScheduleThink(void(void) func, float fl)
|
||||||
vector
|
vector
|
||||||
NSEntity::GetSpawnOrigin(void)
|
NSEntity::GetSpawnOrigin(void)
|
||||||
{
|
{
|
||||||
return m_oldOrigin;
|
return (m_oldOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetSpawnAngles(void)
|
NSEntity::GetSpawnAngles(void)
|
||||||
{
|
{
|
||||||
return m_oldAngle;
|
return (m_oldAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
NSEntity::GetSpawnModel(void)
|
NSEntity::GetSpawnModel(void)
|
||||||
{
|
{
|
||||||
return m_oldModel;
|
return (m_oldModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetEffects(void)
|
NSEntity::GetEffects(void)
|
||||||
{
|
{
|
||||||
return effects;
|
return (effects);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetFrame(void)
|
NSEntity::GetFrame(void)
|
||||||
{
|
{
|
||||||
return frame;
|
return (frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetSkin(void)
|
NSEntity::GetSkin(void)
|
||||||
{
|
{
|
||||||
return skin;
|
return (skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetScale(void)
|
NSEntity::GetScale(void)
|
||||||
{
|
{
|
||||||
return scale;
|
return (scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity
|
entity
|
||||||
NSEntity::GetOwner(void)
|
NSEntity::GetOwner(void)
|
||||||
{
|
{
|
||||||
return owner;
|
return (owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetVelocity(void)
|
NSEntity::GetVelocity(void)
|
||||||
{
|
{
|
||||||
return velocity;
|
return (velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetSolid(void)
|
NSEntity::GetSolid(void)
|
||||||
{
|
{
|
||||||
return solid;
|
return (solid);
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
NSEntity::GetModel(void)
|
NSEntity::GetModel(void)
|
||||||
{
|
{
|
||||||
return model;
|
return (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetModelindex(void)
|
NSEntity::GetModelindex(void)
|
||||||
{
|
{
|
||||||
return modelindex;
|
return (modelindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetMovetype(void)
|
NSEntity::GetMovetype(void)
|
||||||
{
|
{
|
||||||
return movetype;
|
return (movetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetGravity(void)
|
NSEntity::GetGravity(void)
|
||||||
{
|
{
|
||||||
return gravity;
|
return (gravity);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetAngles(void)
|
NSEntity::GetAngles(void)
|
||||||
{
|
{
|
||||||
return angles;
|
return (angles);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetAngularVelocity(void)
|
NSEntity::GetAngularVelocity(void)
|
||||||
{
|
{
|
||||||
return avelocity;
|
return (avelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetOrigin(void)
|
NSEntity::GetOrigin(void)
|
||||||
{
|
{
|
||||||
return origin;
|
return (origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetMins(void)
|
NSEntity::GetMins(void)
|
||||||
{
|
{
|
||||||
return mins;
|
return (mins);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetMaxs(void)
|
NSEntity::GetMaxs(void)
|
||||||
{
|
{
|
||||||
return maxs;
|
return (maxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetRealMins(void)
|
NSEntity::GetRealMins(void)
|
||||||
{
|
{
|
||||||
return m_vecMins;
|
return (m_vecMins);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetRealMaxs(void)
|
NSEntity::GetRealMaxs(void)
|
||||||
{
|
{
|
||||||
return m_vecMaxs;
|
return (m_vecMaxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetAbsoluteMins(void)
|
NSEntity::GetAbsoluteMins(void)
|
||||||
{
|
{
|
||||||
return absmin;
|
return (absmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector
|
vector
|
||||||
NSEntity::GetAbsoluteMaxs(void)
|
NSEntity::GetAbsoluteMaxs(void)
|
||||||
{
|
{
|
||||||
return absmax;
|
return (absmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetFlags(void)
|
NSEntity::GetFlags(void)
|
||||||
{
|
{
|
||||||
return flags;
|
return (flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
NSEntity::GetNextThinkTime(void)
|
NSEntity::GetNextThinkTime(void)
|
||||||
{
|
{
|
||||||
return nextthink;
|
return (nextthink);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -886,7 +828,7 @@ NSEntity::Respawn(void)
|
||||||
SetAngles(GetSpawnAngles());
|
SetAngles(GetSpawnAngles());
|
||||||
SetOrigin(GetSpawnOrigin());
|
SetOrigin(GetSpawnOrigin());
|
||||||
SetModel(GetSpawnModel());
|
SetModel(GetSpawnModel());
|
||||||
target = m_oldstrTarget; /* FIXME: Move into NSTrigger::Respawn */
|
SetTriggerTarget(m_oldstrTarget); /* FIXME: Move into NSTrigger::Respawn */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -972,8 +914,7 @@ NSEntity::Input(entity eAct, string strInput, string strData)
|
||||||
{
|
{
|
||||||
switch (strInput) {
|
switch (strInput) {
|
||||||
case "Kill":
|
case "Kill":
|
||||||
think = Util_Destroy;
|
Destroy();
|
||||||
nextthink = GetTime();
|
|
||||||
break;
|
break;
|
||||||
case "KillHierarchy":
|
case "KillHierarchy":
|
||||||
/* this works because ents are basically just entnums */
|
/* this works because ents are basically just entnums */
|
||||||
|
@ -1079,16 +1020,8 @@ through your own hoops. This however will be sufficient 99,99% of the time.
|
||||||
void
|
void
|
||||||
NSEntity::Destroy(void)
|
NSEntity::Destroy(void)
|
||||||
{
|
{
|
||||||
float flTime = GetTime();
|
|
||||||
|
|
||||||
OnRemoveEntity();
|
OnRemoveEntity();
|
||||||
|
ScheduleThink(Util_Destroy, 0.0f);
|
||||||
think = Util_Destroy;
|
|
||||||
|
|
||||||
if (!flTime)
|
|
||||||
nextthink = flTime + 0.01;
|
|
||||||
else
|
|
||||||
nextthink = flTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1126,29 +1059,40 @@ bool
|
||||||
NSEntity::WithinBounds(entity check)
|
NSEntity::WithinBounds(entity check)
|
||||||
{
|
{
|
||||||
if not (check.absmin[0] >= absmin[0] && check.absmax[0] <= absmax[0])
|
if not (check.absmin[0] >= absmin[0] && check.absmax[0] <= absmax[0])
|
||||||
return false;
|
return (false);
|
||||||
if not (check.absmin[1] >= absmin[1] && check.absmax[1] <= absmax[1])
|
if not (check.absmin[1] >= absmin[1] && check.absmax[1] <= absmax[1])
|
||||||
return false;
|
return (false);
|
||||||
if not (check.absmin[2] >= absmin[2] && check.absmax[2] <= absmax[2])
|
if not (check.absmin[2] >= absmin[2] && check.absmax[2] <= absmax[2])
|
||||||
return false;
|
return (false);
|
||||||
|
|
||||||
return true;
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NSEntity::StartSound(string strSample, float channel, float flags, bool broadcast)
|
NSEntity::StartSound(string strSample, float channel, float flags, bool broadcast)
|
||||||
{
|
{
|
||||||
if not (whichpack(strcat("sound/", strSample)))
|
if not (whichpack(strcat("sound/", strSample)))
|
||||||
return false;
|
return (false);
|
||||||
|
|
||||||
|
if (broadcast)
|
||||||
sound(this, channel, strSample, 1.0, ATTN_NORM);
|
sound(this, channel, strSample, 1.0, ATTN_NORM);
|
||||||
return true;
|
else {
|
||||||
|
#ifdef SERVER
|
||||||
|
msg_entity = this;
|
||||||
|
sound(this, channel, strSample, 1.0, ATTN_NORM, 0, SOUNDFLAG_UNICAST);
|
||||||
|
msg_entity = __NULL__;
|
||||||
|
#else
|
||||||
|
sound(this, channel, strSample, 1.0, ATTN_NORM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NSEntity::StartSoundDef(string strSample, float channel, bool broadcast)
|
NSEntity::StartSoundDef(string strSample, float channel, bool broadcast)
|
||||||
{
|
{
|
||||||
Sound_Play(this, channel, strSample);
|
Sound_Play(this, channel, strSample);
|
||||||
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1168,9 +1112,3 @@ NSEntity::HandleThink(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
|
||||||
NSEntity::GetTime(void)
|
|
||||||
{
|
|
||||||
return (movetype == MOVETYPE_PUSH) ? ltime : time;
|
|
||||||
}
|
|
|
@ -34,6 +34,8 @@ class NSIO
|
||||||
/* Handle entity key/value pairs on init */
|
/* Handle entity key/value pairs on init */
|
||||||
virtual void(string, string) SpawnKey;
|
virtual void(string, string) SpawnKey;
|
||||||
|
|
||||||
|
nonvirtual float(void) GetTime;
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
/* Input/Output System */
|
/* Input/Output System */
|
||||||
string m_strOnTrigger;
|
string m_strOnTrigger;
|
||||||
|
|
|
@ -678,3 +678,15 @@ NSIO::SpawnKey(string strKey, string strValue)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: Why do we need to declare this?! */
|
||||||
|
#ifdef CSQC
|
||||||
|
noref .float ltime;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float
|
||||||
|
NSIO::GetTime(void)
|
||||||
|
{
|
||||||
|
return (movetype == MOVETYPE_PUSH) ? ltime : time;
|
||||||
|
}
|
|
@ -35,6 +35,19 @@ class NSTrigger:NSIO
|
||||||
{
|
{
|
||||||
void(void) NSTrigger;
|
void(void) NSTrigger;
|
||||||
|
|
||||||
|
/* not needed to be saved right now */
|
||||||
|
float m_flTouchTime;
|
||||||
|
bool m_beingTouched;
|
||||||
|
entity m_eTouchLast;
|
||||||
|
|
||||||
|
/* touch/blocked */
|
||||||
|
virtual void(entity) Blocked;
|
||||||
|
virtual void(entity) StartTouch;
|
||||||
|
virtual void(entity) Touch;
|
||||||
|
virtual void(entity) EndTouch;
|
||||||
|
nonvirtual void(void) _TouchHandler;
|
||||||
|
nonvirtual void(void) _BlockedHandler;
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
string m_oldstrTarget; /* needed due to trigger_changetarget */
|
string m_oldstrTarget; /* needed due to trigger_changetarget */
|
||||||
|
|
||||||
|
@ -43,7 +56,6 @@ class NSTrigger:NSIO
|
||||||
string m_strMessage;
|
string m_strMessage;
|
||||||
string m_strMaster;
|
string m_strMaster;
|
||||||
int m_iUseType;
|
int m_iUseType;
|
||||||
int m_iTeam;
|
|
||||||
int m_iValue;
|
int m_iValue;
|
||||||
|
|
||||||
/* legacy trigger architecture */
|
/* legacy trigger architecture */
|
||||||
|
@ -60,10 +72,16 @@ class NSTrigger:NSIO
|
||||||
nonvirtual bool(void) HasTriggerTarget;
|
nonvirtual bool(void) HasTriggerTarget;
|
||||||
nonvirtual bool(void) HasTargetname;
|
nonvirtual bool(void) HasTargetname;
|
||||||
|
|
||||||
|
/* team */
|
||||||
|
nonvirtual void(float) SetTeam;
|
||||||
|
nonvirtual float(void) GetTeam;
|
||||||
|
|
||||||
/* overrides */
|
/* overrides */
|
||||||
virtual void(float) Save;
|
virtual void(float) Save;
|
||||||
virtual void(string,string) Restore;
|
virtual void(string,string) Restore;
|
||||||
virtual void(entity, string, string) Input;
|
virtual void(entity, string, string) Input;
|
||||||
|
#else
|
||||||
|
float team;
|
||||||
#endif
|
#endif
|
||||||
virtual void(string, string) SpawnKey;
|
virtual void(string, string) SpawnKey;
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
void
|
void
|
||||||
NSTrigger::NSTrigger(void)
|
NSTrigger::NSTrigger(void)
|
||||||
{
|
{
|
||||||
|
blocked = _BlockedHandler;
|
||||||
|
touch = _TouchHandler;
|
||||||
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
m_oldstrTarget = __NULL__;
|
m_oldstrTarget = __NULL__;
|
||||||
m_strGlobalState = __NULL__;
|
m_strGlobalState = __NULL__;
|
||||||
|
@ -24,7 +27,7 @@ NSTrigger::NSTrigger(void)
|
||||||
m_strMessage = __NULL__;
|
m_strMessage = __NULL__;
|
||||||
m_strMaster = __NULL__;
|
m_strMaster = __NULL__;
|
||||||
m_iUseType = 0i;
|
m_iUseType = 0i;
|
||||||
m_iTeam = 0i;
|
team = 0;
|
||||||
m_iValue = 0i;
|
m_iValue = 0i;
|
||||||
m_flDelay = 0.0f;
|
m_flDelay = 0.0f;
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,7 +178,7 @@ NSTrigger::Save(float handle)
|
||||||
SaveString(handle, "m_strMessage", m_strMessage);
|
SaveString(handle, "m_strMessage", m_strMessage);
|
||||||
SaveString(handle, "m_strMaster", m_strMaster);
|
SaveString(handle, "m_strMaster", m_strMaster);
|
||||||
SaveInt(handle, "m_iUseType", m_iUseType);
|
SaveInt(handle, "m_iUseType", m_iUseType);
|
||||||
SaveInt(handle, "m_iTeam", m_iTeam);
|
SaveFloat(handle, "team", team);
|
||||||
SaveInt(handle, "m_iValue", m_iValue);
|
SaveInt(handle, "m_iValue", m_iValue);
|
||||||
SaveFloat(handle, "m_flDelay", m_flDelay);
|
SaveFloat(handle, "m_flDelay", m_flDelay);
|
||||||
}
|
}
|
||||||
|
@ -201,8 +204,8 @@ NSTrigger::Restore(string strKey, string strValue)
|
||||||
case "m_iUseType":
|
case "m_iUseType":
|
||||||
m_iUseType = ReadInt(strValue);
|
m_iUseType = ReadInt(strValue);
|
||||||
break;
|
break;
|
||||||
case "m_iTeam":
|
case "team":
|
||||||
m_iTeam = ReadInt(strValue);
|
team = ReadFloat(strValue);
|
||||||
break;
|
break;
|
||||||
case "m_iValue":
|
case "m_iValue":
|
||||||
m_iValue = ReadInt(strValue);
|
m_iValue = ReadInt(strValue);
|
||||||
|
@ -243,7 +246,7 @@ NSTrigger::SpawnKey(string strKey, string strValue)
|
||||||
m_strMaster = strValue;
|
m_strMaster = strValue;
|
||||||
break;
|
break;
|
||||||
case "team_no":
|
case "team_no":
|
||||||
m_iTeam = stoi(strValue);
|
team = stof(strValue);
|
||||||
break;
|
break;
|
||||||
case "delay":
|
case "delay":
|
||||||
m_flDelay = stof(strValue);
|
m_flDelay = stof(strValue);
|
||||||
|
@ -257,3 +260,67 @@ NSTrigger::SpawnKey(string strKey, string strValue)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::Blocked(entity eBlocker)
|
||||||
|
{
|
||||||
|
/* To be handled by sub-classes */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::_BlockedHandler(void)
|
||||||
|
{
|
||||||
|
Blocked(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::Touch(entity eToucher)
|
||||||
|
{
|
||||||
|
/* To be handled by sub-classes */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::StartTouch(entity eToucher)
|
||||||
|
{
|
||||||
|
/* To be handled by sub-classes */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::EndTouch(entity eToucher)
|
||||||
|
{
|
||||||
|
/* To be handled by sub-classes */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::_TouchHandler(void)
|
||||||
|
{
|
||||||
|
#ifdef SERVER
|
||||||
|
if (g_grMode.IsTeamplay())
|
||||||
|
if (team > 0i)
|
||||||
|
if (other.team != team) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* start touch in case we haven't */
|
||||||
|
if (m_beingTouched != true)
|
||||||
|
StartTouch(other);
|
||||||
|
|
||||||
|
Touch(other);
|
||||||
|
|
||||||
|
m_flTouchTime = GetTime();
|
||||||
|
m_beingTouched = true;
|
||||||
|
m_eTouchLast = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NSTrigger::SetTeam(float new_team)
|
||||||
|
{
|
||||||
|
team = new_team;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
NSTrigger::GetTeam(void)
|
||||||
|
{
|
||||||
|
return (team);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue