GS-EntBase: Add SetScale(), SetOwner(), SetVelocity() and SetTouch() methods

to NSEntity.
This commit is contained in:
Marco Cawthorne 2022-02-02 10:23:31 -08:00
parent bcf9e2e758
commit 54cf7f8273
Signed by: eukara
GPG key ID: C196CD8BA993248A
7 changed files with 114 additions and 2 deletions

View file

@ -13,6 +13,7 @@ shared/NSPointTrigger.qc
shared/NSVehicle.qc shared/NSVehicle.qc
shared/NSMonster.qc shared/NSMonster.qc
shared/NSTalkMonster.qc shared/NSTalkMonster.qc
shared/NSProjectile.qc
shared/decals.qc shared/decals.qc
shared/spraylogo.qc shared/spraylogo.qc
shared/func_friction.qc shared/func_friction.qc

View file

@ -21,4 +21,4 @@ class NSBrushTrigger:NSEntity
#ifdef SERVER #ifdef SERVER
virtual void(void) InitBrushTrigger; virtual void(void) InitBrushTrigger;
#endif #endif
}; };

View file

@ -72,6 +72,10 @@ class NSEntity:NSTrigger
nonvirtual string(void) GetSpawnModel; nonvirtual string(void) GetSpawnModel;
#endif #endif
virtual void(float) SetScale;
virtual void(entity) SetOwner;
virtual void(vector) SetVelocity;
virtual void(void()) SetTouch;
virtual void(float) SetSendFlags; virtual void(float) SetSendFlags;
virtual void(float) SetSolid; virtual void(float) SetSolid;
virtual void(string) SetModel; virtual void(string) SetModel;

View file

@ -253,6 +253,28 @@ NSEntity::ClearAngles(void)
} }
#endif #endif
void
NSEntity::SetOwner(entity newOwner)
{
owner = newOwner;
};
void
NSEntity::SetVelocity(vector vecNew)
{
if (vecNew == velocity)
return;
velocity = vecNew;
SetSendFlags(BASEFL_CHANGED_VELOCITY);
};
void
NSEntity::SetTouch(void() newTouch)
{
touch = newTouch;
};
/* we want to really use those set functions because they'll notify of any /* we want to really use those set functions because they'll notify of any
* networking related changes. otherwise we'll have to keep track of copies * networking related changes. otherwise we'll have to keep track of copies
* that get updated every frame */ * that get updated every frame */
@ -282,6 +304,15 @@ NSEntity::SetSolid(float newSolid)
solid = newSolid; solid = newSolid;
SetSendFlags(BASEFL_CHANGED_SOLID); SetSendFlags(BASEFL_CHANGED_SOLID);
} }
void
NSEntity::SetScale(float newScale)
{
if (newScale == scale)
return;
scale = newScale;
SetSendFlags(BASEFL_CHANGED_SCALE);
}
void void
NSEntity::UpdateBounds(void) NSEntity::UpdateBounds(void)

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2016-2022 Vera Visions L.L.C.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class NSProjectile:NSSurfacePropEntity
{
void(void) NSProjectile;
virtual void(entity, entity) m_pImpact = 0;
virtual void(void()) SetImpact;
virtual void(string) SetModel;
virtual void(void) ProjectileTouch;
};

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2016-2022 Vera Visions L.L.C.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
NSProjectile::ProjectileTouch(void)
{
if (m_pImpact)
m_pImpact(other, this);
Destroy();
}
void
NSProjectile::SetImpact(void() func)
{
m_pImpact = func;
}
void
NSProjectile::SetModel(string mdl)
{
super::SetModel(mdl);
SetSize([0,0,0], [0,0,0]);
}
void
NSProjectile::NSProjectile(void)
{
super::NSSurfacePropEntity();
touch = ProjectileTouch;
SetMovetype(MOVETYPE_FLY);
SetRenderColor([1,1,1]);
SetRenderAmt(1.0);
SetSolid(SOLID_BBOX);
}

View file

@ -26,6 +26,7 @@
#include "NSPointTrigger.h" #include "NSPointTrigger.h"
#include "NSMonster.h" #include "NSMonster.h"
#include "NSTalkMonster.h" #include "NSTalkMonster.h"
#include "NSProjectile.h"
/* /*
============ ============
@ -60,4 +61,4 @@ CBaseTrigger::CBaseTrigger(void)
{ {
CBaseEntity::CBaseEntity(); CBaseEntity::CBaseEntity();
} }
#endif #endif