예제 #1
0
void CStation::removeAgent( CAgent& agent )
{
	// Remove the agent from list of currently visiting agents
	visitingAgents.remove( &agent );

	// If station type has a space attribute, free the space used by the agent on the station
	if( getStationType().getHasSpace() )
	{
		space = space - agent.getSizeOnCurrentStation();
	}

	// Reset the agent's size on its current station
	agent.setSizeOnCurrentStation( 0 );
}
예제 #2
0
void CStation::addAgent( CAgent& agent )
{
	// Increase the enter event count
	setEnterEventCount( getEnterEventCount() + 1 );

	//  If has necessity attribute
	if( getStationType().getHasNecessity() )
	{
		// Increase the necessity count for its entering agent
		setNecessity( agent, getNecessity( agent ) + 1 );
	}

	// Add the agent to list of currently visiting agents
	visitingAgents.push_back( &agent );

	// If the agent has a size attribute, set its size on this station to its normal size
	if( agent.getAgentType().getHasSize() )
	{
		agent.setSizeOnCurrentStation( agent.getAgentType().getSize() );
	}

	// If the station has a space attribute and the agent type has a size attribute, add size
	if( getStationType().getHasSpace() && agent.getAgentType().getHasSize() )
	{
		space = space + agent.getSizeOnCurrentStation();
	}

	// else if station type has a space attribute
	else if( getStationType().getHasSpace() )
	{
		// Store the agent's size on this station
		agent.setSizeOnCurrentStation( getStationType().getSpace() - getSpace() );

		// Set space to maximum
		space = getStationType().getSpace();
	}
}