当前位置: 首页>>代码示例>>C++>>正文


C++ const_entity_handle类代码示例

本文整理汇总了C++中const_entity_handle的典型用法代码示例。如果您正苦于以下问题:C++ const_entity_handle类的具体用法?C++ const_entity_handle怎么用?C++ const_entity_handle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了const_entity_handle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: interpolation

std::optional<transformr> interpolation_system::find_interpolated(const const_entity_handle handle) const {
	const auto id = handle.get_id();

	auto result = [&]() -> std::optional<transformr> {
		if (enabled) {
			if (const auto cache = mapped_or_nullptr(per_entity_cache, id)) {
				return cache->interpolated_transform;
			}
		}

		return handle.find_logic_transform();
	}();

	/*
		Here, we integerize the transform of the viewed entity, (and later possibly of the vehicle that it drives)
		so that the rendered player does not shake when exactly followed by the camera,
		which is also integerized for pixel-perfect rendering.

		Ideally we shouldn't do it here because it introduces more state, but that's about the simplest solution
		that doesn't make a mess out of rendering scripts for this special case.	

		Additionally, if someone does not use interpolation (there should be no need to disable it, really)
		they will still suffer from the problem of shaky controlled player. We don't have time for now to handle it better.
	*/

	if (id == id_to_integerize) {
		if (result) {
			result->pos.discard_fract();
		}
	}

	return result;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:33,代码来源:interpolation_system.cpp

示例2: drag_mispredictions_into_past

void simulation_receiver::drag_mispredictions_into_past(interpolation_system& interp, past_infection_system& past, const cosmos& predicted_cosmos, const std::vector<misprediction_candidate_entry>& mispredictions) const {
	for (const auto e : mispredictions) {
		const const_entity_handle reconciliated_entity = predicted_cosmos[e.id];
		
		const bool identity_matches = reconciliated_entity.alive() && reconciliated_entity.has_logic_transform();

		if (!identity_matches)
			continue;

		const auto& reconciliated_transform = reconciliated_entity.logic_transform();
		const bool is_contagious_agent = reconciliated_entity.get_flag(entity_flag::IS_PAST_CONTAGIOUS);
		const bool should_smooth_rotation = !is_contagious_agent || predicted_cosmos[reconciliated_entity.get<components::driver>().owned_vehicle].alive();

		auto& interp_data = interp.get_data(reconciliated_entity);

		const bool shouldnt_smooth = reconciliated_entity.has<components::crosshair>();
		bool misprediction_detected = false;

		const float num_predicted_steps = static_cast<float>(predicted_steps.size());

		if (!shouldnt_smooth && (reconciliated_transform.pos - e.transform.pos).length_sq() > 1.f) {
			interp_data.positional_slowdown_multiplier = std::max(1.f, misprediction_smoothing_multiplier * num_predicted_steps);
			misprediction_detected = true;
		}

		if (should_smooth_rotation && std::abs(reconciliated_transform.rotation - e.transform.rotation) > 1.f) {
			interp_data.rotational_slowdown_multiplier = std::max(1.f, misprediction_smoothing_multiplier * num_predicted_steps);
			misprediction_detected = true;
		}

		if (identity_matches || (!misprediction_detected && !is_contagious_agent)) {
			past.uninfect(reconciliated_entity);
		}
	}
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例3: acquire_potential_misprediction

simulation_receiver::misprediction_candidate_entry simulation_receiver::acquire_potential_misprediction(const const_entity_handle& e) const {
	misprediction_candidate_entry candidate;
	
	if(e.has_logic_transform())
		candidate.transform = e.logic_transform();

	candidate.id = e.get_id();

	return candidate;
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例4: assess_danger

identified_danger assess_danger(
	const const_entity_handle& victim, 
	const const_entity_handle& danger
) {
	identified_danger result;

	const auto* const sentience = victim.find<components::sentience>();

	if (!sentience) {
		return result;
	}

	result.danger = danger;

	const auto* const missile = danger.find<invariants::missile>();
	const auto* const attitude = danger.find<components::attitude>();

	if ((!missile && !attitude) || (missile && danger.get<components::sender>().is_sender_subject(victim))) {
		return result;
	}

	const auto victim_pos = victim.get_logic_transform().pos;
	const auto danger_pos = danger.get_logic_transform().pos;
	const auto danger_vel = danger.get_owner_of_colliders().get_effective_velocity();
	const auto danger_dir = (danger_pos - victim_pos);
	const auto danger_distance = danger_dir.length();

	result.recommended_evasion = augs::danger_avoidance(victim_pos, danger_pos, danger_vel);
	result.recommended_evasion.normalize();

	const auto& sentience_def = victim.get<invariants::sentience>();
	const auto comfort_zone = sentience_def.comfort_zone;
	const auto comfort_zone_disturbance_ratio = augs::disturbance(danger_distance, comfort_zone);

	if (missile) {
		result.amount += comfort_zone_disturbance_ratio * missile->damage.base*4;
	}

	if (attitude) {
		const auto att = calc_attitude(danger, victim);
		
		if (is_hostile(att)) {
			result.amount += comfort_zone_disturbance_ratio * sentience_def.danger_amount_from_hostile_attitude;
		}
	}
	
	return result;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:48,代码来源:entity_scripts.cpp

示例5: destruct

void physics_system::destruct(const const_entity_handle handle) {
	if (is_constructed_rigid_body(handle)) {
		auto& cache = get_rigid_body_cache(handle);
		
		for (const auto& colliders_cache_id : cache.correspondent_colliders_caches)
			colliders_caches[colliders_cache_id] = colliders_cache();

		b2world->DestroyBody(cache.body);

		cache = rigid_body_cache();
	}
	
	if (is_constructed_colliders(handle)) {
		const auto this_cache_id = handle.get_id().pool.indirection_index;
		auto& cache = colliders_caches[this_cache_id];

		ensure(cache.correspondent_rigid_body_cache != -1);

		auto& owner_body_cache = rigid_body_caches[cache.correspondent_rigid_body_cache];

		for (const auto& f_per_c : cache.fixtures_per_collider)
			for (const auto f : f_per_c)
				owner_body_cache.body->DestroyFixture(f);

		remove_element(owner_body_cache.correspondent_colliders_caches, this_cache_id);
		cache = colliders_cache();
	}
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例6: spread_past_infection

void viewing_session::spread_past_infection(const const_logic_step step) {
	const auto& cosm = step.cosm;

	const auto& events = step.transient.messages.get_queue<messages::collision_message>();

	for (const auto& it : events) {
		const const_entity_handle subject_owner_body = cosm[it.subject].get_owner_body();
		const const_entity_handle collider_owner_body = cosm[it.collider].get_owner_body();

		auto& past_system = systems_audiovisual.get<past_infection_system>();

		if (past_system.is_infected(subject_owner_body) && !collider_owner_body.get_flag(entity_flag::IS_IMMUNE_TO_PAST)) {
			past_system.infect(collider_owner_body);
		}
	}
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: is_constructed_colliders

bool physics_system::is_constructed_colliders(const const_entity_handle handle) const {
	return 
		handle.alive() // && is_constructed_rigid_body(handle.get<components::fixtures>().get_owner_body())
		&& 
		get_colliders_cache(handle).fixtures_per_collider.size()> 0 && 
		get_colliders_cache(handle).fixtures_per_collider[0].size() > 0;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例8: set_updated_interpolated_transform

void interpolation_system::set_updated_interpolated_transform(
	const const_entity_handle subject,
	const transformr updated_value
) {
	auto& cache = per_entity_cache[subject];
	const auto& info = subject.get<components::interpolation>();
	
	cache.recorded_place_of_birth = info.place_of_birth;
	cache.interpolated_transform = updated_value;
	cache.recorded_version = subject.get_id().raw.version;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:11,代码来源:interpolation_system.cpp

示例9: assess_projectile_velocity_of_weapon

real32 assess_projectile_velocity_of_weapon(const const_entity_handle& weapon) {
	if (weapon.dead()) {
		return 0.f;
	}

	if (const auto* const gun_def = weapon.find<invariants::gun>()) {
		// TODO: Take into consideration the missile invariant found in the chamber
		return (gun_def->muzzle_velocity.first + gun_def->muzzle_velocity.second) / 2;
	}

	return 0.f;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:12,代码来源:entity_scripts.cpp

示例10: assign_item_to_hotbar_button

	void gui_element::assign_item_to_hotbar_button(
		const size_t button_index, 
		const entity_handle element_entity, 
		const const_entity_handle item
	) {
		clear_hotbar_selection_for_item(element_entity, item);

		ensure(item.get_owning_transfer_capability() == element_entity);

		auto& element = element_entity.get<components::gui_element>();
		element.hotbar_buttons[button_index].last_assigned_entity = item;
		LOG_NVPS(button_index);
	}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例11: make_pair

std::pair<size_t, size_t> physics_system::map_fixture_pointer_to_indices(const b2Fixture* const f, const const_entity_handle& handle) {
	const auto this_cache_id = handle.get_id().pool.indirection_index;
	const auto& cache = colliders_caches[this_cache_id];

	for (size_t collider_index = 0; collider_index < cache.fixtures_per_collider.size(); ++collider_index) {
		for (size_t convex_index = 0; convex_index < cache.fixtures_per_collider[collider_index].size(); ++convex_index) {
			if (cache.fixtures_per_collider[collider_index][convex_index] == f) {
				return std::make_pair(collider_index, convex_index);
			}
		}
	}

	ensure(false);
	return{};
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例12: calculate_space_occupied_with_children

unsigned calculate_space_occupied_with_children(const const_entity_handle item) {
	auto space_occupied = item.get<components::item>().get_space_occupied();

	if (item.find<components::container>()) {
		ensure(item.get<components::item>().charges == 1);

		for (auto& slot : item.get<components::container>().slots) {
			for (auto& entity_in_slot : slot.second.items_inside) {
				space_occupied += calculate_space_occupied_with_children(item.get_cosmos()[entity_in_slot]);
			}
		}
	}

	return space_occupied;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例13: get_attachment_offset

components::transform get_attachment_offset(
	const inventory_slot& slot, 
	const components::transform container_transform, 
	const const_entity_handle item
) {
	ensure(slot.is_physical_attachment_slot);

	components::transform total;

	const auto sticking = slot.attachment_sticking_mode;

	total = slot.attachment_offset;
	total.pos += item.get_aabb(components::transform()).get_size().get_sticking_offset(sticking);
	total.pos.rotate(container_transform.rotation, vec2(0, 0));

	return total;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例14: construct

void physics_system::construct(const const_entity_handle handle) {
	//ensure(!is_constructed_rigid_body(handle));
	if (is_constructed_rigid_body(handle))
		return;

	fixtures_construct(handle);

	if (handle.has<components::physics>()) {
		const auto& physics = handle.get<components::physics>();
		const auto& fixture_entities = physics.get_fixture_entities();

		if (physics.is_activated() && fixture_entities.size() > 0) {
			const auto& physics_data = physics.get_data();
			auto& cache = get_rigid_body_cache(handle);

			b2BodyDef def;

			switch (physics_data.body_type) {
			case components::physics::type::DYNAMIC: def.type = b2BodyType::b2_dynamicBody; break;
			case components::physics::type::STATIC: def.type = b2BodyType::b2_staticBody; break;
			case components::physics::type::KINEMATIC: def.type = b2BodyType::b2_kinematicBody; break;
			default:ensure(false) break;
			}

			def.userData = handle.get_id();
			def.bullet = physics_data.bullet;
			def.transform = physics_data.transform;
			def.sweep = physics_data.sweep;
			def.angularDamping = physics_data.angular_damping;
			def.linearDamping = physics_data.linear_damping;
			def.fixedRotation = physics_data.fixed_rotation;
			def.gravityScale = physics_data.gravity_scale;
			def.active = true;
			def.linearVelocity = physics_data.velocity;
			def.angularVelocity = physics_data.angular_velocity;

			cache.body = b2world->CreateBody(&def);
			cache.body->SetAngledDampingEnabled(physics_data.angled_damping);
			
			/* notice that all fixtures must be unconstructed at this moment since we assert that the rigid body itself is not */
			for (const auto& f : fixture_entities)
				fixtures_construct(f);
		}
	}
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例15: calc_reloadable_ammo_info

ammunition_information calc_reloadable_ammo_info(const const_entity_handle item) {
	ammunition_information out;

	const auto maybe_magazine_slot = item[slot_function::GUN_DETACHABLE_MAGAZINE];

	if (maybe_magazine_slot.alive() && maybe_magazine_slot.has_items()) {
		const auto mag = item.get_cosmos()[maybe_magazine_slot.get_items_inside()[0]];
		const auto ammo_depo = mag[slot_function::ITEM_DEPOSIT];

		ensure(ammo_depo->has_limited_space());

		out.total_charges += count_charges_in_deposit(mag);
		out.total_ammo_space += ammo_depo->space_available;
		out.available_ammo_space += ammo_depo.calc_local_space_available();
	}

	return out;
}
开发者ID:TeamHypersomnia,项目名称:Augmentations,代码行数:18,代码来源:entity_scripts.cpp


注:本文中的const_entity_handle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。