Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
GameContext.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "GameContext.h"
23
24#include "AppContext.h"
25#include "Actor.h"
26#include "AeroEngine.h"
27#include "CacheSystem.h"
28#include "Collisions.h"
29#include "Console.h"
30#include "DashBoardManager.h"
31#include "Engine.h"
32#include "GfxScene.h"
33#include "GUIManager.h"
35#include "GUI_MainSelector.h"
36#include "GUI_TopMenubar.h"
37#include "InputEngine.h"
38#include "OverlayWrapper.h"
39#include "Replay.h"
40#include "ScrewProp.h"
41#include "ScriptEngine.h"
42#include "SkyManager.h"
43#include "SkyXManager.h"
44#include "SoundScriptManager.h"
45#include "Terrain.h"
46#include "Terrn2FileFormat.h"
47#include "TuneupFileFormat.h"
48#include "Utils.h"
49#include "VehicleAI.h"
50
51using namespace RoR;
52
54{
55 // Constructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++).
56}
57
59{
60 // Destructs `ActorPtr` - doesn't compile without `#include Actor.h` - not pretty if in header (even if auto-generated by C++).
61}
62
63// --------------------------------
64// Message queue
65
67{
68 std::lock_guard<std::mutex> lock(m_msg_mutex);
69 m_msg_queue.push(m);
71}
72
74{
75 std::lock_guard<std::mutex> lock(m_msg_mutex);
77 {
78
79 m_msg_chain_end->chain.push_back(m);
81 }
82 else
83 {
84 // Regular `PushMessage()`, just without the lock.
85 m_msg_queue.push(m);
87 }
88}
89
91{
92 std::lock_guard<std::mutex> lock(m_msg_mutex);
93 return !m_msg_queue.empty();
94}
95
97{
98 std::lock_guard<std::mutex> lock(m_msg_mutex);
99 ROR_ASSERT(m_msg_queue.size() > 0);
100 if (m_msg_chain_end == &m_msg_queue.front())
101 {
102 m_msg_chain_end = nullptr;
103 }
104 Message m = m_msg_queue.front();
105 m_msg_queue.pop();
106 return m;
107}
108
109// --------------------------------
110// Terrain
111
112bool GameContext::LoadTerrain(std::string const& filename_part)
113{
114 m_last_spawned_actor = nullptr;
115
116 // Find terrain in modcache
117 CacheEntryPtr terrn_entry = App::GetCacheSystem()->FindEntryByFilename(LT_Terrain, /*partial=*/true, filename_part);
118 if (!terrn_entry)
119 {
120 Str<200> msg; msg << _L("Terrain not found: ") << filename_part;
121 RoR::Log(msg.ToCStr());
122 App::GetGuiManager()->ShowMessageBox(_L("Terrain loading error"), msg.ToCStr());
123 return false;
124 }
125
126 // Init resources
127 App::GetCacheSystem()->LoadResource(terrn_entry);
128
129 // Load the terrain def file
130 Terrn2DocumentPtr terrn2;
131 std::string const& filename = terrn_entry->fname;
132 try
133 {
134 Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(filename);
135 LOG(" ===== LOADING TERRAIN " + filename);
136 Terrn2Parser parser;
137 terrn2 = parser.LoadTerrn2(stream);
138 if (!terrn2)
139 {
140 return false; // Errors already logged to console
141 }
142 }
143 catch (Ogre::Exception& e)
144 {
145 App::GetGuiManager()->ShowMessageBox(_L("Terrain loading error"), e.getFullDescription().c_str());
146 return false;
147 }
148 terrn_entry->terrn2_def = terrn2;
149
150 for (std::string const& assetpack_filename: terrn2->assetpack_files)
151 {
152 App::GetCacheSystem()->LoadAssetPack(terrn_entry, assetpack_filename);
153 }
154
155 // CAUTION - the global instance must be set during init! Needed by:
156 // * GameScript::spawnObject()
157 // * ProceduralManager
158 // * Landusemap
159 // * SurveyMapTextureCreator
160 // * Collisions (debug visualization)
161 m_terrain = new RoR::Terrain(terrn_entry, terrn2);
162 if (!m_terrain->initialize())
163 {
164 m_terrain = nullptr; // release local reference - object will be deleted when all references are released.
165 return false; // Message box already displayed
166 }
167
168 // Initialize envmap textures by rendering center of map
169 Ogre::Vector3 center = m_terrain->getMaxTerrainSize() / 2;
170 center.y = m_terrain->getHeightAt(center.x, center.z) + 1.0f;
171 App::GetGfxScene()->GetEnvMap().UpdateEnvMap(center, /*gfx_actor:*/nullptr, /*full:*/true);
172
173 // Scan groundmodels
175
176 return true;
177}
178
180{
181 if (m_terrain != nullptr)
182 {
183 // dispose(), do not `delete` - script may still hold reference to the object.
185 // release local reference - object will be deleted when all references are released.
186 m_terrain = nullptr;
187 }
188}
189
190// --------------------------------
191// Actors (physics and netcode)
192
194{
196 {
201
202 if (rq.asr_spawnbox == nullptr)
203 {
204 if (m_player_actor != nullptr)
205 {
206 float h = m_player_actor->getMaxHeight(true);
207 rq.asr_rotation = Ogre::Quaternion(Ogre::Degree(270) - Ogre::Radian(m_player_actor->getRotation()), Ogre::Vector3::UNIT_Y);
210 rq.asr_position.y += m_player_actor->getHeightAboveGroundBelow(h, true); // retain height above ground
211 }
212 else
213 {
214 Character* player_character = this->GetPlayerCharacter();
215 rq.asr_rotation = Ogre::Quaternion(Ogre::Degree(180) - player_character->getRotation(), Ogre::Vector3::UNIT_Y);
216 rq.asr_position = player_character->getPosition();
217 }
218 }
219 }
220
221 LOG(" ===== LOADING VEHICLE: " + rq.asr_filename);
222
223 if (rq.asr_cache_entry)
224 {
226 }
227 else
228 {
230 }
231
233 if (def == nullptr)
234 {
235 return nullptr; // Error already reported
236 }
237
238 if (rq.asr_skin_entry)
239 {
240 App::GetCacheSystem()->LoadResource(rq.asr_skin_entry); // Also loads associated .skin file.
241 if (!rq.asr_skin_entry->skin_def) // Make sure .skin was loaded OK.
242 {
243 rq.asr_skin_entry = nullptr; // Error already logged
244 }
245 }
246
247 if (App::sim_tuning_enabled->getBool() && (App::mp_state->getEnum<MpState>() != MpState::CONNECTED))
248 {
249 if (rq.asr_tuneup_entry)
250 {
251 App::GetCacheSystem()->LoadResource(rq.asr_tuneup_entry); // Also loads associated .tuneup file.
253 {
254 rq.asr_tuneup_entry = nullptr; // Error already logged
255 }
256 }
257 }
258 else
259 {
260 rq.asr_working_tuneup = nullptr; // Make sure no tuneup is used
261 }
262
263#ifdef USE_SOCKETW
265 {
266 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
267 {
270 rq.asr_net_color = info.colournum;
271 }
272 }
273#endif //SOCKETW
274
275 ActorPtr fresh_actor = m_actor_manager.CreateNewActor(rq, def);
276 bool fresh_actor_seat_player = false;
277
278 // lock slide nodes after spawning the actor?
279 if (def->slide_nodes_connect_instantly)
280 {
281 fresh_actor->toggleSlideNodeLock(); // OK to invoke here - processing MSG_SIM_ACTOR_SPAWN_REQUESTED
282 }
283
285 {
286 m_last_spawned_actor = fresh_actor;
287 if (fresh_actor->ar_driveable != NOT_DRIVEABLE)
288 {
289 fresh_actor_seat_player = true;
290 }
291 if (rq.asr_spawnbox == nullptr)
292 {
293 // Try to resolve collisions with other actors
294 fresh_actor->resolveCollisions(50.0f, m_player_actor == nullptr);
295 }
296 }
298 {
299 if (fresh_actor->ar_driveable != NOT_DRIVEABLE &&
300 fresh_actor->ar_num_nodes > 0 &&
302 {
303 fresh_actor_seat_player = true;
304 }
305 }
307 {
308 if (rq.asr_terrn_machine)
309 {
310 fresh_actor->ar_driveable = MACHINE;
311 }
312 }
314 {
315 fresh_actor->ar_driveable = AI;
317
318 if (fresh_actor->ar_engine)
319 {
321 fresh_actor->ar_engine->autoShiftSet(Engine::DRIVE);
322 }
323 }
325 {
326 fresh_actor->ar_net_source_id = rq.net_source_id;
327 fresh_actor->ar_net_stream_id = rq.net_stream_id;
328
330 {
332 }
334 {
336 }
337 }
339 {
340 if (rq.asr_saved_state)
341 {
343 req->amr_actor = fresh_actor->ar_instance_id;
347 }
348 }
349 else
350 {
351 if (fresh_actor->ar_driveable != NOT_DRIVEABLE &&
353 rq.asr_enter)
354 {
355 fresh_actor_seat_player = true;
356 }
357 }
358
359 if (fresh_actor_seat_player)
360 {
362 // Loading all addonparts to resolve conflicts is slow and would cause huge UI lag if not forced now. Do it right after player was seated in the actor.
364 }
365
366 return fresh_actor;
367}
368
370{
372
373 if (!actor)
374 {
375 return;
376 }
377
379 {
380 actor->SoftReset();
381 }
383 {
384 actor->SyncReset(/*reset_position:*/false);
385 }
387 {
388 actor->SyncReset(/*reset_position:*/true);
389 }
391 {
393 }
396 {
398 actor->ar_sleep_counter = 0.0f;
399 }
401 {
402 if (actor->getUsedActorEntry()->deleted)
403 {
405 fmt::format(_LC("GameContext", "Cannot reload '{}' ({}) - the associated modcache entry was deleted."),
406 actor->getUsedActorEntry()->dname, actor->getUsedActorEntry()->fname));
407 return;
408 }
409
410 // Create spawn request while actor still exists
412 srq->asr_position = Ogre::Vector3(actor->getPosition().x, actor->getMinHeight(), actor->getPosition().z);
413 srq->asr_rotation = Ogre::Quaternion(Ogre::Degree(270) - Ogre::Radian(actor->getRotation()), Ogre::Vector3::UNIT_Y);
414 srq->asr_config = actor->getSectionConfig();
415 srq->asr_skin_entry = actor->getUsedSkinEntry();
417 srq->asr_cache_entry= actor->getUsedActorEntry();
418 srq->asr_debugview = (int)actor->GetGfxActor()->GetDebugView();
420
421 // This deletes all actors using the resource bundle, including the one we're reloading.
423
424 // Load our actor again, but only after all actors are deleted.
426 }
428 {
430 }
432 {
435 }
436}
437
439{
440 if (actor == m_player_actor)
441 {
442 Ogre::Vector3 center = m_player_actor->getRotationCenter();
443 this->ChangePlayerActor(nullptr); // Get out of the vehicle
444 this->GetPlayerCharacter()->setPosition(center);
445 // Update scene SimBuffer immediatelly to prevent having dangling pointer.
447 }
448
449 if (actor == m_prev_player_actor)
450 {
451 m_prev_player_actor = nullptr;
452 }
453
454 if (actor == m_last_spawned_actor)
455 {
456 m_last_spawned_actor = nullptr;
457 }
458
459 // Find linked actors and un-tie if tied
460 for (auto actorx : m_actor_manager.GetLocalActors())
461 {
462 if (actorx->isTied() && std::find(actor->ar_linked_actors.begin(), actor->ar_linked_actors.end(), actorx) != actor->ar_linked_actors.end())
463 {
464 actorx->tieToggle(); // OK to invoke here - processing MSG_SIM_DELETE_ACTOR_REQUESTED
465 }
466
467 if (actorx->isLocked() && std::find(actor->ar_linked_actors.begin(), actor->ar_linked_actors.end(), actorx) != actor->ar_linked_actors.end())
468 {
469 actorx->hookToggle(); // OK to invoke here - processing MSG_SIM_DELETE_ACTOR_REQUESTED
470 }
471 }
472
474
475#ifdef USE_SOCKETW
476 if (App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
477 {
479 }
480#endif //SOCKETW
481
483
485}
486
488{
489 ActorPtr prev_player_actor = m_player_actor;
490 m_player_actor = actor;
491
492 // hide any old dashes
493 if (prev_player_actor && prev_player_actor->ar_dashboard)
494 {
495 prev_player_actor->ar_dashboard->setVisible3d(false);
496 }
497 // show new
499 {
501 }
502
503 if (prev_player_actor)
504 {
505 App::GetOverlayWrapper()->showDashboardOverlays(false, prev_player_actor);
506
507 prev_player_actor->GetGfxActor()->SetRenderdashActive(false);
508
509 SOUND_STOP(prev_player_actor, SS_TRIG_AIR);
510 SOUND_STOP(prev_player_actor, SS_TRIG_PUMP);
511 }
512
513 if (m_player_actor == nullptr)
514 {
515 // getting outside
516
517 if (prev_player_actor)
518 {
520 {
522 }
523
524 prev_player_actor->prepareInside(false);
525
526 // get player out of the vehicle
527 float h = prev_player_actor->getMinCameraRadius();
528 float rotation = prev_player_actor->getRotation() - Ogre::Math::HALF_PI;
529 Ogre::Vector3 position = prev_player_actor->getPosition();
530 if (prev_player_actor->ar_cinecam_node[0] != NODENUM_INVALID)
531 {
532 // actor has a cinecam (find optimal exit position)
533 Ogre::Vector3 l = position - 2.0f * prev_player_actor->GetCameraRoll();
534 Ogre::Vector3 r = position + 2.0f * prev_player_actor->GetCameraRoll();
535 float l_h = m_terrain->GetCollisions()->getSurfaceHeightBelow(l.x, l.z, l.y + h);
536 float r_h = m_terrain->GetCollisions()->getSurfaceHeightBelow(r.x, r.z, r.y + h);
537 position = std::abs(r.y - r_h) * 1.2f < std::abs(l.y - l_h) ? r : l;
538 }
539 position.y = m_terrain->GetCollisions()->getSurfaceHeightBelow(position.x, position.z, position.y + h);
540
541 Character* player_character = this->GetPlayerCharacter();
542 if (player_character)
543 {
544 player_character->SetActorCoupling(false, nullptr);
545 player_character->setRotation(Ogre::Radian(rotation));
546 player_character->setPosition(position);
547 }
548 }
549
551
552 TRIGGER_EVENT_ASYNC(SE_TRUCK_EXIT, prev_player_actor?prev_player_actor->ar_instance_id:-1);
553 }
554 else
555 {
556 // getting inside
558 !App::GetGuiManager()->IsGuiHidden(), m_player_actor);
559
561 {
563 }
564
566
567 // force feedback
569
570 // attach player to vehicle
571 Character* player_character = this->GetPlayerCharacter();
572 if (player_character)
573 {
574 player_character->SetActorCoupling(true, m_player_actor);
575 }
576
578
580 }
581
582 if (prev_player_actor != nullptr || m_player_actor != nullptr)
583 {
585 }
586
588}
589
594
599
604
605ActorPtr GameContext::FindActorByCollisionBox(std::string const & ev_src_instance_name, std::string const & box_name)
606{
608 ev_src_instance_name, box_name);
609}
610
623
624void GameContext::SpawnPreselectedActor(std::string const& preset_vehicle, std::string const& preset_veh_config)
625{
627 LT_AllBeam, /*partial=*/true, preset_vehicle);
628
629 if (!entry)
630 return;
631
633 rq->asr_cache_entry = entry;
635 rq->asr_rotation = Ogre::Quaternion(Ogre::Degree(180) - this->GetPlayerCharacter()->getRotation(), Ogre::Vector3::UNIT_Y);
637
638 RoR::LogFormat("[RoR|Diag] Preselected Truck: %s (%s)", entry->dname.c_str(), entry->fname.c_str());
639
640 // Section config lookup
641 if (!entry->sectionconfigs.empty())
642 {
643 if (std::find(entry->sectionconfigs.begin(), entry->sectionconfigs.end(),
644 preset_veh_config)
645 == entry->sectionconfigs.end())
646 {
647 // Preselected config doesn't exist -> use first available one
648 rq->asr_config = entry->sectionconfigs[0];
649 }
650 else
651 {
652 rq->asr_config = preset_veh_config;
653 }
654 RoR::LogFormat("[RoR|Diag] Preselected Truck Config: %s", rq->asr_config.c_str());
655 }
656
658}
659
660void GameContext::ShowLoaderGUI(int type, const Ogre::String& instance, const Ogre::String& box)
661{
662 // first, test if the place if clear, BUT NOT IN MULTIPLAYER
663 if (!(App::mp_state->getEnum<MpState>() == MpState::CONNECTED))
664 {
665 collision_box_t* spawnbox = m_terrain->GetCollisions()->getBox(instance, box);
666 for (ActorPtr& actor : this->GetActorManager()->GetActors())
667 {
668 for (int i = 0; i < actor->ar_num_nodes; i++)
669 {
670 if (m_terrain->GetCollisions()->isInside(actor->ar_nodes[i].AbsPosition, spawnbox))
671 {
672 App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("Please clear the place first"), "error.png");
673 return;
674 }
675 }
676 }
677 }
678
682
684 m.payload = reinterpret_cast<void*>(new LoaderType(LoaderType(type)));
686}
687
689{
691
692 if (App::GetGuiManager()->TopMenubar.ai_select)
693 {
696 }
697 if (App::GetGuiManager()->TopMenubar.ai_select2)
698 {
701 }
702}
703
704void GameContext::OnLoaderGuiApply(LoaderType type, CacheEntryPtr entry, std::string sectionconfig)
705{
706 bool spawn_now = false;
707 switch (type)
708 {
709 case LT_AddonPart:
710 if (m_player_actor)
711 {
714 req->mpr_subject = entry->fname;
717 }
718 break;
719
720 case LT_Skin:
721 if (entry != m_dummy_cache_selection)
722 {
724 if (App::GetGuiManager()->TopMenubar.ai_select)
725 {
727 }
728 if (App::GetGuiManager()->TopMenubar.ai_select2)
729 {
731 }
732 }
733 spawn_now = true;
734 break;
735
736 case LT_Vehicle:
737 case LT_Truck:
738 case LT_Car:
739 case LT_Boat:
740 case LT_Airplane:
741 case LT_Trailer:
742 case LT_Train:
743 case LT_Load:
744 case LT_Extension:
745 case LT_AllBeam:
747 m_current_selection.asr_config = sectionconfig;
748 if (App::GetGuiManager()->TopMenubar.ai_select)
749 {
751 }
752 if (App::GetGuiManager()->TopMenubar.ai_select2)
753 {
755 }
757 // Look for extra skins
758 if (!entry->guid.empty())
759 {
760 CacheQuery skin_query;
761 skin_query.cqy_filter_guid = entry->guid;
762 skin_query.cqy_filter_type = LT_Skin;
763 size_t num_skins = App::GetCacheSystem()->Query(skin_query);
764 // Determine default skin
765 CacheEntryPtr default_skin_entry = nullptr;
766 if (entry->default_skin != "")
767 {
768 for (CacheQueryResult& res : skin_query.cqy_results)
769 {
770 if (res.cqr_entry->dname == entry->default_skin)
771 default_skin_entry = res.cqr_entry;
772 }
773 if (!default_skin_entry)
774 {
776 fmt::format(_L("Default skin '{}' for actor '{}' not found!"), entry->default_skin, entry->dname));
777 }
778 if (default_skin_entry && num_skins == 1)
779 {
780 m_current_selection.asr_skin_entry = default_skin_entry;
781 }
782 }
783 else
784 {
785 default_skin_entry = m_dummy_cache_selection;
786 default_skin_entry->dname = "Default skin";
787 default_skin_entry->description = "Original, unmodified skin";
788 }
789
790 if (!m_current_selection.asr_skin_entry && num_skins > 0)
791 {
792 App::GetGuiManager()->MainSelector.Show(LT_Skin, entry->guid, default_skin_entry); // Intentionally not using MSG_
793 }
794 else
795 {
796 spawn_now = true;
797 }
798 }
799 else
800 {
801 spawn_now = true;
802 }
803 break;
804
805 default:;
806 }
807
808 if (spawn_now)
809 {
810 if (App::GetGuiManager()->TopMenubar.ai_select)
811 {
816 }
817 else if (App::GetGuiManager()->TopMenubar.ai_select2)
818 {
823 }
824 else
825 {
829 }
830
832 }
833}
834
836
837// --------------------------------
838// Characters
839
841{
843
844 // Adjust character position and rotation
845 Ogre::Vector3 spawn_pos = m_terrain->getSpawnPos();
846 Ogre::Degree spawn_rot(0.f);
847
848 if (m_terrain->GetDef()->start_rotation_specified)
849 {
850 spawn_rot = m_terrain->GetDef()->start_rotation;
851 }
852 else if (!m_terrain->HasPredefinedActors())
853 {
854 // Classic behavior, retained for compatibility.
855 // Required for maps like N-Labs or F1 Track.
856 spawn_rot = 180.0f;
857 }
858
859 // Preset position - commandline has precedence
860 if (App::cli_preset_spawn_pos->getStr() != "")
861 {
862 spawn_pos = Ogre::StringConverter::parseVector3(App::cli_preset_spawn_pos->getStr(), spawn_pos);
864 }
865 else if (App::diag_preset_spawn_pos->getStr() != "")
866 {
867 spawn_pos = Ogre::StringConverter::parseVector3(App::diag_preset_spawn_pos->getStr(), spawn_pos);
869 }
870
871 // Preset rotation - commandline has precedence
872 if (App::cli_preset_spawn_rot->getStr() != "")
873 {
874 spawn_rot = Ogre::StringConverter::parseReal(App::cli_preset_spawn_rot->getStr(), spawn_rot.valueDegrees());
876 }
877 else if (App::diag_preset_spawn_rot->getStr() != "")
878 {
879 spawn_rot = Ogre::StringConverter::parseReal(App::diag_preset_spawn_rot->getStr(), spawn_rot.valueDegrees());
881 }
882
883 spawn_pos.y = m_terrain->GetCollisions()->getSurfaceHeightBelow(spawn_pos.x, spawn_pos.z, spawn_pos.y + 1.8f);
884
885 this->GetPlayerCharacter()->setPosition(spawn_pos);
886 this->GetPlayerCharacter()->setRotation(spawn_rot);
887
888 App::GetCameraManager()->GetCameraNode()->setPosition(this->GetPlayerCharacter()->getPosition());
889
890 // Small hack to improve the spawn experience
891 for (int i = 0; i < 100; i++)
892 {
894 }
895}
896
897Character* GameContext::GetPlayerCharacter() // Convenience ~ counterpart of `GetPlayerActor()`
898{
900}
901
902// --------------------------------
903// Gameplay feats
904
906{
908 if (!this->GetPlayerActor())
909 {
910 this->GetPlayerCharacter()->setPosition(Ogre::Vector3(x, y, z));
911 return;
912 }
913
914 TRIGGER_EVENT_ASYNC(SE_TRUCK_TELEPORT, this->GetPlayerActor()->ar_instance_id);
915
916 Ogre::Vector3 translation = Ogre::Vector3(x, y, z) - this->GetPlayerActor()->ar_nodes[0].AbsPosition;
917
918 std::vector<ActorPtr> actorsToBeamUp;
919 actorsToBeamUp.assign(this->GetPlayerActor()->ar_linked_actors.begin(), this->GetPlayerActor()->ar_linked_actors.end());
920 actorsToBeamUp.push_back(this->GetPlayerActor());
921
922 float src_agl = std::numeric_limits<float>::max();
923 float dst_agl = std::numeric_limits<float>::max();
924 for (ActorPtr& actor : actorsToBeamUp)
925 {
926 for (int i = 0; i < actor->ar_num_nodes; i++)
927 {
928 Ogre::Vector3 pos = actor->ar_nodes[i].AbsPosition;
929 src_agl = std::min(pos.y - m_terrain->GetCollisions()->getSurfaceHeight(pos.x, pos.z), src_agl);
930 pos += translation;
931 dst_agl = std::min(pos.y - m_terrain->GetCollisions()->getSurfaceHeight(pos.x, pos.z), dst_agl);
932 }
933 }
934
935 translation += Ogre::Vector3::UNIT_Y * (std::max(0.0f, src_agl) - dst_agl);
936
937 for (ActorPtr& actor : actorsToBeamUp)
938 {
939 actor->resetPosition(actor->ar_nodes[0].AbsPosition + translation, false);
940 }
941}
942
944{
945 // Generic escape key event
946 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_QUIT_GAME))
947 {
948 if (App::app_state->getEnum<AppState>() == AppState::MAIN_MENU)
949 {
950 if (App::GetGuiManager()->GameAbout.IsVisible())
951 {
953 }
954 else if (App::GetGuiManager()->MainSelector.IsVisible())
955 {
957 }
958 else if (App::GetGuiManager()->GameSettings.IsVisible())
959 {
961 }
962 else if (App::GetGuiManager()->GameControls.IsVisible())
963 {
965 }
966 else if (App::GetGuiManager()->MultiplayerSelector.IsVisible())
967 {
969 }
970 else if (App::GetGuiManager()->RepositorySelector.IsVisible())
971 {
973 }
974 else
975 {
977 }
978 }
979 else if (App::app_state->getEnum<AppState>() == AppState::SIMULATION)
980 {
981 if (App::GetGuiManager()->MainSelector.IsVisible())
982 {
984 }
985 else if (App::GetGuiManager()->GameControls.IsVisible())
986 {
988 }
989 else if (App::sim_state->getEnum<SimState>() == SimState::RUNNING)
990 {
992 if (App::mp_state->getEnum<MpState>() != MpState::CONNECTED)
993 {
995 }
996 }
997 else if (App::sim_state->getEnum<SimState>() == SimState::PAUSED)
998 {
1001 }
1002 }
1003 }
1004
1005 // screenshot
1006 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_SCREENSHOT, 0.25f))
1007 {
1009 }
1010
1011 // fullscreen toggle
1012 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_FULLSCREEN_TOGGLE, 2.0f))
1013 {
1014 if (App::GetAppContext()->GetRenderWindow()->isFullScreen())
1016 else
1018 }
1019
1020 // render mode
1021 switch (App::gfx_polygon_mode->getEnum<Ogre::PolygonMode>())
1022 {
1023 case 1: App::GetCameraManager()->GetCamera()->setPolygonMode(Ogre::PM_SOLID); break;
1024 case 2: App::GetCameraManager()->GetCamera()->setPolygonMode(Ogre::PM_WIREFRAME); break;
1025 case 3: App::GetCameraManager()->GetCamera()->setPolygonMode(Ogre::PM_POINTS); break;
1026 }
1027
1028 // Write player position to log
1029 if (App::app_state->getEnum<AppState>() == AppState::SIMULATION &&
1030 App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_OUTPUT_POSITION))
1031 {
1032 Ogre::Vector3 position(Ogre::Vector3::ZERO);
1033 Ogre::Radian rotation(0);
1034 if (this->GetPlayerActor() == nullptr)
1035 {
1036 position = this->GetPlayerCharacter()->getPosition();
1037 rotation = this->GetPlayerCharacter()->getRotation() + Ogre::Radian(Ogre::Math::PI);
1038 }
1039 else
1040 {
1041 position = this->GetPlayerActor()->getPosition();
1042 rotation = this->GetPlayerActor()->getRotation();
1043 }
1044 Ogre::String pos = Ogre::StringUtil::format("%8.3f, %8.3f, %8.3f" , position.x, position.y, position.z);
1045 Ogre::String rot = Ogre::StringUtil::format("% 6.1f, % 6.1f, % 6.1f", 0.0f, rotation.valueDegrees() , 0.0f);
1046 LOG("Position: " + pos + ", " + rot);
1047 }
1048
1049 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_RESET_MODE))
1050 {
1054 (App::sim_soft_reset_mode->getBool()) ? _L("Enabled soft reset mode") : _L("Enabled hard reset mode"));
1055 }
1056}
1057
1059{
1060 // get new vehicle
1061 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_GET_NEW_VEHICLE))
1062 {
1064 m.payload = reinterpret_cast<void*>(new LoaderType(LT_AllBeam));
1066 }
1067
1068 // Enter/exit truck - With a toggle delay
1069 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_ENTER_OR_EXIT_TRUCK, 0.5f))
1070 {
1071 if (this->GetPlayerActor() == nullptr) // no vehicle
1072 {
1073 // find the nearest vehicle
1074 float mindist = 1000.0;
1075 ActorPtr nearest_actor = nullptr;
1076 for (ActorPtr& actor : this->GetActorManager()->GetActors())
1077 {
1078 if (!actor->ar_driveable)
1079 continue;
1080 if (actor->ar_cinecam_node[0] == NODENUM_INVALID)
1081 {
1082 LOG("cinecam missing, cannot enter the actor!");
1083 continue;
1084 }
1085 float len = 0.0f;
1086 if (this->GetPlayerCharacter())
1087 {
1088 len = actor->ar_nodes[actor->ar_cinecam_node[0]].AbsPosition.distance(this->GetPlayerCharacter()->getPosition() + Ogre::Vector3(0.0, 2.0, 0.0));
1089 }
1090 if (len < mindist)
1091 {
1092 mindist = len;
1093 nearest_actor = actor;
1094 }
1095 }
1096
1097 if (mindist < 20.0)
1098 {
1099 this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(nearest_actor))));
1100 }
1101 }
1102 else // We're in a vehicle -> If moving slowly enough, get out
1103 {
1104 if (this->GetPlayerActor()->ar_nodes[0].Velocity.squaredLength() < 1.0f ||
1105 this->GetPlayerActor()->ar_state == ActorState::NETWORKED_OK || this->GetPlayerActor()->ar_state == ActorState::NETWORKED_HIDDEN ||
1106 this->GetPlayerActor()->ar_driveable == AI)
1107 {
1108 this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr())));
1109 }
1110 }
1111 }
1112
1113 // enter next truck
1114 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_ENTER_NEXT_TRUCK, 0.25f))
1115 {
1116 ActorPtr actor = this->FetchNextVehicleOnList();
1117 if (actor != this->GetPlayerActor())
1118 {
1119 this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(actor))));
1120 }
1121 }
1122
1123 // enter previous truck
1124 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_ENTER_PREVIOUS_TRUCK, 0.25f))
1125 {
1126 ActorPtr actor = this->FetchPrevVehicleOnList();
1127 if (actor != this->GetPlayerActor())
1128 {
1129 this->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(actor))));
1130 }
1131 }
1132
1133 // respawn last truck
1134 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_RESPAWN_LAST_TRUCK, 0.25f))
1135 {
1136 this->RespawnLastActor();
1137 }
1138
1139 // terrain editor toggle
1141 {
1143 }
1144
1145 // forward commands from character
1146 ActorPtr actor_to_reset_commandkeys;
1147 if (!m_player_actor)
1148 {
1149 // Find nearest actor
1150 const Ogre::Vector3 position = App::GetGameContext()->GetPlayerCharacter()->getPosition();
1151 ActorPtr nearest_actor = nullptr;
1152 float min_squared_distance = std::numeric_limits<float>::max();
1154 {
1155 float squared_distance = position.squaredDistance(actor->ar_nodes[0].AbsPosition);
1156 if (squared_distance < min_squared_distance)
1157 {
1158 min_squared_distance = squared_distance;
1159 nearest_actor = actor;
1160 }
1161 }
1162
1163 // Evaluate
1164 if (nearest_actor != nullptr &&
1165 nearest_actor->ar_import_commands &&
1166 min_squared_distance < (nearest_actor->getMinCameraRadius()*nearest_actor->getMinCameraRadius()))
1167 {
1168 if (nearest_actor != m_actor_remotely_receiving_commands)
1169 {
1170 actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
1171 }
1173
1174 // get commands
1175 for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
1176 {
1177 int eventID = EV_COMMANDS_01 + (i - 1);
1178
1179 const float eventVal = RoR::App::GetInputEngine()->getEventValue(eventID);
1180 if (eventVal != nearest_actor->ar_command_key[i].playerInputValue
1181 && nearest_actor->ar_state == ActorState::LOCAL_SLEEPING)
1182 {
1183 // Wake up
1184 nearest_actor->ar_state = ActorState::LOCAL_SIMULATED;
1185 nearest_actor->ar_sleep_counter = 0.0f;
1186 }
1187
1188 nearest_actor->ar_command_key[i].playerInputValue = eventVal;
1189 }
1190 }
1191 else
1192 {
1194 {
1195 // Just left the vicinity of the actor, but still on foot
1196 actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
1198 }
1199 }
1200 }
1202 {
1203 // Just left the vicinity of the actor by entering vehicle
1204 actor_to_reset_commandkeys = m_actor_remotely_receiving_commands;
1206 }
1207
1208 if (actor_to_reset_commandkeys)
1209 {
1210 for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
1211 {
1212 actor_to_reset_commandkeys->ar_command_key[i].playerInputValue = 0.f;
1213 }
1214 actor_to_reset_commandkeys = nullptr;
1215 }
1216
1217 // AI waypoint recording
1218 if (App::GetGuiManager()->TopMenubar.ai_rec)
1219 {
1220 if (m_timer.getMilliseconds() > 1000) // Don't spam it, record every 1 sec
1221 {
1222 if (App::GetGameContext()->GetPlayerActor()) // We are in vehicle
1223 {
1224 if (App::GetGameContext()->GetPlayerActor()->getPosition().distance(prev_pos) >= 5) // Skip very close positions
1225 {
1226 ai_events waypoint;
1228 waypoint.speed = App::GetGameContext()->GetPlayerActor()->getWheelSpeed() * 3.6;
1229 if (waypoint.speed < 5)
1230 {
1231 waypoint.speed = -1;
1232 }
1233 App::GetGuiManager()->TopMenubar.ai_waypoints.push_back(waypoint);
1234 }
1236 }
1237 else // We are in feet
1238 {
1239 if (App::GetGameContext()->GetPlayerCharacter()->getPosition() != prev_pos) // Skip same positions
1240 {
1241 ai_events waypoint;
1243 App::GetGuiManager()->TopMenubar.ai_waypoints.push_back(waypoint);
1244 }
1246 }
1247 m_timer.reset();
1248 }
1249 }
1250 else
1251 {
1252 prev_pos = Ogre::Vector3::ZERO;
1253 }
1254}
1255
1257{
1258#ifdef USE_CAELUM
1259 if (App::gfx_sky_mode->getEnum<GfxSkyMode>() == GfxSkyMode::CAELUM &&
1261 {
1262 float time_factor = 1.0f;
1263
1264 if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_INCREASE_TIME))
1265 {
1266 time_factor = 1000.0f;
1267 }
1268 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_INCREASE_TIME_FAST))
1269 {
1270 time_factor = 10000.0f;
1271 }
1272 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_DECREASE_TIME))
1273 {
1274 time_factor = -1000.0f;
1275 }
1276 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_DECREASE_TIME_FAST))
1277 {
1278 time_factor = -10000.0f;
1279 }
1280 else if (App::gfx_sky_time_cycle->getBool())
1281 {
1282 time_factor = App::gfx_sky_time_speed->getInt();
1283 }
1284
1285 if (m_terrain->getSkyManager()->GetSkyTimeFactor() != time_factor)
1286 {
1287 m_terrain->getSkyManager()->SetSkyTimeFactor(time_factor);
1288 Str<200> msg; msg << _L("Time set to ") << m_terrain->getSkyManager()->GetPrettyTime();
1290 }
1291 }
1292
1293#endif // USE_CAELUM
1294 if (App::gfx_sky_mode->getEnum<GfxSkyMode>() == GfxSkyMode::SKYX &&
1296 {
1297 if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_INCREASE_TIME))
1298 {
1300 }
1301 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_INCREASE_TIME_FAST))
1302 {
1304 }
1305 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_DECREASE_TIME))
1306 {
1308 }
1309 else if (RoR::App::GetInputEngine()->getEventBoolValue(EV_SKY_DECREASE_TIME_FAST))
1310 {
1312 }
1313 else
1314 {
1316 }
1317 }
1318}
1319
1321{
1323
1324 // reload current truck
1325 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCKEDIT_RELOAD, 0.5f))
1326 {
1331 }
1332
1333 // remove current truck
1334 if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_REMOVE_CURRENT_TRUCK))
1335 {
1337 }
1338
1339 // Front lights
1340 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_TRUCK_LOW_BEAMS))
1341 {
1343 // sync sidelights to lowbeams
1345 }
1346 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_CYCLE_TRUCK_LIGHTS))
1347 {
1348 // Smart cycling:
1349 // 1) all lights off
1350 // 2) sidelights on but only if any installed, otherwise skip to 3).
1351 // 3) sidelights and lowbeams on.
1352 // 4) sidelights, lowbeams and highbeams on, but only if highbeams are installed, otherwise cycle to 1).
1354 {
1356 }
1358 {
1361 }
1363 {
1367 }
1368 else
1369 {
1373 }
1374 }
1375 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_TRUCK_HIGH_BEAMS))
1376 {
1378 }
1379 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_TRUCK_FOG_LIGHTS))
1380 {
1382 }
1383
1384 // Beacons
1385 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_TRUCK_BEACONS))
1386 {
1388 }
1389
1390 // blinkers
1391 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_BLINK_LEFT))
1393
1394 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_BLINK_RIGHT))
1396
1397 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_BLINK_WARN))
1399
1400 // custom lights
1401 for (int i = 0; i < MAX_CLIGHTS; i++)
1402 {
1403 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_LIGHTTOGGLE01 + i))
1405 }
1406
1407 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TRUCK_REMOVE))
1408 {
1410 }
1411
1412 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_ROPELOCK))
1413 {
1415 }
1416
1417 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_LOCK))
1418 {
1419 //m_player_actor->hookToggle(-1, HOOK_TOGGLE, -1);
1424
1425 //m_player_actor->toggleSlideNodeLock();
1426 ActorLinkingRequest* slidenode_rq = new ActorLinkingRequest();
1430 }
1431
1432 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_AUTOLOCK))
1433 {
1434 m_player_actor->hookToggle(-2, ActorLinkingRequestType::HOOK_UNLOCK, -1); //unlock all autolocks
1435 }
1436
1437 //strap
1438 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_SECURE_LOAD))
1439 {
1441 }
1442
1443 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_CUSTOM_PARTICLES))
1444 {
1446 }
1447
1448 if (App::GetInputEngine()->getEventBoolValueBounce(EV_COMMON_TOGGLE_DEBUG_VIEW))
1449 {
1452 {
1453 actor->GetGfxActor()->SetDebugView(m_player_actor->GetGfxActor()->GetDebugView());
1454 }
1455 }
1456
1458 {
1461 {
1462 actor->GetGfxActor()->SetDebugView(m_player_actor->GetGfxActor()->GetDebugView());
1463 }
1464 }
1465
1469 {
1470 ActorPtr rescuer = nullptr;
1472 {
1473 if (actor->ar_rescuer_flag)
1474 {
1475 rescuer = actor;
1476 }
1477 }
1478 if (rescuer == nullptr)
1479 {
1481 }
1482 else
1483 {
1484 App::GetGameContext()->PushMessage(Message(MSG_SIM_SEAT_PLAYER_REQUESTED, static_cast<void*>(new ActorPtr(rescuer))));
1485 }
1486 }
1487
1488 // parking brake
1489 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TRAILER_PARKING_BRAKE))
1490 {
1495 }
1496
1497 // videocam
1498 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_VIDEOCAMERA, 0.5f))
1499 {
1501 {
1503 }
1504 else
1505 {
1507 }
1508 }
1509
1510 // enter/exit truck - Without a delay: the vehicle must brake like braking normally
1511 if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_ENTER_OR_EXIT_TRUCK))
1512 {
1514 {
1515 m_player_actor->ar_brake = 0.66f;
1516 }
1517 }
1518
1519 // toggle physics
1520 if (RoR::App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_PHYSICS))
1521 {
1523 {
1524 actor->ar_physics_paused = !App::GetGameContext()->GetPlayerActor()->ar_physics_paused;
1525 }
1527 }
1528
1529 // reset truck
1530 if (App::GetInputEngine()->getEventBoolValue(EV_COMMON_RESET_TRUCK))
1531 {
1536 }
1537
1538 // Commandkeys: process controller input for all commands
1539 for (int i = 1; i <= MAX_COMMANDS; i++) // BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
1540 {
1541 int eventID = EV_COMMANDS_01 + (i - 1);
1542
1543 m_player_actor->ar_command_key[i].playerInputValue = RoR::App::GetInputEngine()->getEventValue(eventID);
1544 }
1545
1546 // Commandkeys: Apply command buttons in T-screen
1547 if (App::GetGuiManager()->VehicleInfoTPanel.GetActiveCommandKey() != COMMANDKEYID_INVALID)
1548 {
1550 }
1551
1552 if (RoR::App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_FORWARDCOMMANDS))
1553 {
1556 {
1557 RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("forwardcommands enabled"), "information.png");
1558 }
1559 else
1560 {
1561 RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("forwardcommands disabled"), "information.png");
1562 }
1563 }
1564
1565 if (RoR::App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_IMPORTCOMMANDS))
1566 {
1569 {
1570 RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("importcommands enabled"), "information.png");
1571 }
1572 else
1573 {
1574 RoR::App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_INFO, Console::CONSOLE_SYSTEM_NOTICE, _L("importcommands disabled"), "information.png");
1575 }
1576 }
1577
1579 {
1581 }
1582}
1583
1584// Internal heper for UpdateAirplaneInputEvents()
1585void smoothValue(float& ref, float value, float rate)
1586{
1587 if (value < -1)
1588 value = -1;
1589 if (value > 1)
1590 value = 1;
1591 // smooth!
1592 if (ref > value)
1593 {
1594 ref -= rate;
1595 if (ref < value)
1596 ref = value;
1597 }
1598 else if (ref < value)
1599 ref += rate;
1600}
1601
1603{
1605 return;
1606
1607 // autopilot
1609 {
1611 }
1612
1613 // steer
1614 float commandrate = 4.0;
1617 float sum_steer = -tmp_left + tmp_right;
1618 smoothValue(m_player_actor->ar_aileron, sum_steer, dt * commandrate);
1621
1622 // pitch
1625 float sum_pitch = tmp_pitch_down - tmp_pitch_up;
1626 smoothValue(m_player_actor->ar_elevator, sum_pitch, dt * commandrate);
1627
1628 // rudder
1629 float tmp_rudder_left = App::GetInputEngine()->getEventValue(EV_AIRPLANE_RUDDER_LEFT);
1630 float tmp_rudder_right = App::GetInputEngine()->getEventValue(EV_AIRPLANE_RUDDER_RIGHT);
1631 float sum_rudder = tmp_rudder_left - tmp_rudder_right;
1632 smoothValue(m_player_actor->ar_rudder, sum_rudder, dt * commandrate);
1633
1634 // brakes
1636 {
1638 }
1639
1640 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_PARKING_BRAKE))
1641 {
1643 }
1644
1645 // reverse
1646 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_REVERSE))
1647 {
1648 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1649 {
1651 }
1652 }
1653
1654 // engines
1655 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_TOGGLE_ENGINES))
1656 {
1657 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1658 {
1660 }
1661 }
1662
1663 // flaps
1664 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_FLAPS_NONE))
1665 {
1667 {
1669 }
1670 }
1671
1672 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_FLAPS_FULL))
1673 {
1675 {
1677 }
1678 }
1679
1680 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_FLAPS_LESS))
1681 {
1683 {
1685 }
1686 }
1687
1689 {
1691 {
1693 }
1694 }
1695
1696 // airbrakes
1698 {
1700 {
1702 }
1703 }
1704
1706 {
1708 {
1710 }
1711 }
1712
1714 {
1716 {
1718 }
1719 }
1720
1722 {
1724 {
1726 }
1727 }
1728
1729 // throttle
1731 if (tmp_throttle > 0)
1732 {
1733 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1734 {
1735 m_player_actor->ar_aeroengines[i]->setThrottle(tmp_throttle);
1736 }
1737 }
1738
1739 if (App::GetInputEngine()->isEventDefined(EV_AIRPLANE_THROTTLE_AXIS))
1740 {
1742 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1743 {
1745 }
1746 }
1747
1748 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_THROTTLE_DOWN, 0.1f))
1749 {
1750 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1751 {
1753 }
1754 }
1755
1756 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_THROTTLE_UP, 0.1f))
1757 {
1758 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1759 {
1761 }
1762 }
1763
1764 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_THROTTLE_NO, 0.1f))
1765 {
1766 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1767 {
1769 }
1770 }
1771
1772 if (App::GetInputEngine()->getEventBoolValueBounce(EV_AIRPLANE_THROTTLE_FULL, 0.1f))
1773 {
1774 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1775 {
1777 }
1778 }
1779
1780 // autopilot
1782 {
1783 for (int i = 0; i < m_player_actor->ar_num_aeroengines; i++)
1784 {
1786 }
1787 }
1788}
1789
1791{
1792 // throttle
1793 if (App::GetInputEngine()->isEventDefined(EV_BOAT_THROTTLE_AXIS))
1794 {
1796 // use negative values also!
1797 f = f * 2 - 1;
1798 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1800 }
1801
1802 if (App::GetInputEngine()->getEventBoolValueBounce(EV_BOAT_THROTTLE_DOWN, 0.1f))
1803 {
1804 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1806 }
1807
1808 if (App::GetInputEngine()->getEventBoolValueBounce(EV_BOAT_THROTTLE_UP, 0.1f))
1809 {
1810 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1812 }
1813
1814 // steer
1815 float tmp_steer_left = App::GetInputEngine()->getEventValue(EV_BOAT_STEER_LEFT);
1816 float tmp_steer_right = App::GetInputEngine()->getEventValue(EV_BOAT_STEER_RIGHT);
1818 float sum_steer = (tmp_steer_left - tmp_steer_right) * dt;
1819 // do not center the rudder!
1820 if (fabs(sum_steer) > 0 && stime <= 0)
1821 {
1822 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1824 }
1825
1827 {
1830 sum_steer = (tmp_steer_left - tmp_steer_right);
1831 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1832 m_player_actor->ar_screwprops[i]->setRudder(sum_steer);
1833 }
1834
1835 // rudder
1837 {
1838 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1840 }
1841
1842 // reverse
1844 {
1845 for (int i = 0; i < m_player_actor->ar_num_screwprops; i++)
1847 }
1848}
1849
1851{
1853 return;
1854#ifdef USE_ANGELSCRIPT
1856 return;
1857#endif // USE_ANGELSCRIPT
1858
1859 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_LEFT_MIRROR_LEFT))
1861
1862 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_LEFT_MIRROR_RIGHT))
1864
1865 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_RIGHT_MIRROR_LEFT))
1867
1868 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_RIGHT_MIRROR_RIGHT))
1870
1871 // steering
1876
1877 float sum = -std::max(tmp_left_digital, tmp_left_analog) + std::max(tmp_right_digital, tmp_right_analog);
1878
1879 m_player_actor->ar_hydro_dir_command = Ogre::Math::Clamp(sum, -1.0f, 1.0f);
1880
1881 m_player_actor->ar_hydro_speed_coupling = (tmp_left_digital >= tmp_left_analog) && (tmp_right_digital >= tmp_right_analog);
1882
1884 {
1886 }
1887
1888 if (m_player_actor->ar_brake > 1.0f / 6.0f)
1889 {
1891 }
1892 else
1893 {
1895 }
1896
1897 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_INTER_AXLE_DIFF))
1898 {
1901 }
1902
1903 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_INTER_WHEEL_DIFF))
1904 {
1907 }
1908
1909 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_TCASE_4WD_MODE))
1910 {
1913 }
1914
1915 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TOGGLE_TCASE_GEAR_RATIO))
1916 {
1919 }
1920
1922 {
1923 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_HORN))
1924 {
1925 SOUND_TOGGLE(m_player_actor, SS_TRIG_HORN); // Police siren
1926 }
1927 }
1928 else
1929 {
1930 if (App::GetInputEngine()->getEventBoolValue(EV_TRUCK_HORN)
1931 || App::GetGuiManager()->VehicleInfoTPanel.IsHornButtonActive())
1932 {
1934 }
1935 else
1936 {
1938 }
1939 }
1940
1941 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_PARKING_BRAKE) &&
1943 {
1945 }
1946
1947 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_ANTILOCK_BRAKE))
1948 {
1950 }
1951
1952 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_TRACTION_CONTROL))
1953 {
1955 }
1956
1957 if (App::GetInputEngine()->getEventBoolValueBounce(EV_TRUCK_CRUISE_CONTROL))
1958 {
1960 }
1961
1963 {
1965 }
1966}
1967
System integration layer; inspired by OgreBites::ApplicationContext.
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
void LOG(const char *msg)
Legacy alias - formerly a macro.
#define BITMASK_IS_1(VAR, FLAGS)
Definition BitFlags.h:14
A database of user-installed content alias 'mods' (vehicles, terrains...)
#define _L
void smoothValue(float &ref, float value, float rate)
Game state manager and message-queue provider.
Handles controller inputs from player.
#define _LC(ctx, str)
Definition Language.h:38
static const int MAX_CLIGHTS
See RoRnet::Lightmask and enum events in InputEngine.h.
static const int MAX_COMMANDS
maximum number of commands per actor
#define SOUND_TOGGLE(_ACTOR_, _TRIG_)
#define SOUND_START(_ACTOR_, _TRIG_)
#define SOUND_STOP(_ACTOR_, _TRIG_)
The vehicle tuning system; applies addonparts and user overrides to vehicles.
Simple waypoint AI.
bool ar_hydro_speed_coupling
Definition Actor.h:551
bool ar_parking_brake
Definition Actor.h:467
int ar_num_screwprops
Definition Actor.h:391
void setHighBeamsVisible(bool val)
Definition Actor.h:221
bool ar_import_commands
Sim state.
Definition Actor.h:556
EnginePtr ar_engine
Definition Actor.h:432
int ar_airbrake_intensity
Physics state; values 0-5.
Definition Actor.h:478
void toggleTransferCaseGearRatio()
Definition Actor.cpp:1522
bool ar_forward_commands
Sim state.
Definition Actor.h:555
void toggleSlideNodeLock()
CacheEntryPtr & getUsedSkinEntry()
Definition Actor.cpp:4878
void antilockbrakeToggle()
Definition Actor.cpp:3831
CmdKeyArray ar_command_key
BEWARE: commandkeys are indexed 1-MAX_COMMANDS!
Definition Actor.h:369
void hookToggle(int group=-1, ActorLinkingRequestType mode=ActorLinkingRequestType::HOOK_TOGGLE, NodeNum_t mousenode=NODENUM_INVALID, ActorInstanceID_t forceunlock_filter=ACTORINSTANCEID_INVALID)
Definition Actor.cpp:3677
DashBoardManagerPtr ar_dashboard
Definition Actor.h:484
void prepareInside(bool inside)
Prepares vehicle for in-cabin camera use.
Definition Actor.cpp:3023
void displayTransferCaseMode()
Gets the current transfer case mode name (4WD Hi, ...)
Definition Actor.cpp:1477
float getWheelSpeed() const
Definition Actor.h:107
float getMaxHeight(bool skip_virtual_nodes=true)
Definition Actor.cpp:1581
node_t * ar_nodes
Definition Actor.h:330
int ar_aerial_flap
Sim state; state of aircraft flaps (values: 0-5)
Definition Actor.h:474
void beaconsToggle()
Definition Actor.cpp:3849
GfxActor * GetGfxActor()
Definition Actor.h:309
float getRotation()
Definition Actor.cpp:355
bool getHighBeamsVisible() const
Definition Actor.h:220
float ar_sleep_counter
Sim state; idle time counter.
Definition Actor.h:465
Replay * getReplay()
Definition Actor.cpp:4663
float getMinHeight(bool skip_virtual_nodes=true)
Definition Actor.cpp:1568
void toggleWheelDiffMode()
Definition Actor.cpp:1407
ScrewpropPtr ar_screwprops[MAX_SCREWPROPS]
Definition Actor.h:390
void tieToggle(int group=-1, ActorLinkingRequestType mode=ActorLinkingRequestType::TIE_TOGGLE, ActorInstanceID_t forceunlock_filter=ACTORINSTANCEID_INVALID)
Definition Actor.cpp:3483
void setAirbrakeIntensity(float intensity)
Definition Actor.cpp:2974
Ogre::Vector3 getRotationCenter()
Definition Actor.cpp:1550
bool ar_is_police
Gfx/sfx attr.
Definition Actor.h:553
bool getSideLightsVisible() const
Definition Actor.h:216
bool ar_physics_paused
Actor physics individually paused by user.
Definition Actor.h:521
float ar_left_mirror_angle
Sim state; rear view mirror angle.
Definition Actor.h:469
void toggleBlinkType(BlinkType blink)
Definition Actor.cpp:3153
Ogre::Vector3 getPosition()
Definition Actor.cpp:370
void toggleTransferCaseMode()
Definition Actor.cpp:1491
bool ar_toggle_ropes
Sim state.
Definition Actor.h:557
float ar_hydro_dir_command
Definition Actor.h:456
float ar_elevator
Sim state; aerial controller.
Definition Actor.h:471
void displayAxleDiffMode()
Cycles through the available inter axle diff modes.
Definition Actor.cpp:1423
void displayWheelDiffMode()
Cycles through the available inter wheel diff modes.
Definition Actor.cpp:1451
int ar_net_source_id
Unique ID of remote player who spawned this actor.
Definition Actor.h:479
void setHeadlightsVisible(bool val)
Definition Actor.h:219
int countFlaresByType(FlareType type)
Definition Actor.cpp:4598
float ar_right_mirror_angle
Sim state; rear view mirror angle.
Definition Actor.h:470
void setSideLightsVisible(bool val)
Definition Actor.h:217
ActorState ar_state
Definition Actor.h:518
bool getCustomLightVisible(int number)
Definition Actor.cpp:4539
float getHeightAboveGroundBelow(float height, bool skip_virtual_nodes=true)
Definition Actor.cpp:1608
AeroEnginePtr ar_aeroengines[MAX_AEROENGINES]
Definition Actor.h:388
bool isBeingReset() const
Definition Actor.h:313
int ar_num_aeroengines
Definition Actor.h:389
void SoftReset()
Definition Actor.cpp:1633
void toggleAxleDiffMode()
Definition Actor.cpp:1415
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
Definition Actor.h:429
void setCustomLightVisible(int number, bool visible)
Definition Actor.cpp:4561
float ar_rudder
Sim state; aerial/marine controller.
Definition Actor.h:472
ActorPtrVec ar_linked_actors
BEWARE: Includes indirect links, see DetermineLinkedActors(); Other actors linked using 'hooks/ties/r...
Definition Actor.h:519
void SyncReset(bool reset_position)
this one should be called only synchronously (without physics running in background)
Definition Actor.cpp:1657
Ogre::Real ar_brake
Physics state; braking intensity.
Definition Actor.h:452
TyrePressure & getTyrePressure()
Definition Actor.h:259
void parkingbrakeToggle()
Definition Actor.cpp:3816
int ar_num_nodes
Definition Actor.h:345
float getMinCameraRadius()
Definition Actor.h:296
VehicleAIPtr ar_vehicle_ai
Definition Actor.h:450
Ogre::String getSectionConfig()
Definition Actor.h:270
float ar_aileron
Sim state; aerial controller.
Definition Actor.h:473
AutopilotPtr ar_autopilot
Definition Actor.h:435
void resolveCollisions(Ogre::Vector3 direction)
Moves the actor at most 'direction.length()' meters towards 'direction' to resolve any collisions.
Definition Actor.cpp:1108
bool getFogLightsVisible() const
Definition Actor.h:222
void tractioncontrolToggle()
Definition Actor.cpp:3840
CacheEntryPtr & getUsedActorEntry()
The actor entry itself.
Definition Actor.cpp:4873
Ogre::Vector3 GetCameraRoll()
Definition Actor.h:307
NodeNum_t ar_cinecam_node[MAX_CAMERAS]
Sim attr; Cine-camera node indexes.
Definition Actor.h:433
void toggleCustomParticles()
Definition Actor.cpp:3257
void softRespawn(Ogre::Vector3 spawnpos, Ogre::Quaternion spawnrot)
Use MSG_SIM_MODIFY_ACTOR_REQUESTED with type SOFT_RESPAWN; Resets the actor to given position as if s...
Definition Actor.cpp:1376
void setFogLightsVisible(bool val)
Definition Actor.h:223
bool ar_trailer_parking_brake
Definition Actor.h:468
bool ar_toggle_ties
Sim state.
Definition Actor.h:558
TuneupDefPtr & getWorkingTuneupDef()
Definition Actor.cpp:4893
ActorType ar_driveable
Sim attr; marks vehicle type and features.
Definition Actor.h:431
int ar_net_stream_id
Definition Actor.h:480
void cruisecontrolToggle()
Defined in 'gameplay/CruiseControl.cpp'.
bool getHeadlightsVisible() const
Definition Actor.h:218
ActorPtrVec & GetActors()
void UpdateSleepingState(ActorPtr player_actor, float dt)
RigDef::DocumentPtr FetchActorDef(RoR::ActorSpawnRequest &rq)
void RestoreSavedState(ActorPtr actor, rapidjson::Value const &j_entry)
Definition Savegame.cpp:787
void DeleteActorInternal(ActorPtr actor)
Do not call directly; use GameContext::DeleteActor()
const ActorPtr & FetchNextVehicleOnList(ActorPtr player, ActorPtr prev_player)
const ActorPtr & FetchPreviousVehicleOnList(ActorPtr player, ActorPtr prev_player)
ActorPtr FindActorInsideBox(Collisions *collisions, const Ogre::String &inst, const Ogre::String &box)
void UpdateActors(ActorPtr player_actor)
const ActorPtr & GetActorById(ActorInstanceID_t actor_id)
ActorPtr CreateNewActor(ActorSpawnRequest rq, RigDef::DocumentPtr def)
std::vector< ActorPtr > GetLocalActors()
virtual void toggleReverse()=0
virtual void setThrottle(float val)=0
virtual void flipStart()=0
virtual float getThrottle()=0
RoR::ForceFeedback & GetForceFeedback()
Definition AppContext.h:68
bool wantsdisconnect
Definition AutoPilot.h:55
void disconnect()
Definition AutoPilot.cpp:70
float getThrottle(float thrtl, float dt)
T getEnum() const
Definition CVar.h:99
bool getBool() const
Definition CVar.h:98
void setStr(std::string const &str)
Definition CVar.h:83
void setVal(T val)
Definition CVar.h:72
int getInt() const
Definition CVar.h:97
Terrn2DocumentPtr terrn2_def
Cached terrain definition document.
Definition CacheSystem.h:95
std::vector< Ogre::String > sectionconfigs
Ogre::String fname
filename
Definition CacheSystem.h:67
Ogre::String description
Ogre::String dname
name parsed from the file
Definition CacheSystem.h:70
SkinDocumentPtr skin_def
Cached skin info, added on first use or during cache rebuild.
Definition CacheSystem.h:92
TuneupDefPtr tuneup_def
Cached tuning info, added on first use or during cache rebuild.
Definition CacheSystem.h:93
std::string default_skin
bool deleted
is this mod deleted?
Definition CacheSystem.h:84
Ogre::String guid
global unique id; Type "addonpart" leaves this empty and uses addonpart_guids; Always lowercase.
Definition CacheSystem.h:77
void LoadAssetPack(CacheEntryPtr &t_dest, Ogre::String const &assetpack_filename)
Adds asset pack to the requesting cache entry's resource group.
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &_filename_maybe_bundlequalified)
Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache,...
size_t Query(CacheQuery &query)
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
void NotifyVehicleChanged(ActorPtr new_vehicle)
void UpdateInputEvents(float dt)
Ogre::SceneNode * GetCameraNode()
Ogre::Camera * GetCamera()
Character * CreateLocalCharacter()
void UndoRemoteActorCoupling(ActorPtr actor)
Character * GetLocalCharacter()
void setPosition(Ogre::Vector3 position)
Definition Character.cpp:85
Ogre::Vector3 getPosition()
Definition Character.cpp:92
void setRotation(Ogre::Radian rotation)
Definition Character.cpp:98
void SetActorCoupling(bool enabled, ActorPtr actor)
Ogre::Radian getRotation() const
Definition Character.h:53
collision_box_t * getBox(const Ogre::String &inst, const Ogre::String &box)
float getSurfaceHeightBelow(float x, float z, float height)
Ogre::Vector3 getPosition(const Ogre::String &inst, const Ogre::String &box)
Ogre::Quaternion getDirection(const Ogre::String &inst, const Ogre::String &box)
float getSurfaceHeight(float x, float z)
bool isInside(Ogre::Vector3 pos, const Ogre::String &inst, const Ogre::String &box, float border=0)
@ CONSOLE_MSGTYPE_ACTOR
Parsing/spawn/simulation messages for actors.
Definition Console.h:63
@ CONSOLE_MSGTYPE_INFO
Generic message.
Definition Console.h:60
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
Definition Console.cpp:103
@ CONSOLE_SYSTEM_ERROR
Definition Console.h:52
@ CONSOLE_SYSTEM_NOTICE
Definition Console.h:51
@ CONSOLE_SYSTEM_WARNING
Definition Console.h:53
void setVisible3d(bool visibility)
void autoShiftSet(int mode)
Definition Engine.cpp:1154
void UpdateInputEvents(float dt)
Definition Engine.cpp:1260
void setAutoMode(SimGearboxMode mode)
Definition Engine.cpp:847
void SetEnabled(bool v)
void AnalyzeFlexbodies()
populates the combobox
void SetVisible(bool visible)
void Show(LoaderType type, std::string const &filter_guid="", CacheEntryPtr advertised_entry=nullptr)
Ogre::String ai_sectionconfig
Ogre::String ai_sectionconfig2
std::vector< ai_events > ai_waypoints
CommandkeyID_t GetActiveCommandKey() const
GUI::RepositorySelector RepositorySelector
Definition GUIManager.h:130
GUI::MultiplayerSelector MultiplayerSelector
Definition GUIManager.h:123
GUI::GameAbout GameAbout
Definition GUIManager.h:118
GUI::MainSelector MainSelector
Definition GUIManager.h:124
GUI::GameSettings GameSettings
Definition GUIManager.h:119
GUI::VehicleInfoTPanel VehicleInfoTPanel
Definition GUIManager.h:120
GUI::TopMenubar TopMenubar
Definition GUIManager.h:133
void ShowMessageBox(const char *title, const char *text, bool allow_close=true, const char *btn1_text="OK", const char *btn2_text=nullptr)
GUI::FrictionSettings FrictionSettings
Definition GUIManager.h:127
GUI::GameControls GameControls
Definition GUIManager.h:129
GUI::FlexbodyDebug FlexbodyDebug
Definition GUIManager.h:137
void SetPrevPlayerActor(ActorPtr actor)
Message * m_msg_chain_end
ActorPtr m_last_spawned_actor
Last actor spawned by user and still alive.
TerrainPtr m_terrain
void UpdateGlobalInputEvents()
std::mutex m_msg_mutex
ActorPtr SpawnActor(ActorSpawnRequest &rq)
ActorPtr FindActorByCollisionBox(std::string const &ev_src_instance_name, std::string const &box_name)
Ogre::Vector3 prev_pos
Message PopMessage()
void UpdateSkyInputEvents(float dt)
ActorSpawnRequest m_current_selection
Context of the loader UI.
const ActorPtr & FetchNextVehicleOnList()
ActorPtr m_player_actor
Actor (vehicle or machine) mounted and controlled by player.
void OnLoaderGuiApply(RoR::LoaderType type, CacheEntryPtr entry, std::string sectionconfig)
GUI callback.
const ActorPtr & FetchPrevVehicleOnList()
CacheEntryPtr m_last_skin_selection
CharacterFactory m_character_factory
Character * GetPlayerCharacter()
const ActorPtr & GetPlayerActor()
void ShowLoaderGUI(int type, const Ogre::String &instance, const Ogre::String &box)
ActorManager m_actor_manager
void UpdateTruckInputEvents(float dt)
Ogre::String m_last_section_config
void UpdateCommonInputEvents(float dt)
CacheEntryPtr m_last_tuneup_selection
void ChangePlayerActor(ActorPtr actor)
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
void SpawnPreselectedActor(std::string const &preset_vehicle, std::string const &preset_veh_config)
needs Character to exist
bool LoadTerrain(std::string const &filename_part)
CacheEntryPtr m_dummy_cache_selection
Ogre::Timer m_timer
void CreatePlayerCharacter()
Terrain must be loaded.
ActorPtr m_actor_remotely_receiving_commands
Actor close enough to import command keys.
void UpdateSimInputEvents(float dt)
void ChainMessage(Message m)
Add to last pushed message's chain.
void DeleteActor(ActorPtr actor)
void ModifyActor(ActorModifyRequest &rq)
void TeleportPlayer(float x, float z)
GameMsgQueue m_msg_queue
void UpdateBoatInputEvents(float dt)
ActorPtr m_prev_player_actor
Previous actor (vehicle or machine) mounted and controlled by player.
ActorManager * GetActorManager()
CacheEntryPtr m_last_cache_selection
Vehicle/load.
void OnLoaderGuiCancel()
GUI callback.
void UpdateAirplaneInputEvents(float dt)
void SetVideoCamState(VideoCamState state)
Definition GfxActor.cpp:443
void UpdateSimDataBuffer()
Copies sim. data from Actor to GfxActor for later update.
void SetRenderdashActive(bool active)
VideoCamState GetVideoCamState() const
Definition GfxActor.h:144
void CycleDebugViews()
void ToggleDebugView()
DebugViewType GetDebugView() const
Definition GfxActor.h:145
void UpdateEnvMap(Ogre::Vector3 center, GfxActor *gfx_actor, bool full=false)
void ForceUpdateSingleGfxActor(RoR::GfxActor *gfx_actor)
Definition GfxScene.cpp:339
GfxEnvmap & GetEnvMap()
Definition GfxScene.h:81
void RemoveGfxActor(RoR::GfxActor *gfx_actor)
Definition GfxScene.cpp:330
GameContextSB & GetSimDataBuffer()
Definition GfxScene.h:80
float getEventBounceTime(int eventID)
bool getEventBoolValue(int eventID)
bool isEventDefined(int eventID)
bool getEventBoolValueBounce(int eventID, float time=0.2f)
float getEventValue(int eventID, bool pure=false, InputSourceType valueSource=InputSourceType::IST_ANY)
valueSource: IST_ANY=digital and analog devices, IST_DIGITAL=only digital, IST_ANALOG=only analog
bool isEventAnalog(int eventID)
RoRnet::UserInfo GetLocalUserData()
Definition Network.cpp:707
void showDashboardOverlays(bool show, ActorPtr actor)
void UpdateInputEvents()
Definition Replay.cpp:251
void toggleReverse()
float getRudder()
void setRudder(float val)
Definition ScrewProp.cpp:94
float getThrottle()
void setThrottle(float val)
Definition ScrewProp.cpp:81
SkyX::SkyX * GetSkyX()
Definition SkyXManager.h:52
Wrapper for classic c-string (local buffer) Refresher: strlen() excludes '\0' terminator; strncat() A...
Definition Str.h:36
const char * ToCStr() const
Definition Str.h:46
SkyXManager * getSkyXManager()
Definition Terrain.h:83
Ogre::Vector3 getMaxTerrainSize()
Definition Terrain.cpp:505
bool initialize()
Definition Terrain.cpp:151
bool HasPredefinedActors()
Definition Terrain.cpp:547
SkyManager * getSkyManager()
Definition Terrain.cpp:522
float getHeightAt(float x, float z)
Definition Terrain.cpp:512
Collisions * GetCollisions()
Definition Terrain.h:86
void dispose()
Definition Terrain.cpp:79
Ogre::Vector3 getSpawnPos()
Definition Terrain.cpp:594
Terrn2DocumentPtr GetDef()
Definition Terrain.cpp:584
Terrn2DocumentPtr LoadTerrn2(Ogre::DataStreamPtr &ds)
void UpdateInputEvents(float dt)
bool IsEnabled() const
bool isActive()
Returns the status of the AI.
Definition VehicleAI.cpp:58
void setTimeMultiplier(const Ogre::Real &TimeMultiplier)
Set time multiplier.
Definition SkyX.h:166
@ BLINK_RIGHT
Definition SimData.h:117
@ BLINK_LEFT
Definition SimData.h:116
@ BLINK_WARN
Definition SimData.h:118
@ MACHINE
its a machine
Definition SimData.h:88
@ TRUCK
its a truck (or other land vehicle)
Definition SimData.h:85
@ NOT_DRIVEABLE
not drivable at all
Definition SimData.h:84
@ AIRPLANE
its an airplane
Definition SimData.h:86
@ AI
machine controlled by an Artificial Intelligence
Definition SimData.h:89
@ EV_BOAT_CENTER_RUDDER
center the rudder
@ EV_AIRPLANE_THROTTLE
Definition InputEngine.h:93
@ EV_COMMON_TOGGLE_RESET_MODE
toggle truck reset truck mode (soft vs. hard)
@ EV_COMMANDS_01
Command 1.
@ EV_COMMON_ROPELOCK
connect hook node to a node in close proximity
@ EV_TRUCK_TOGGLE_PHYSICS
toggle physics simulation
@ EV_TRUCK_HORN
truck horn
@ EV_AIRPLANE_THROTTLE_FULL
full thrust
Definition InputEngine.h:96
@ EV_TRUCK_TOGGLE_VIDEOCAMERA
toggle videocamera update
@ EV_AIRPLANE_THROTTLE_UP
increase the airplane thrust
Definition InputEngine.h:98
@ EV_TRUCK_TOGGLE_TCASE_GEAR_RATIO
toggle the transfer case gear ratio
@ EV_AIRPLANE_BRAKE
normal brake for an aircraft.
Definition InputEngine.h:80
@ EV_COMMON_LOCK
connect hook node to a node in close proximity
@ EV_TRUCK_BLINK_RIGHT
toggle right direction indicator (blinker)
@ EV_AIRPLANE_THROTTLE_AXIS
throttle axis. Only use this if you have fitting hardware :) (i.e. a Slider)
Definition InputEngine.h:94
@ EV_TRUCK_TOGGLE_INTER_AXLE_DIFF
toggle the inter axle differential mode
@ EV_TRUCK_LEFT_MIRROR_LEFT
@ EV_BOAT_THROTTLE_UP
increase throttle
@ EV_AIRPLANE_STEER_RIGHT
steer right
Definition InputEngine.h:92
@ EV_AIRPLANE_AIRBRAKES_LESS
Definition InputEngine.h:77
@ EV_COMMON_OUTPUT_POSITION
write current position to log (you can open the logfile and reuse the position)
@ EV_COMMON_TOGGLE_TRUCK_FOG_LIGHTS
toggle truck fog lights (on/off); doesn't need low beams, doesn't use 't' lights.
@ EV_SKY_INCREASE_TIME
increase day-time
@ EV_AIRPLANE_PARKING_BRAKE
airplane parking brake.
Definition InputEngine.h:87
@ EV_BOAT_STEER_LEFT_AXIS
steer left (analog value!)
@ EV_COMMON_REMOVE_CURRENT_TRUCK
remove current truck
@ EV_TRUCK_BLINK_LEFT
toggle left direction indicator (blinker)
@ EV_COMMON_TOGGLE_TRUCK_HIGH_BEAMS
toggle truck high beams (on/off); doesn't need low beams, doesn't use 't' lights.
@ EV_AIRPLANE_REVERSE
reverse the turboprops
Definition InputEngine.h:88
@ EV_TRUCK_PARKING_BRAKE
toggle parking brake
@ EV_BOAT_THROTTLE_DOWN
decrease throttle
@ EV_AIRPLANE_FLAPS_MORE
one step more flaps.
Definition InputEngine.h:85
@ EV_AIRPLANE_TOGGLE_ENGINES
switch all engines on / off
Definition InputEngine.h:99
@ EV_BOAT_THROTTLE_AXIS
throttle axis. Only use this if you have fitting hardware :) (i.e. a Slider)
@ EV_BOAT_STEER_RIGHT_AXIS
steer right (analog value!)
@ EV_AIRPLANE_RUDDER_RIGHT
rudder right
Definition InputEngine.h:90
@ EV_TRUCK_TRACTION_CONTROL
toggle antilockbrake system
@ EV_AIRPLANE_FLAPS_NONE
no flaps.
Definition InputEngine.h:86
@ EV_BOAT_STEER_RIGHT
steer right a step
@ EV_AIRPLANE_ELEVATOR_DOWN
pull the elevator down in an aircraft.
Definition InputEngine.h:81
@ EV_COMMON_CYCLE_DEBUG_VIEWS
cycle debug view mode
@ EV_TRUCK_BLINK_WARN
toggle all direction indicators
@ EV_TRUCK_RIGHT_MIRROR_LEFT
@ EV_COMMON_SCREENSHOT
take a screenshot
@ EV_COMMON_RESCUE_TRUCK
teleport to rescue truck
@ EV_AIRPLANE_FLAPS_FULL
full flaps in an aircraft.
Definition InputEngine.h:83
@ EV_AIRPLANE_FLAPS_LESS
one step less flaps.
Definition InputEngine.h:84
@ EV_AIRPLANE_AIRBRAKES_MORE
Definition InputEngine.h:78
@ EV_COMMON_SECURE_LOAD
tie a load to the truck
@ EV_COMMON_QUIT_GAME
exit the game
@ EV_TRUCK_TRAILER_PARKING_BRAKE
toggle trailer parking brake
@ EV_SKY_DECREASE_TIME_FAST
decrease day-time a lot faster
@ EV_AIRPLANE_THROTTLE_DOWN
decreases the airplane thrust
Definition InputEngine.h:95
@ EV_AIRPLANE_ELEVATOR_UP
pull the elevator up in an aircraft.
Definition InputEngine.h:82
@ EV_COMMON_GET_NEW_VEHICLE
get new vehicle
@ EV_SKY_DECREASE_TIME
decrease day-time
@ EV_TRUCK_STEER_LEFT
steer left
@ EV_SKY_INCREASE_TIME_FAST
increase day-time a lot faster
@ EV_BOAT_STEER_LEFT
steer left a step
@ EV_COMMON_RESET_TRUCK
reset truck to original starting position
@ EV_BOAT_REVERSE
no thrust
@ EV_COMMON_TOGGLE_TRUCK_BEACONS
toggle truck beacons
@ EV_COMMON_ENTER_PREVIOUS_TRUCK
enter previous truck
@ EV_TRUCK_RIGHT_MIRROR_RIGHT
@ EV_COMMON_ENTER_NEXT_TRUCK
enter next truck
@ EV_TRUCK_TOGGLE_FORWARDCOMMANDS
toggle forwardcommands
@ EV_AIRPLANE_THROTTLE_NO
no thrust
Definition InputEngine.h:97
@ EV_AIRPLANE_AIRBRAKES_NONE
Definition InputEngine.h:79
@ EV_TRUCK_CRUISE_CONTROL
toggle cruise control
@ EV_COMMON_FULLSCREEN_TOGGLE
@ EV_TRUCK_TOGGLE_TCASE_4WD_MODE
toggle the transfer case 4wd mode
@ EV_COMMON_CYCLE_TRUCK_LIGHTS
cycle truck front light mode (off -> running light -> low beams -> off).
@ EV_TRUCK_STEER_RIGHT
steer right
@ EV_COMMON_TOGGLE_TRUCK_LOW_BEAMS
toggle truck low beams (on/off); also toggles running lights.
@ EV_AIRPLANE_STEER_LEFT
steer left
Definition InputEngine.h:91
@ EV_COMMON_AUTOLOCK
unlock autolock hook node
@ EV_AIRPLANE_RUDDER_LEFT
rudder left
Definition InputEngine.h:89
@ EV_COMMON_TOGGLE_CUSTOM_PARTICLES
toggle particle cannon
@ EV_COMMON_RESPAWN_LAST_TRUCK
respawn last truck
@ EV_TRUCK_ANTILOCK_BRAKE
toggle antilockbrake system
@ EV_TRUCK_TOGGLE_IMPORTCOMMANDS
toggle importcommands
@ EV_TRUCK_LIGHTTOGGLE01
toggle custom light 1
@ EV_COMMON_ENTER_OR_EXIT_TRUCK
enter or exit a truck
@ EV_COMMON_TOGGLE_TERRAIN_EDITOR
toggle terrain editor
@ EV_TRUCK_LEFT_MIRROR_RIGHT
@ EV_TRUCK_TOGGLE_INTER_WHEEL_DIFF
toggle the inter wheel differential mode
@ EV_AIRPLANE_AIRBRAKES_FULL
Definition InputEngine.h:76
@ EV_TRUCKEDIT_RELOAD
@ EV_COMMON_TRUCK_REMOVE
@ EV_COMMON_TOGGLE_DEBUG_VIEW
toggle debug view mode
@ MSG_GUI_OPEN_MENU_REQUESTED
@ MSG_GUI_CLOSE_MENU_REQUESTED
@ MSG_SIM_PAUSE_REQUESTED
@ MSG_SIM_UNPAUSE_REQUESTED
@ MSG_SIM_HIDE_NET_ACTOR_REQUESTED
Payload = ActorPtr* (owner)
@ MSG_GUI_REFRESH_TUNING_MENU_REQUESTED
@ MSG_APP_DISPLAY_WINDOWED_REQUESTED
Definition Application.h:89
@ MSG_EDI_ENTER_TERRN_EDITOR_REQUESTED
@ MSG_SIM_ACTOR_LINKING_REQUESTED
Payload = RoR::ActorLinkingRequest* (owner)
@ MSG_SIM_SPAWN_ACTOR_REQUESTED
Payload = RoR::ActorSpawnRequest* (owner)
@ MSG_GUI_OPEN_SELECTOR_REQUESTED
Payload = LoaderType* (owner), Description = GUID | empty.
@ MSG_SIM_SEAT_PLAYER_REQUESTED
Payload = RoR::ActorPtr (owner) | nullptr.
@ MSG_APP_SHUTDOWN_REQUESTED
Definition Application.h:86
@ MSG_APP_DISPLAY_FULLSCREEN_REQUESTED
Definition Application.h:88
@ MSG_SIM_MUTE_NET_ACTOR_REQUESTED
Payload = ActorPtr* (owner)
@ MSG_EDI_MODIFY_PROJECT_REQUESTED
Payload = RoR::UpdateProjectRequest* (owner)
@ MSG_SIM_DELETE_ACTOR_REQUESTED
Payload = RoR::ActorPtr* (owner)
@ MSG_SIM_MODIFY_ACTOR_REQUESTED
Payload = RoR::ActorModifyRequest* (owner)
@ MSG_APP_SCREENSHOT_REQUESTED
Definition Application.h:87
@ MSG_EDI_RELOAD_BUNDLE_REQUESTED
Payload = RoR::CacheEntryPtr* (owner)
@ LOCAL_SIMULATED
simulated (local) actor
@ LOCAL_SLEEPING
sleeping (local) actor
@ NETWORKED_OK
not simulated (remote) actor
@ NETWORKED_HIDDEN
not simulated, not updated (remote)
void TRIGGER_EVENT_ASYNC(scriptEvents type, int arg1, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
Asynchronously (via MSG_SIM_SCRIPT_EVENT_TRIGGERED) invoke script function eventCallbackEx(),...
@ AUTO
Automatic shift.
std::shared_ptr< Document > DocumentPtr
CVar * gfx_sky_mode
CVar * gfx_polygon_mode
AppContext * GetAppContext()
CVar * gfx_sky_time_cycle
CVar * sim_state
OverlayWrapper * GetOverlayWrapper()
InputEngine * GetInputEngine()
CVar * gfx_sky_time_speed
CameraManager * GetCameraManager()
CVar * diag_preset_spawn_pos
GUIManager * GetGuiManager()
GameContext * GetGameContext()
CVar * sim_tuning_enabled
CVar * sim_soft_reset_mode
GfxScene * GetGfxScene()
CVar * app_state
CVar * cli_preset_spawn_pos
CVar * mp_state
CVar * diag_preset_spawn_rot
Console * GetConsole()
CacheSystem * GetCacheSystem()
CVar * diag_preset_veh_enter
CVar * cli_preset_spawn_rot
Network * GetNetwork()
static const NodeNum_t NODENUM_INVALID
void Log(const char *msg)
The ultimate, application-wide logging function. Adds a line (any length) in 'RoR....
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
@ LT_Airplane
@ LT_Boat
@ LT_Train
@ LT_AddonPart
@ LT_Skin
@ LT_Truck
@ LT_Car
@ LT_Load
@ LT_Terrain
@ LT_Trailer
@ LT_Vehicle
@ LT_Extension
@ LT_AllBeam
@ TUNEUP_USE_ADDONPART_SET
'subject' is addonpart filename.
std::shared_ptr< Terrn2Document > Terrn2DocumentPtr
void LogFormat(const char *format,...)
Improved logging utility. Uses fixed 2Kb buffer.
RefCountingObjectPtr< Actor > ActorPtr
@ SE_TRUCK_TELEPORT
triggered when the user teleports the truck, the argument refers to the actor ID of the vehicle
@ SE_TRUCK_EXIT
triggered when switching from vehicle mode to person mode, the argument refers to the actor ID of the...
@ SE_TRUCK_ENTER
triggered when switching from person mode to vehicle mode, the argument refers to the actor ID of the...
@ SE_GENERIC_DELETED_TRUCK
triggered when the user deletes an actor, the argument refers to the actor ID
@ CAELUM
Caelum (best looking, slower)
@ SKYX
SkyX (best looking, slower)
std::string tryConvertUTF(const char *buffer)
Definition Utils.cpp:61
RefCountingObjectPtr< CacheEntry > CacheEntryPtr
static const CommandkeyID_t COMMANDKEYID_INVALID
@ PEEROPT_HIDE_ACTORS
Spawn actors hidden and immediatelly hide existing actors.
Definition RoRnet.h:133
@ PEEROPT_MUTE_ACTORS
Spawn actors muted and immediatelly mute existing actors.
Definition RoRnet.h:132
Estabilishing a physics linkage between 2 actors modifies a global linkage table and triggers immedia...
Definition SimData.h:909
ActorLinkingRequestType alr_type
Definition SimData.h:911
ActorInstanceID_t alr_actor_instance_id
Definition SimData.h:910
ActorInstanceID_t amr_actor
Definition SimData.h:875
Ogre::Quaternion amr_softrespawn_rotation
Rotation to use with SOFT_RESPAWN; use TObjParser::CalcRotation() to calculate quaternion from XYZ li...
Definition SimData.h:882
Ogre::Vector3 amr_softrespawn_position
Position to use with SOFT_RESPAWN.
Definition SimData.h:881
std::shared_ptr< rapidjson::Document > amr_saved_state
Definition SimData.h:878
@ RELOAD
Full reload from filesystem, requested by user.
@ SOFT_RESPAWN
Like hard reset, but positions the actor like spawn process does - using the relative positions from ...
@ REFRESH_VISUALS
Forces a synchronous update of visuals from any context - i.e. from terrain editor mode or with sleep...
std::string asr_net_username
Definition SimData.h:845
Ogre::String asr_config
Definition SimData.h:836
CacheEntryPtr asr_cache_entry
Optional, overrides 'asr_filename' and 'asr_cache_entry_num'.
Definition SimData.h:834
TuneupDefPtr asr_working_tuneup
Only filled when editing tuneup via Tuning menu.
Definition SimData.h:842
bool asr_terrn_machine
This is a fixed machinery.
Definition SimData.h:852
Ogre::Vector3 asr_position
Definition SimData.h:837
CacheEntryPtr asr_skin_entry
Definition SimData.h:840
std::string asr_filename
Can be in "Bundle-qualified" format, i.e. "mybundle.zip:myactor.truck".
Definition SimData.h:835
Ogre::Quaternion asr_rotation
Definition SimData.h:838
@ CONFIG_FILE
'Preselected vehicle' in RoR.cfg or command line
@ NETWORK
Remote controlled.
@ USER
Direct selection by user via GUI.
@ SAVEGAME
User spawned and part of a savegame.
@ TERRN_DEF
Preloaded with terrain.
BitMask_t asr_net_peeropts
RoRnet::PeerOptions to be applied after spawn.
Definition SimData.h:847
collision_box_t * asr_spawnbox
Definition SimData.h:839
CacheEntryPtr asr_tuneup_entry
Only filled when user selected a saved/downloaded .tuneup mod in SelectorUI.
Definition SimData.h:841
std::shared_ptr< rapidjson::Document > asr_saved_state
Pushes msg MODIFY_ACTOR (type RESTORE_SAVED) after spawn.
Definition SimData.h:854
std::string cqy_filter_guid
Exact match (case-insensitive); leave empty to disable.
std::vector< CacheQueryResult > cqy_results
RoR::LoaderType cqy_filter_type
ActorPtr simbuf_player_actor
Definition SimBuffers.h:203
Unified game event system - all requests and state changes are reported using a message.
Definition GameContext.h:52
void * payload
Definition GameContext.h:59
std::vector< Message > chain
Posted after the message is processed.
Definition GameContext.h:60
ModifyProjectRequestType mpr_type
Ogre::Vector3 AbsPosition
absolute position in the world (shaky)
Definition SimData.h:267
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
Definition RoRnet.h:196
int32_t colournum
colour set by server
Definition RoRnet.h:194
Ogre::Vector3 position