コード例 #1
0
void game::draw_interface(const DRAW_MODE_UI draw_mode a2e_unused, rtt::fbo* buffer) {
	const uint2 screen_size(buffer->width, buffer->height);
	switch(status.load()) {
		case GAME_STATUS::DEATH:
			draw_center_screen_tex(screen_size, death_tex, float4(1.0f, 0.0f, 0.0f, 0.5f));
			break;
		case GAME_STATUS::MAP_LOAD:
			gfx2d::draw_rectangle_fill(rect(0, 0, screen_size.x, screen_size.y), float4(1.0f));
			break;
		case GAME_STATUS::AI_PUSHED:
		case GAME_STATUS::OBJECT_SWAPPED:
		case GAME_STATUS::OBJECT_PUSHED:
		case GAME_STATUS::OBJECT_SELECTED:
		case GAME_STATUS::OBJECT_SELECTED_FINISHED:
			// selected object will be drawn by the geometry-render method
		default: {
			// draw health overlay
			const float cur_health = get_health();
			if(cur_health < 100.0f) {
				const float4 health_background(1.0f, 0.0f, 0.0f, (1.0f - (get_health() / 100.0f)));
				gfx2d::draw_rectangle_fill(rect(0, 0, screen_size.x, screen_size.y), health_background);
			}
			
			// draw crosshair
			draw_crosshair(screen_size);
		}
		break;
	}
}
コード例 #2
0
void game::physics_update() {
	// handle active object
	switch(status.load()) {
		case GAME_STATUS::OBJECT_SELECTED: {
			// grab object with growing force
			float3 target_dir = get_block_target_pos() - body->get_position();
			float len = target_dir.length();
			if(len < object_grab_distance) {
				set_status(GAME_STATUS::OBJECT_SELECTED_FINISHED);
				// hide object and remove it from physics engine
				active_map->update_dynamic(body, BLOCK_MATERIAL::NONE);
				// unregister physical object
				pc->disable_body(body);
			}
			else {
				// speed up body -> min scale 3
				target_dir = target_dir.normalize() * std::max<float>(len, 0.5f);
				body->get_body()->setLinearVelocity(btVector3(target_dir[0], target_dir[1], target_dir[2]));
			}
		} break;
		case GAME_STATUS::OBJECT_SELECTED_FINISHED: {
			// nothing to do
			break;
		}
		default: break;
	}
	
	static float old_health = -1.0f;
	const float cur_health = get_health();
	if(cur_health != old_health && cur_health < 100.0f && cb_obj != nullptr) {
		old_health = cur_health;
		cb_obj->redraw();
	}
	physics_player::physics_update();
}
コード例 #3
0
ファイル: ascii_man.cpp プロジェクト: ferg2065/ASCIIman
void ascii_man::collide(object *obj2, float adj, vector2d temp_mv, float x_over, float y_over)
{
	set_hit_object(obj2);

	if(x_over > y_over) 
	{
		if(this->get_pt().get_x() < obj2->get_pt().get_x())
		{set_hitR(true);}
		else
		{set_hitL(true);}
	}
	if(x_over < y_over)
	{
		if(this->get_pt().get_y() < obj2->get_pt().get_y())
		{set_hitD(true);}
		else
		{set_hitU(true);}
	}
	if (adj < 0.0001)
	{adj=1;}
	set_pt(get_pt() + (get_mv()* adj));
	set_mv(temp_mv * obj2->get_mass());

	if(this->get_mv().get_y() > 0 && get_hitD()==true && obj2->is_fixed()==true)
	{set_mv(get_mv().get_x(),0);}


	if (can_die()==true)
	{
		set_health(get_health()-obj2->get_damage());
	}
	if (get_health() <= 0)
	{
		isdead(true);
	}
	did_collide(true);
	did_move(true);
}
コード例 #4
0
void CSE_ActorMP::UPDATE_Read	(NET_Packet &packet)
{
    flags						= 0;
    m_u16NumItems				= 1;
    velocity.set				(0.f,0.f,0.f);

    if (get_health() <= 0)
    {
        actor_mp_state_holder	tmp_state_holder;
        tmp_state_holder.read	(packet);
        return;
    }
    m_state_holder.read			(packet);
    R_ASSERT2(valid_pos(m_state_holder.state().position,phBoundaries), "read bad position");

    m_AliveState.quaternion		= m_state_holder.state().physics_quaternion;
    m_AliveState.angular_vel	= m_state_holder.state().physics_angular_velocity;
    m_AliveState.linear_vel		= m_state_holder.state().physics_linear_velocity;
    m_AliveState.force			= m_state_holder.state().physics_force;
    m_AliveState.torque			= m_state_holder.state().physics_torque;
    m_AliveState.position		= m_state_holder.state().physics_position;

    o_Position					= m_state_holder.state().position;

    accel						= m_state_holder.state().logic_acceleration;

    o_model						= m_state_holder.state().model_yaw;
    o_torso.yaw					= m_state_holder.state().camera_yaw;
    o_torso.pitch				= m_state_holder.state().camera_pitch;
    o_torso.roll				= m_state_holder.state().camera_roll;

    timestamp					= m_state_holder.state().time;

    weapon						= m_state_holder.state().inventory_active_slot;
    mstate						= m_state_holder.state().body_state_flags;
    set_health					( m_state_holder.state().health );
    fRadiation					= m_state_holder.state().radiation;
    m_AliveState.enabled		= m_state_holder.state().physics_state_enabled;

    m_ready_to_update			= true;
    //Msg("* Client 0x%08x UPDATE_Read, health is: %2.04f", this->ID, m_state_holder.state().health);
}
コード例 #5
0
ファイル: Ephemeris.c プロジェクト: EpsilonRTD/EGNOS_SDK_Core
/**
 * ReadSubfr1 function.
 * The function decodes the 1st subframe of the GPS navigation data
 * according to the IS-GPS-200E section 20.3.3.3.1 Subframe 1 content and
 * updates the Satellite structure, identified by its pointer.
 * @param *Sat  The pointer of the Satellite structure
 * @param *data The pointer of the 300 bits
 */
