env_beverage/item_food: Fix item_food not rendering and or spawning.
This commit is contained in:
parent
94d5d5408c
commit
33295ff409
9 changed files with 100 additions and 162 deletions
|
@ -20,11 +20,7 @@ Entity_EntityUpdate(float type, float new)
|
|||
{
|
||||
switch (type) {
|
||||
case ENT_ENTITY:
|
||||
NSEntity me = (NSEntity)self;
|
||||
if (new) {
|
||||
spawnfunc_NSEntity();
|
||||
}
|
||||
me.ReceiveEntity(new, readfloat());
|
||||
NSEntity_ReadEntity(new);
|
||||
break;
|
||||
case ENT_ENTITYRENDERABLE:
|
||||
NSRenderableEntity_ReadEntity(new);
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef enum
|
|||
|
||||
/*!QUAKED env_beverage (1 0 0) (-8 -8 -8) (8 8 8)
|
||||
# OVERVIEW
|
||||
Upon triggered, the entity will spawn item_food in its place in
|
||||
Upon being triggered, the entity will spawn item_food in its place in
|
||||
the shape of a soda can.
|
||||
|
||||
# KEYS
|
||||
|
@ -59,10 +59,6 @@ This entity was introduced in Half-Life (1998).
|
|||
class
|
||||
env_beverage:NSRenderableEntity
|
||||
{
|
||||
int m_iUses;
|
||||
bool m_bReady;
|
||||
sodaskin_t m_sodaSkin;
|
||||
|
||||
public:
|
||||
void env_beverage(void);
|
||||
|
||||
|
@ -72,6 +68,10 @@ public:
|
|||
virtual void Spawned(void);
|
||||
virtual void Trigger(entity,int);
|
||||
|
||||
private:
|
||||
int m_iUses;
|
||||
bool m_bReady;
|
||||
sodaskin_t m_sodaSkin;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -147,6 +147,7 @@ env_beverage::Trigger(entity act, int unused)
|
|||
}
|
||||
|
||||
NSEntity eCan = spawn(NSEntity);
|
||||
eCan.Respawn();
|
||||
eCan.SetOrigin(GetOrigin());
|
||||
eCan.SetAngles(GetAngles());
|
||||
eCan.SetOwner(this);
|
||||
|
|
|
@ -74,6 +74,30 @@ This entity was introduced in Quake (1996).
|
|||
class
|
||||
func_door:NSRenderableEntity
|
||||
{
|
||||
public:
|
||||
void func_door(void);
|
||||
|
||||
virtual void Spawned(void);
|
||||
|
||||
virtual void PortalOpen(void);
|
||||
virtual void PortalClose(void);
|
||||
virtual void SetMovementDirection(void);
|
||||
virtual void MoveToDestination(vector, void(void) func);
|
||||
virtual void MoveAway(void);
|
||||
virtual void MoveBack(void);
|
||||
virtual void Arrived(void);
|
||||
virtual void Returned(void);
|
||||
virtual void Respawn(void);
|
||||
virtual void Trigger(entity, int);
|
||||
virtual void Blocked(entity);
|
||||
virtual void Touch(entity);
|
||||
virtual void PlayerUse(void);
|
||||
virtual void Save(float);
|
||||
virtual void Restore(string, string);
|
||||
virtual void SpawnKey(string, string);
|
||||
virtual void Input(entity, string, string);
|
||||
|
||||
private:
|
||||
string targetClose;
|
||||
vector m_vecPos1;
|
||||
vector m_vecPos2;
|
||||
|
@ -99,29 +123,6 @@ func_door:NSRenderableEntity
|
|||
string m_strSndClose;
|
||||
string m_strSndMove;
|
||||
string m_strSndStop;
|
||||
|
||||
public:
|
||||
void(void) func_door;
|
||||
|
||||
virtual void Spawned(void);
|
||||
|
||||
virtual void PortalOpen(void);
|
||||
virtual void PortalClose(void);
|
||||
virtual void SetMovementDirection(void);
|
||||
virtual void MoveToDestination(vector, void(void) func);
|
||||
virtual void MoveAway(void);
|
||||
virtual void MoveBack(void);
|
||||
virtual void Arrived(void);
|
||||
virtual void Returned(void);
|
||||
virtual void Respawn(void);
|
||||
virtual void Trigger(entity, int);
|
||||
virtual void Blocked(entity);
|
||||
virtual void Touch(entity);
|
||||
virtual void PlayerUse(void);
|
||||
virtual void Save(float);
|
||||
virtual void Restore(string, string);
|
||||
virtual void SpawnKey(string, string);
|
||||
virtual void Input(entity, string, string);
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -25,15 +25,16 @@ This is a food item that will give the user 1 health when touched.
|
|||
|
||||
# TRIVIA
|
||||
This entity was introduced in Half-Life (1998).
|
||||
It's also known as item_sodacan.
|
||||
*/
|
||||
class
|
||||
item_food:NSEntity
|
||||
item_food:NSRenderableEntity
|
||||
{
|
||||
int m_iIsCan;
|
||||
|
||||
void item_food(void);
|
||||
|
||||
virtual void Spawned(void);
|
||||
virtual void Respawn(void);
|
||||
virtual void Save(float);
|
||||
virtual void Restore(string,string);
|
||||
virtual void Setup(void);
|
||||
|
@ -67,16 +68,14 @@ item_food::Restore(string strKey, string strValue)
|
|||
}
|
||||
|
||||
void
|
||||
item_food::Spawned(void)
|
||||
item_food::Respawn(void)
|
||||
{
|
||||
super::Spawned();
|
||||
|
||||
SetSolid(SOLID_NOT);
|
||||
SetMovetype(MOVETYPE_TOSS);
|
||||
|
||||
if (m_iIsCan) {
|
||||
//if (m_iIsCan) {
|
||||
SetModel("models/can.mdl");
|
||||
}
|
||||
//}
|
||||
|
||||
SetSize([0,0,0], [0,0,0]);
|
||||
ScheduleThink(Setup, 1.0f);
|
||||
|
@ -88,9 +87,9 @@ item_food::Setup(void)
|
|||
SetSolid(SOLID_TRIGGER);
|
||||
SetSize([-16,-16,-16], [16,16,16]);
|
||||
|
||||
if (m_iIsCan) {
|
||||
//if (m_iIsCan) {
|
||||
sound(this, CHAN_ITEM, "weapons/g_bounce3.wav", 1.0f, ATTN_NORM);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -62,19 +62,6 @@ This entity was introduced in Half-Life (1998).
|
|||
*/
|
||||
class ambient_generic:NSTalkMonster
|
||||
{
|
||||
/* networked attributes */
|
||||
PREDICTED_STRING(m_strActivePath)
|
||||
PREDICTED_FLOAT(m_flVolume)
|
||||
PREDICTED_FLOAT(m_flRadius)
|
||||
PREDICTED_FLOAT(m_flPitch)
|
||||
PREDICTED_BOOL(m_bLoops)
|
||||
bool m_bToggle;
|
||||
|
||||
/* spawn values */
|
||||
string m_strSpawnPath;
|
||||
float m_flSpawnVolume;
|
||||
float m_flSpawnPitch;
|
||||
|
||||
public:
|
||||
void ambient_generic(void);
|
||||
|
||||
|
@ -89,14 +76,26 @@ public:
|
|||
virtual float SendEntity(entity,float);
|
||||
virtual void UseNormal(entity,int);
|
||||
virtual void UseLoop(entity,int);
|
||||
|
||||
#else
|
||||
virtual void ReceiveEntity(float,float);
|
||||
virtual float predraw(void);
|
||||
virtual void SentenceSample(string);
|
||||
|
||||
#endif
|
||||
virtual void OnRemoveEntity(void);
|
||||
|
||||
private:
|
||||
/* networked attributes */
|
||||
PREDICTED_STRING(m_strActivePath)
|
||||
PREDICTED_FLOAT(m_flVolume)
|
||||
PREDICTED_FLOAT(m_flRadius)
|
||||
PREDICTED_FLOAT(m_flPitch)
|
||||
PREDICTED_BOOL(m_bLoops)
|
||||
bool m_bToggle;
|
||||
|
||||
/* spawn values */
|
||||
string m_strSpawnPath;
|
||||
float m_flSpawnVolume;
|
||||
float m_flSpawnPitch;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -382,7 +381,8 @@ ambient_generic::ReceiveEntity(float isnew, float flChanged)
|
|||
void
|
||||
ambient_generic::SentenceSample(string sample)
|
||||
{
|
||||
/* honestly, the 0.25 for the radius is probably inaccurate (winged it), ATTN_NORM is too short though */
|
||||
/* honestly, the 0.25 for the radius is probably inaccurate (winged it),
|
||||
ATTN_NORM is too short though */
|
||||
sound(this, CHAN_VOICE, sample, 1.0, m_flRadius, 100, SOUNDFLAG_FOLLOW);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,22 +30,6 @@ enumflags
|
|||
VEHFL_FLAGS
|
||||
};
|
||||
|
||||
/*!QUAKED prop_vehicle_driveable (0 0 1) (-50 -50 0) (50 50 70)
|
||||
# OVERVIEW
|
||||
Point entity defining a 4-wheel vehicle that you can drive.
|
||||
|
||||
# KEYS
|
||||
- "targetname" : Name
|
||||
|
||||
# SPAWNFLAGS
|
||||
None currently.
|
||||
|
||||
# NOTES
|
||||
None currently.
|
||||
|
||||
# TRIVIA
|
||||
This entity was introduced in Half-Life 2 (2004).
|
||||
*/
|
||||
class prop_vehicle_driveable_wheel
|
||||
{
|
||||
private:
|
||||
|
@ -73,6 +57,22 @@ public:
|
|||
virtual void Physics(float,float);
|
||||
};
|
||||
|
||||
/*!QUAKED prop_vehicle_driveable (0 0 1) (-50 -50 0) (50 50 70)
|
||||
# OVERVIEW
|
||||
Point entity defining a 4-wheel vehicle that you can drive.
|
||||
|
||||
# KEYS
|
||||
- "targetname" : Name
|
||||
|
||||
# SPAWNFLAGS
|
||||
None currently.
|
||||
|
||||
# NOTES
|
||||
None currently.
|
||||
|
||||
# TRIVIA
|
||||
This entity was introduced in Half-Life 2 (2004).
|
||||
*/
|
||||
class prop_vehicle_driveable:NSVehicle
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -339,6 +339,8 @@ public:
|
|||
/** Stops a sound sample or soundDef that is playing on the given channel. */
|
||||
nonvirtual void StopSound(float,bool);
|
||||
|
||||
/** Returns the nearest point on a wall of this entity within a specified radius.
|
||||
If there is nothing nearby, it'll return the position of the entity. */
|
||||
nonvirtual vector NearestWallPointForRadius(float);
|
||||
|
||||
/** For physics functions only. Call this inside your customphysics function
|
||||
|
@ -346,3 +348,7 @@ public:
|
|||
This saves you the effort of writing your own routines and methods. */
|
||||
nonvirtual void HandleThink(void);
|
||||
};
|
||||
|
||||
#ifdef CLIENT
|
||||
void NSEntity_ReadEntity(float);
|
||||
#endif
|
|
@ -14,18 +14,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::NSEntity
|
||||
static void droptofloorwrapper( entity foo ) {
|
||||
entity old_self = self;
|
||||
|
||||
self = foo;
|
||||
droptofloor();
|
||||
self = old_self;
|
||||
}
|
||||
|
||||
client doesn't have to do a whole lot here
|
||||
============
|
||||
*/
|
||||
void NSEntity::NSEntity( void ) {
|
||||
identity = 1;
|
||||
}
|
||||
|
||||
|
||||
void NSEntity::Spawned( void ) {
|
||||
super::Spawned();
|
||||
|
||||
|
@ -51,14 +51,6 @@ float NSEntity::EntIndex( void ) {
|
|||
return ( num_for_edict( this ) );
|
||||
}
|
||||
|
||||
void droptofloorwrapper( entity foo ) {
|
||||
entity old_self = self;
|
||||
|
||||
self = foo;
|
||||
droptofloor();
|
||||
self = old_self;
|
||||
}
|
||||
|
||||
void NSEntity::DropToFloor( void ) {
|
||||
droptofloorwrapper( this );
|
||||
}
|
||||
|
@ -78,36 +70,14 @@ vector NSEntity::GetUp( void ) {
|
|||
return ( v_up );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::WorldSpaceCenter
|
||||
|
||||
Returns the center of an entity's bounding boxes.
|
||||
Useful on brush entities that have no real 'origin' defined.
|
||||
============
|
||||
*/
|
||||
vector NSEntity::WorldSpaceCenter( void ) {
|
||||
return ( absmin + ( 0.5 * ( absmax - absmin ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::WaterLevel
|
||||
|
||||
Returns whether or not the entity is able to see a given position
|
||||
============
|
||||
*/
|
||||
float NSEntity::WaterLevel( void ) {
|
||||
return ( waterlevel );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::VisibleVec
|
||||
|
||||
Returns whether or not the entity is able to see a given position
|
||||
============
|
||||
*/
|
||||
bool NSEntity::VisibleVec( vector org ) {
|
||||
vector flDelta;
|
||||
float flFoV;
|
||||
|
@ -125,13 +95,6 @@ bool NSEntity::VisibleVec( vector org ) {
|
|||
return ( false );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::Visible
|
||||
|
||||
Returns whether or not the entity is able to see a given entity
|
||||
============
|
||||
*/
|
||||
bool NSEntity::Visible( entity ent ) {
|
||||
vector flDelta;
|
||||
float flFoV;
|
||||
|
@ -175,23 +138,10 @@ bool NSEntity::CreatedByMap( void ) {
|
|||
|
||||
|
||||
#ifdef CLIENT
|
||||
/*
|
||||
============
|
||||
NSEntity::RendererRestarted
|
||||
|
||||
make sure any child-classes precache their assets in here
|
||||
for vid_reload calls or other sudden deaths (driver restarts)
|
||||
============
|
||||
*/
|
||||
void NSEntity::RendererRestarted( void ) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::ReceiveEntity
|
||||
============
|
||||
*/
|
||||
void NSEntity::ReceiveEntity( float flNew, float flChanged ) {
|
||||
READENTITY_COORD( origin[0], BASEFL_CHANGED_ORIGIN_X )
|
||||
READENTITY_COORD( origin[1], BASEFL_CHANGED_ORIGIN_Y )
|
||||
|
@ -234,11 +184,6 @@ void NSEntity::ReceiveEntity( float flNew, float flChanged ) {
|
|||
setorigin( this, origin );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::postdraw
|
||||
============
|
||||
*/
|
||||
void NSEntity::postdraw( void ) {
|
||||
}
|
||||
|
||||
|
@ -785,15 +730,6 @@ void NSEntity::Input( entity eAct, string strInput, string strData ) {
|
|||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::SpawnKey
|
||||
|
||||
note that the engine still likes to try and map key/value
|
||||
pairs on its own, but we can at least undo some of that in
|
||||
here if needed
|
||||
============
|
||||
*/
|
||||
void NSEntity::SpawnKey( string strKey, string strValue ) {
|
||||
/* we do re-read a lot of the builtin fields in case we want to set
|
||||
defaults. just in case anybody is wondering. */
|
||||
|
@ -833,26 +769,9 @@ void NSEntity::SpawnKey( string strKey, string strValue ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
OnRemoveEntity
|
||||
|
||||
Empty method, meant for sub-classes to clean up their contents
|
||||
============
|
||||
*/
|
||||
void NSEntity::OnRemoveEntity( void ) {
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
NSEntity::Destroy
|
||||
|
||||
Call if the entity is to be removed the next possible frame.
|
||||
If you want an entity to be purged immediately, you'll have to jump
|
||||
through your own hoops. This however will be sufficient 99,99% of the time.
|
||||
============
|
||||
*/
|
||||
void NSEntity::Destroy( void ) {
|
||||
removed = 1; /* mark this as cleanly removed */
|
||||
OnRemoveEntity();
|
||||
|
@ -940,3 +859,19 @@ void NSEntity::HandleThink( void ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CLIENT
|
||||
void
|
||||
NSEntity_ReadEntity(bool new)
|
||||
{
|
||||
float fl;
|
||||
|
||||
NSEntity read = (NSEntity)self;
|
||||
if (new) {
|
||||
spawnfunc_NSEntity();
|
||||
}
|
||||
|
||||
fl = readfloat();
|
||||
read.ReceiveEntity(new, fl);
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue