Ejemplo n.º 1
0
    Entity* EntityCreator::CreateFromFile(const string& filepath) {
        std::ifstream fin(filepath, std::ios::in);

        if (fin) {
            Json::Value rootNode;
            Json::Reader reader;
            bool success = reader.parse(fin, rootNode);
            if (success) {
                Model* model = nullptr;
                PhysicsBody* body = nullptr;

                if (CheckExistence(rootNode, "model")) {
                    const Json::Value& modelNode = rootNode["model"];
                    model = ModelCreator::CreateFromJson(modelNode);
                }

                if (CheckExistence(rootNode, "body")) {
                    const Json::Value& bodyNode = rootNode["body"];
                    body = PhysicsCreator::CreateFromJson(bodyNode, model);
                }

                Entity* entity = new Entity(model, body);
                return entity;
            } else {
                throw Exception("SceneCreator: Cannot parse file '" + filepath + "': " + reader.getFormatedErrorMessages());
            }
        } else {
            throw FileNotFoundException(filepath);
        }
    }
Ejemplo n.º 2
0
void CGeneInfoFileReader::x_MapMemFiles()
{
    if (!CheckExistence(m_strGi2GeneFile))
        NCBI_THROW(CGeneInfoException, eFileNotFoundError,
        "Gi->GeneId processed file not found: " + m_strGi2GeneFile);
    m_memGi2GeneFile.reset(new CMemoryFile(m_strGi2GeneFile));

    if (!CheckExistence(m_strGene2OffsetFile))
        NCBI_THROW(CGeneInfoException, eFileNotFoundError,
        "GeneId->Offset processed file not found: " + m_strGene2OffsetFile);
    m_memGene2OffsetFile.reset(new CMemoryFile(m_strGene2OffsetFile));

    if (m_bGiToOffsetLookup)
    {
        if (!CheckExistence(m_strGi2OffsetFile))
            NCBI_THROW(CGeneInfoException, eFileNotFoundError,
            "Gi->Offset processed file not found: " + m_strGi2OffsetFile);
        m_memGi2OffsetFile.reset(new CMemoryFile(m_strGi2OffsetFile));
    }

    if (!CheckExistence(m_strGene2GiFile))
        NCBI_THROW(CGeneInfoException, eFileNotFoundError,
        "Gene->Gi processed file not found: " + m_strGene2GiFile);
    m_memGene2GiFile.reset(new CMemoryFile(m_strGene2GiFile));
}
Ejemplo n.º 3
0
/*QUAKED trigger_teleport (.5 .5 .5) ? PLAYER_ONLY SILENT
Any object touching this will be transported to the corresponding info_teleport_destination entity. You must set the "target" field, and create an object with a "targetname" field that matches.

If the trigger_teleport has a targetname, it will only teleport entities when it has been fired.
*/
void SP_trigger_teleport(  )
{
	vec3_t  o;

	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	InitTrigger(  );
	self->s.v.touch = ( func_t ) teleport_touch;
	// find the destination 
	if ( !self->s.v.target )
		G_Error( "no target" );
	self->s.v.use = ( func_t ) teleport_use;

	if ( !( ( int ) ( self->s.v.spawnflags ) & SILENT ) )
	{
		trap_precache_sound( "ambience/hum1.wav" );
		VectorAdd( self->s.v.mins, self->s.v.maxs, o );
		VectorScale( o, 0.5, o );
		//o = (self.mins + self.maxs)*0.5;
		trap_ambientsound( PASSVEC3( o ), "ambience/hum1.wav", 0.5, ATTN_STATIC );
	}
}
Ejemplo n.º 4
0
void SP_misc_explobox2(  )
{
	float   oldz;

	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}

	self->s.v.solid = SOLID_BBOX;
	self->s.v.movetype = MOVETYPE_NONE;

	trap_precache_model( "maps/b_exbox2.bsp" );
	setmodel( self, "maps/b_exbox2.bsp" );
	setsize( self, 0, 0, 0, 32, 32, 32 );
	trap_precache_sound( "weapons/r_exp3.wav" );

	self->s.v.health = 20;
	self->th_die = barrel_explode;
	self->s.v.takedamage = DAMAGE_AIM;

	self->s.v.origin[2] += 2;
	oldz = self->s.v.origin[2];

	droptofloor( self );

	if ( oldz - self->s.v.origin[2] > 250 )
	{
		G_dprintf( "item fell out of level at '%f %f %f'\n", PASSVEC3( self->s.v.origin ) );
		ent_remove( self );
	}
}
Ejemplo n.º 5
0
/*QUAKED trigger_secret (.5 .5 .5) ?
secret counter trigger
sounds
1) secret
2) beep beep
3)
4)
set "message" to text string
*/
void SP_trigger_secret(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	g_globalvars.total_secrets = g_globalvars.total_secrets + 1;
	self->wait = -1;
	if ( !self->s.v.message )
		self->s.v.message = "You found a secret area!";
	if ( !self->s.v.sounds )
		self->s.v.sounds = 1;

	if ( self->s.v.sounds == 1 )
	{
		trap_precache_sound( "misc/secret.wav" );
		self->s.v.noise = "misc/secret.wav";
	} else if ( self->s.v.sounds == 2 )
	{
		trap_precache_sound( "misc/talk.wav" );
		self->s.v.noise = "misc/talk.wav";
	}

	SP_trigger_multiple(  );
}
Ejemplo n.º 6
0
/*QUAKED air_bubbles (0 .5 .8) (-8 -8 -8) (8 8 8)

testing air bubbles
*/
void SP_air_bubbles(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	ent_remove( self );
}
Ejemplo n.º 7
0
/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
This fixed size trigger cannot be touched, it can only be fired by other events.  It can contain killtargets, targets, delays, and messages.
*/
void SP_trigger_relay(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	self->s.v.use = ( func_t ) SUB_UseTargets;
}
Ejemplo n.º 8
0
/*QUAKED path_corner (0.5 0.3 0) (-8 -8 -8) (8 8 8)
Monsters will continue walking towards the next target corner.
*/
void SP_path_corner(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	movetarget_f(  );
}
Ejemplo n.º 9
0
/*QUAKED ambient_swamp2 (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void SP_ambient_swamp2(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_sound( "ambience/swamp2.wav" );
	trap_ambientsound( PASSVEC3( self->s.v.origin ), "ambience/swamp2.wav", 0.5, ATTN_STATIC );
}
Ejemplo n.º 10
0
/*QUAKED ambient_comp_hum (0.3 0.1 0.6) (-10 -10 -8) (10 10 8)
*/
void SP_ambient_comp_hum(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_sound( "ambience/comp1.wav" );
	trap_ambientsound( PASSVEC3( self->s.v.origin ), "ambience/comp1.wav", 1, ATTN_STATIC );
}
Ejemplo n.º 11
0
/*QUAKED trigger_once (.5 .5 .5) ? notouch
Variable sized trigger. Triggers once, then removes itself.  You must set the key "target" to the name of another object in the level that has a matching
"targetname".  If "health" is set, the trigger must be killed to activate.
If notouch is set, the trigger is only fired by other entities, not by touching.
if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired.
if "angle" is set, the trigger will only fire when someone is facing the direction of the angle.  Use "360" for an angle of 0.
sounds
1) secret
2) beep beep
3) large switch
4)
set "message" to text string
*/
void SP_trigger_once(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	self->wait = -1;
	SP_trigger_multiple(  );
}
Ejemplo n.º 12
0
/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/
void SP_trigger_onlyregistered(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_sound( "misc/talk.wav" );
	InitTrigger(  );
	self->s.v.touch = ( func_t ) trigger_onlyregistered_touch;
}
Ejemplo n.º 13
0
/*QUAKED light_globe (0 1 0) (-8 -8 -8) (8 8 8)
Sphere globe light.
Default light value is 300
Default style is 0
*/
void SP_light_globe(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_model( "progs/s_light.spr" );
	setmodel( self, "progs/s_light.spr" );
	makestatic( self );
}
Ejemplo n.º 14
0
    Entity* EntityCreator::CreateFromSceneNode(const Json::Value& node) {
        AssertExistence(node, "filepath");
        string filepath = node.get("filepath", "undefined").asString();

        Entity* entity = nullptr;

        try {
            entity = CreateFromFile(filepath);
        } catch (const FileNotFoundException& exception) {
            entity = CreateFromFile(ResourceManager::Get()->GetDataRootDir() + filepath);
        }

        if (CheckExistence(node, "name")) {
            string name = node.get("name", "undefined").asString();
            entity->SetName(name);
        }

        if (CheckExistence(node, "script")) {
            string script = node.get("script", "undefined").asString();
            
        }

        if (CheckExistence(node, "position")) {
            string positionStr = node.get("position", "0.0 0.0 0.0").asString();
            entity->SetPosition(Vector3f(positionStr));
        }

        if (CheckExistence(node, "scale")) {
            string scaleStr = node.get("scale", "1.0 1.0 1.0").asString();
            entity->SetScale(Vector3f(scaleStr));
        }

        if (CheckExistence(node, "rotation")) {
            string rotationStr = node.get("rotation", "0.0 0.0 0.0 1.0").asString();
            entity->SetRotation(Quaternion(rotationStr));
        }

        entity->EnablePhysics();

        return entity;
    }
