示例#1
0
	FBox Door::computeBBox(DoorState state) const {	
		float3 size = (float3)m_sprite.bboxSize();
		float maxs = max(size.x, size.z);
		
		FBox box;
		if(classId() == DoorClassId::sliding || state == DoorState::closed)
			box = FBox(float3(0, 0, 0), state == DoorState::opened_in? float3(0, 0, 0) : size);
		else if(state == DoorState::closing_in || state == DoorState::opening_in)
			box = FBox(-maxs + 1, 0, 0, 1, size.y, maxs);
		else if(state == DoorState::closing_out || state == DoorState::opening_out)
			box = FBox(0, 0, 0, maxs, size.y, maxs);
		else if(state == DoorState::opened_out)
			box = FBox(0, 0, 0, size.z, size.y, size.x);
		else if(state == DoorState::opened_in)
			box = FBox(-size.z + 1, 0, 0, 1, size.y, size.x);

		//TODO: this is still wrong
		FBox out = rotateY(box, size * 0.5f, dirAngle());
		out.min = (float3)(int3)out.min;
		out.max = (float3)(int3)out.max;
		DASSERT(classId() == DoorClassId::sliding || !out.empty());
		return out;
	}
示例#2
0
文件: actor.cpp 项目: nadult/FreeFT
Actor::Actor(Stream &sr)
    :EntityImpl(sr), m_actor(*m_proto.actor) {
    m_inventory.setDummyWeapon(Weapon(*m_actor.punch_weapon));

    u8 flags;
    sr.unpack(flags, m_stance, m_action);
    m_hit_points = decodeInt(sr);
    m_sound_variation = decodeInt(sr);
    m_client_id = decodeInt(sr);
    m_faction_id = decodeInt(sr);

    if(flags & 1)
        sr >> m_target_angle;
    else
        m_target_angle = dirAngle();
    sr >> m_inventory;
}

Actor::Actor(const XMLNode &node)
    :EntityImpl(node), m_actor(*m_proto.actor), m_stance(Stance::stand), m_inventory(node.child("inventory")),
     m_target_angle(dirAngle()), m_client_id(-1) {
    m_inventory.setDummyWeapon(Weapon(*m_actor.punch_weapon));
    m_sound_variation = node.attrib<int>("sound_variation") % m_actor.sounds.size();
    m_faction_id = node.attrib<int>("faction_id");
    m_hit_points = m_actor.hit_points;
    animate(Action::idle);
}

Actor::Actor(const Proto &proto, Stance stance)
    :EntityImpl(proto), m_actor(*m_proto.actor), m_stance(stance), m_target_angle(dirAngle()), m_client_id(-1) {
示例#3
0
文件: entity.cpp 项目: nadult/FreeFT
	const float2 Entity::dir() const {
		return angleToVector(dirAngle());
	}
示例#4
0
	Turret::Turret(const Proto &proto)
		:EntityImpl(proto), m_target_angle(dirAngle()) {
		m_hit_points = m_proto.hit_points;
		animate(TurretAction::idle);
	}
示例#5
0
	Turret::Turret(const XMLNode &node)
	  :EntityImpl(node), m_target_angle(dirAngle()) {
		m_hit_points = m_proto.hit_points;
		animate(TurretAction::idle);
	}
示例#6
0
	void Turret::nextFrame() {
		setDirAngle(blendAngles(dirAngle(), m_target_angle, constant::pi / 4.0f));
		ThinkingEntity::nextFrame();
	}