Vehicle component has "CurrentRPM"

This commit is contained in:
Stiffly
2014-06-05 05:11:04 +02:00
parent 09971b2d77
commit ccc2c49317
5 changed files with 20 additions and 10 deletions
+2 -1
View File
@@ -12,7 +12,7 @@ struct Vehicle : Component
Vehicle()
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.0f), DownshiftRPM(1000.0f),
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ }
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f), currentRPM(0.0f){ }
float MaxTorque;
float MinRPM;
float OptimalRPM;
@@ -29,6 +29,7 @@ struct Vehicle : Component
float gearsRatio1;
float gearsRatio2;
float gearsRatio3;
float currentRPM;
Vehicle* Clone() const override { return new Vehicle(*this); }
};
+2 -1
View File
@@ -253,7 +253,8 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
}
}*/
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(car);
vehicleComponent->currentRPM = m_Vehicles[car]->calcRPM();
m_Vehicles[car]->getChassis()->activate();
+9 -7
View File
@@ -57,7 +57,7 @@ void Systems::SoundSystem::Update(double dt)
else
{
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
// m_DeleteSounds.erase(it->first);
m_DeleteSounds.erase(it->first);
it = m_DeleteChannels.erase(it);
}
@@ -104,7 +104,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
if(emitter)
{
FMOD_CHANNEL* channel = m_Channels[entity];
//FMOD_SOUND* sound = m_Sounds[entity];
FMOD_SOUND* sound = m_Sounds[entity];
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
@@ -137,9 +137,9 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev
float maxDist = emitter->MaxDistance;
float minDist = emitter->MinDistance;
float pitch = emitter->Pitch;
//LoadSound(sound, path, maxDist, minDist);
LoadSound(sound, path, maxDist, minDist);
m_Channels.insert(std::make_pair(emitter->Entity, channel));
// m_Sounds.insert(std::make_pair(emitter->Entity, sound));
m_Sounds.insert(std::make_pair(emitter->Entity, sound));
}
return true;
}
@@ -157,7 +157,7 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
//m_Sounds[eEntity] = *sound;
m_Sounds[eEntity] = *sound;
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
@@ -181,6 +181,8 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
return true;
}
bool Systems::SoundSystem::StopSound(const Events::StopSound &event)
{
auto eComp = m_World->GetComponent<Components::SoundEmitter>(event.Emitter);
@@ -222,8 +224,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type,
if(emitter)
{
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
//m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
m_Channels.erase(entity);
//m_Sounds.erase(entity);
m_Sounds.erase(entity);
}
}
+1
View File
@@ -53,6 +53,7 @@ private:
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
std::map<EntityID, FMOD_SOUND*> m_Sounds;
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
};
+6 -1
View File
@@ -445,9 +445,12 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
player->ID = playerID;
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
m_World->AddComponent<Components::Input>(tank);
m_World->AddComponent<Components::Listener>(tank);
auto health = m_World->AddComponent<Components::Health>(tank);
health->Amount = 100.f;
m_World->AddComponent<Components::Listener>(tank);
{
@@ -535,6 +538,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f));
auto cameraComp = m_World->AddComponent<Components::Camera>(cameraTower);
cameraComp->FarClip = 2000.f;
/*auto follow = m_World->AddComponent<Components::Follow>(cameraTower);
follow->Entity = barrel;
follow->Distance = 15.f;