void ReadSubfr1(Satellite * Sat, char * data)
{
/*	form the subframe
 * 	data is a table of 10 words, to form the subframe:
		- conversion to binary of each words
		- add the 6 bits parity at the beginning of the words,  for each words (if there arent there already)
		- concatenation of the 10 words
		- if TLM and/or HOW are deleted, add the 32/64 bits
*/
	(*Sat).weeknb = get_weeknb((*Sat).subfr1);
	(*Sat).cl2 = get_cl2((*Sat).subfr1);
	(*Sat).ura = get_ura((*Sat).subfr1);
	(*Sat).health = get_health((*Sat).subfr1);
	(*Sat).iodc = get_iodc((*Sat).subfr1);
	(*Sat).tgd = get_tgd((*Sat).subfr1);
	(*Sat).toc = get_toc((*Sat).subfr1);
	(*Sat).af0 = get_af0((*Sat).subfr1);
	(*Sat).af1 = get_af1((*Sat).subfr1);
	(*Sat).af2 = get_af2((*Sat).subfr1);
}
コード例 #6
0
bool HealthTelemetryReader::read(TelemetryReader::Context::Ptr context, ipmi::IpmiController&) {
    SelContext* ctx = static_cast<SelContext*>(context.get());
    double shoreup_period = get_metric_definition().get_shoreup_period();

    agent_framework::model::enums::Health::base_enum health{};
    std::set<std::string> events{};
    bool shored_up = false;

    /* Check events */
    bool only_first = get_metric_definition().get_metric_jsonptr().empty();
    do {
        SelContext::FoundRecords critical = ctx->asserting_events(get_critical_events(),
            shoreup_period, shored_up, only_first);
        if (!critical.empty()) {
            log_error("telemetry", get_resource_key() << " event " << critical.front().record->to_string()
                                            << " => critical");
            health = agent_framework::model::enums::Health::Critical;
            if (!only_first) {
                for (const auto& record : critical) {
                    if (record.descr != nullptr) {
                        events.insert(record.descr);
                    }
                }
            }
            break;
        }

        SelContext::FoundRecords warnings = ctx->asserting_events(get_warning_events(),
            shoreup_period, shored_up, only_first);
        if (!warnings.empty()) {
            log_warning("telemetry", get_resource_key() << " event " << warnings.front().record->to_string()
                                              << " => warning");
            health = agent_framework::model::enums::Health::Warning;
            if (!only_first) {
                for (const auto& record : warnings) {
                    if (record.descr != nullptr) {
                        events.insert(record.descr);
                    }
                }
            }
            break;
        }

        health = agent_framework::model::enums::Health::OK;
    } while (false);

    if (shored_up) {
        set_to_be_read(shored_up);
    }

    /* if no events found, add current health to the list. Mostly "OK" */
    if (events.empty()) {
        events.insert(agent_framework::model::enums::Health(health).to_string());
    }

    json::Json value = json::Json();
    if ((!get_metric_definition().get_discrete_metric_type().has_value()) ||
        (get_metric_definition().get_discrete_metric_type().value() != agent_framework::model::enums::DiscreteMetricType::Multiple)) {

        value = *(events.cbegin());
    }
    else {
        value = events;
    }

    bool changed = false;
    if ((get_health() != health) || (get_value() != value)) {
        set_value(value);
        changed = true;
    }
    if (changed) {
        set_health(health);
    }
    return changed;
}
コード例 #7
0
bool CSE_ALifeMonsterAbstract::bfActive()
{
	CSE_ALifeGroupAbstract		*l_tpALifeGroupAbstract = smart_cast<CSE_ALifeGroupAbstract*>(this);
	return						(/**/interactive() && /**/((l_tpALifeGroupAbstract && (l_tpALifeGroupAbstract->m_wCount > 0)) || (!l_tpALifeGroupAbstract && (get_health() > EPS_L))));
}
コード例 #8
0
ファイル: engines.cpp プロジェクト: Lasall/goiosimulator
Thrust Engine::get_thrust_changed() const {
  return (get_health()/get_max_health())*get_thrust();
}