Ejemplo n.º 15
0
void viewthing(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	self->s.v.movetype = MOVETYPE_NONE;
	self->s.v.solid = SOLID_NOT;
	trap_precache_model( "progs/player.mdl" );
	setmodel( self, "progs/player.mdl" );
}
Ejemplo n.º 16
0
/*QUAKED light_flame_small_white (0 1 0) (-10 -10 -40) (10 10 40) START_OFF
Small white flame ball
*/
void SP_light_flame_small_white(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_model( "progs/flame2.mdl" );
	setmodel( self, "progs/flame2.mdl" );
	FireAmbient( );
	makestatic( self );
}
Ejemplo n.º 17
0
/*QUAKED trigger_hurt (.5 .5 .5) ?
Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/
void SP_trigger_hurt(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	InitTrigger(  );
	self->s.v.touch = ( func_t ) hurt_touch;
	if ( !self->dmg )
		self->dmg = 5;
}
Ejemplo n.º 18
0
/*QUAKED light_flame_large_yellow (0 1 0) (-10 -10 -12) (12 12 18)
Large yellow flame ball
*/
void SP_light_flame_large_yellow(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_model( "progs/flame2.mdl" );
	setmodel( self, "progs/flame2.mdl" );
	self->s.v.frame = 1;
	FireAmbient( );
	makestatic( self );
}
Ejemplo n.º 19
0
/*QUAKED light_fluorospark (0 1 0) (-8 -8 -8) (8 8 8)
Non-displayed light.
Default light value is 300
Default style is 10
Makes sparking, broken fluorescent sound
*/
void SP_light_fluorospark(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	if ( !self->style )
		self->style = 10;

	trap_precache_sound( "ambience/buzz1.wav" );
	trap_ambientsound( PASSVEC3( self->s.v.origin ), "ambience/buzz1.wav", 0.5, ATTN_STATIC );
}
Ejemplo n.º 20
0
/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE
Pushes the player
*/
void SP_trigger_push(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	InitTrigger(  );
	trap_precache_sound( "ambience/windfly.wav" );
	self->s.v.touch = ( func_t ) trigger_push_touch;
	if ( !self->speed )
		self->speed = 1000;
}
Ejemplo n.º 21
0
/*QUAKED func_illusionary (0 .5 .8) ?
A simple entity that looks solid but lets you walk through it.
*/
void SP_func_illusionary(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	SetVector( self->s.v.angles, 0, 0, 0 );
	self->s.v.movetype = MOVETYPE_NONE;
	self->s.v.solid = SOLID_NOT;
	setmodel( self, self->s.v.model );
	makestatic( self );
}
Ejemplo n.º 22
0
/*QUAKED func_wall (0 .5 .8) ?
This is just a solid wall if not inhibitted
*/
void SP_func_wall(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	SetVector( self->s.v.angles, 0, 0, 0 );
	self->s.v.movetype = MOVETYPE_PUSH;	// so it doesn't get pushed by anything
	self->s.v.solid = SOLID_BSP;
	self->s.v.use = ( func_t ) func_wall_use;
	setmodel( self, self->s.v.model );
}
Ejemplo n.º 23
0
/*QUAKED trigger_counter (.5 .5 .5) ? nomessage
Acts as an intermediary for an action that takes multiple inputs.

If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.

After the counter has been triggered "count" g_globalvars.times (default 2), it will fire all of it's targets and remove itself.
*/
void SP_trigger_counter(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	self->wait = -1;
	if ( !self->count )
		self->count = 2;

	self->s.v.use = ( func_t ) counter_use;
}
Ejemplo n.º 24
0
void trigger_jumper ( )
{
    if ( CheckExistence ( ) == 0 )
    {
        dremove ( self);
        return;
    }

    InitTrigger ( );
    trap_precache_sound ( "misc/boing.wav");
    self->s.v.touch = ( func_t ) trigger_jumper_touch;
    if ( !self->speed )
        self->speed = 1000;
}
Ejemplo n.º 25
0
/*QUAKED trap_shooter (0 .5 .8) (-8 -8 -8) (8 8 8) superspike laser
Continuously fires spikes.
"wait" g_globalvars.time between spike (1.0 default)
"nextthink" delay before firing first spike, so multiple shooters can be stagered.
*/
void SP_trap_shooter(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	SP_trap_spikeshooter(  );

	if ( self->wait == 0 )
		self->wait = 1;
	self->s.v.nextthink = self->s.v.nextthink + self->wait + self->s.v.ltime;
	self->s.v.think = ( func_t ) shooter_think;
}
Ejemplo n.º 26
0
void SP_misc_fireball(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	trap_precache_model( "progs/lavaball.mdl" );
	self->s.v.classname = "fireball";
	self->s.v.nextthink = g_globalvars.time + ( g_random(  ) * 5 );
	self->s.v.think = ( func_t ) fire_fly;

	if ( !self->speed )
		self->speed = 1000;
}
Ejemplo n.º 27
0
/*QUAKED info_teleport_destination (.5 .5 .5) (-8 -8 -8) (8 8 32)
This is the destination marker for a teleporter.  It should have a "targetname" field with the same value as a teleporter's "target" field.
*/
void SP_info_teleport_destination(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
// this does nothing, just serves as a target spot
	VectorCopy( self->s.v.angles, self->mangle );
// self.mangle = self.angles;
	SetVector( self->s.v.angles, 0, 0, 0 );
	self->s.v.model = "";
	self->s.v.origin[2] += 27;
	if ( !self->s.v.targetname )
		G_Error( "no targetname" );
}
Ejemplo n.º 28
0
/*QUAKED func_episodegate (0 .5 .8) ? E1 E2 E3 E4
This bmodel will appear if the episode has allready been completed, so players can't reenter it.
*/
void SP_func_episodegate(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	if ( !( ( int ) ( g_globalvars.serverflags ) & ( int ) ( self->s.v.spawnflags ) ) )
		return;		// can still enter episode

	SetVector( self->s.v.angles, 0, 0, 0 );
	self->s.v.movetype = MOVETYPE_PUSH;	// so it doesn't get pushed by anything
	self->s.v.solid = SOLID_BSP;
	self->s.v.use = ( func_t ) func_wall_use;
	setmodel( self, self->s.v.model );
}
Ejemplo n.º 29
0
/*QUAKED func_bossgate (0 .5 .8) ?
This bmodel appears unless players have all of the episode sigils.
*/
void SP_func_bossgate(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	if ( ( ( int ) ( g_globalvars.serverflags ) & 15 ) == 15 )
		return;
	if ( ( ( int ) ( g_globalvars.serverflags ) & 15 ) == 15 )
		return;		// all episodes completed
	SetVector( self->s.v.angles, 0, 0, 0 );
	self->s.v.movetype = MOVETYPE_PUSH;	// so it doesn't get pushed by anything
	self->s.v.solid = SOLID_BSP;
	self->s.v.use = ( func_t ) func_wall_use;
	setmodel( self, self->s.v.model );
}
Ejemplo n.º 30
0
void SP_trap_spikeshooter(  )
{
	if ( !CheckExistence(  ) )
	{
		dremove( self );
		return;
	}
	SetMovedir(  );
	self->s.v.use = ( func_t ) spikeshooter_use;
	if ( ( int ) ( self->s.v.spawnflags ) & SPAWNFLAG_LASER )
	{
		trap_precache_model( "progs/laser.mdl" );

		trap_precache_sound( "enforcer/enfire.wav" );
		trap_precache_sound( "enforcer/enfstop.wav" );
	} else
		trap_precache_sound( "weapons/spike2.wav" );
}