improve trainingmode collision sound

This commit is contained in:
milek7
2020-11-01 20:49:03 +01:00
parent 124f6bca0c
commit bbf0102e16
4 changed files with 16 additions and 5 deletions

View File

@@ -87,7 +87,7 @@ bool TEventLauncher::Load(cParser *parser)
parser->getTokens();
*parser >> token;
asEvent2Name = token; // drugi event
if ((asEvent2Name == "end") || (asEvent2Name == "condition"))
if ((asEvent2Name == "end") || (asEvent2Name == "condition") || (asEvent2Name == "traintriggered"))
{ // drugiego eventu może nie być, bo są z tym problemy, ale ciii...
token = asEvent2Name; // rozpoznane słowo idzie do dalszego przetwarzania
asEvent2Name = "none"; // a drugiego eventu nie ma
@@ -129,6 +129,10 @@ bool TEventLauncher::Load(cParser *parser)
parser->getTokens(); // słowo zamykające
*parser >> token;
}
if (token == "traintriggered")
{
train_triggered = true;
}
if( DeltaTime < 0 )
DeltaTime = -DeltaTime; // dla ujemnego zmieniamy na dodatni

View File

@@ -48,6 +48,7 @@ public:
TMemCell *MemCell { nullptr };
int iCheckMask { 0 };
double dRadius { 0.0 };
bool train_triggered { false };
private:
// methods

View File

@@ -124,9 +124,16 @@ basic_cell::update_events() {
// event launchers
for( auto *launcher : m_eventlaunchers ) {
glm::dvec3 campos = Global.pCamera.Pos;
double radius = launcher->dRadius;
if (launcher->train_triggered && simulation::Train) {
campos = simulation::Train->Dynamic()->HeadPosition();
radius *= Timer::GetDeltaTime() * simulation::Train->Dynamic()->GetVelocity() * 0.277;
}
if( launcher->check_conditions()
&& ( launcher->dRadius < 0.0
|| SquareMagnitude( launcher->location() - Global.pCamera.Pos ) < launcher->dRadius ) ) {
&& ( radius < 0.0
|| glm::distance2( launcher->location(), campos ) < launcher->dRadius ) ) {
if( launcher->check_activation() )
launch_event( launcher, true );
if( launcher->check_activation_key() )

View File

@@ -343,8 +343,7 @@ void state_manager::process_commands() {
std::getline(ss, data, ':');
TAnimModel *model = simulation::State.create_model(data, name, commanddata.location);
simulation::State.create_eventlauncher("node -1 0 launcher eventlauncher 0 0 0 " + std::to_string(model->radius())
+ " none -10000.0 obstacle_collision end", name + "_snd", commanddata.location);
simulation::State.create_eventlauncher("node -1 0 launcher eventlauncher 0 0 0 0.8 none -10000.0 obstacle_collision traintriggered end", name + "_snd", commanddata.location);
}
if (commanddata.command == user_command::deletemodel) {