Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TutorialGamemodeComponent.c
Go to the documentation of this file.
4
5class SCR_TutorialGamemodeComponent : SCR_BaseGameModeComponent
6{
7 [Attribute("{14FDB620B5FF18BC}Configs/Tutorial/TutorialStagesConfig.conf", UIWidgets.ResourceNamePicker, "", "conf")]
8 protected ResourceName m_sCoursesConfigResourceName;
9
10 [Attribute("{86D830868F026D54}Prefabs/Vehicles/Wheeled/M151A2/M151A2_MERDC.et", UIWidgets.ResourceNamePicker, "", "conf")]
12
13 protected const int GARBAGE_DESPAWN_DISTANCE_SQ = 200*200;
14 protected const int PUNISHMENT_TIMEOUT = 5000;
15 protected const string FADEOUT_LAYOUT = "{265245C299401BF6}UI/layouts/Menus/ContentBrowser/DownloadManager/ScrollBackground.layout";
16 protected const string TASK_COMPLETED_SUFFIX = "#AR-Tutorial_TaskCompletedSuffix";
17
20 protected ref array<ref SCR_TutorialStageInfo> m_aStageInfos = {};
21 protected ref array<ref SCR_MapMarkerBase> m_aMarkers = {};
22 protected int m_iActiveStage;
25 protected bool m_bFirstStageSet;
26
27 protected bool m_bIsMapOpen = false;
28 protected bool m_bUsed3PV = false;
29
31 protected bool m_bIsUsingGamepad;
32 protected bool m_bProtectionWarning;
36 protected bool m_bStagesComplete = false;
40 protected float m_fSavedTime;
41
42 protected ref array <SCR_TutorialInstructorComponent> m_aInstructors = {};
43
47
48 protected bool m_bIsFastTraveling;
49 protected bool m_bCourseBreaking;
51
53
54 protected ref array <IEntity> m_aGarbage;
55 protected ref array <SCR_VehicleDamageManagerComponent> m_aDamagedVehicles;
56 protected ref array <SCR_NarrativeComponent> m_aNarratedCharacters;
57
60 protected bool m_bOutroBreak;
61
63
64 protected float m_fSavedViewDistance;
65
66 // Sound fade
68 protected float m_fSoundVolume;
69 protected bool m_bApplySoundFade;
70
71
72 #ifdef ENABLE_DIAG
73 bool m_bIgnoreCourseRequirements;
74 bool m_bSkipIntro;
75 protected bool m_bDrawAreaRestrictions;
76 #endif
77
78 //------------------------------------------------------------------------------------------------
79 void BlockBuildingModeAccess(notnull IEntity providerEntity, bool block)
80 {
81 ActionsManagerComponent actionsMan = ActionsManagerComponent.Cast(providerEntity.FindComponent(ActionsManagerComponent));
82 if (!actionsMan)
83 return;
84
85 array <BaseUserAction> outActions = {};
86 actionsMan.GetActionsList(outActions);
87 if (!outActions || outActions.IsEmpty())
88 return;
89
91 foreach (BaseUserAction userAction : outActions)
92 {
93 buildingAction = SCR_TutorialBuildingStartUserAction.Cast(userAction);
94 if (!buildingAction)
95 continue;
96
97 buildingAction.SetCanShow(!block);
98
99 return;
100 }
101 }
102
103 //------------------------------------------------------------------------------------------------
104 void EnableRefunding(IEntity ent, bool enable)
105 {
106 if (!ent)
107 return;
108
109 BaseInventoryStorageComponent storageComp = BaseInventoryStorageComponent.Cast(ent.FindComponent(BaseInventoryStorageComponent));
110 if (!storageComp)
111 return;
112
113 SCR_ItemAttributeCollection attributeCollection = SCR_ItemAttributeCollection.Cast(storageComp.GetAttributes());
114 if (!attributeCollection)
115 return;
116
117 attributeCollection.SetRefundable(enable);
118 }
119
120 //------------------------------------------------------------------------------------------------
125
126 //------------------------------------------------------------------------------------------------
128 {
130 }
131
132 //------------------------------------------------------------------------------------------------
133 void SetupTargets(string parentTargetName, out array <SCR_FiringRangeTarget> targets = null, ETargetState setupState = -1, bool setupAutoReset = true)
134 {
135 SCR_FiringRangeTarget target = SCR_FiringRangeTarget.Cast(GetGame().GetWorld().FindEntityByName(parentTargetName));
136 if (!target)
137 return;
138
139 target.SetAutoResetTarget(setupAutoReset);
140 target.SetState(setupState);
141
142 if (targets)
143 targets.Insert(target);
144
145 target = SCR_FiringRangeTarget.Cast(target.GetChildren());
146
147 while (target)
148 {
149 if (targets)
150 targets.Insert(target);
151
152 target.SetAutoResetTarget(setupAutoReset);
153 target.SetState(setupState);
154
155 target = SCR_FiringRangeTarget.Cast(target.GetSibling());
156 }
157 }
158
159 //------------------------------------------------------------------------------------------------
161 {
162 if (!m_aDamagedVehicles || m_aDamagedVehicles.IsEmpty())
163 return;
164
165 string name;
167 {
168
169 if (!damageManager)
170 continue;
171
172 name = damageManager.GetOwner().GetName();
173 if (name == "RespawnAmbulance" || name == "UH1COURSE" || name == "SmallJeep")
174 continue;
175
176 damageManager.FullHeal();
177 }
178
179 m_aDamagedVehicles = null;
180 }
181
182 //------------------------------------------------------------------------------------------------
184 {
185 //Vehicle was repaired.
186 if (damageManager.GetState() == EDamageState.UNDAMAGED)
187 return;
188
189 IEntity owner = damageManager.GetOwner();
190 if (owner.GetName() == "TARGET_BTR")
191 return;
192
195
196 m_aDamagedVehicles.Insert(damageManager);
197
198 Instigator instigator = damageManager.GetInstigator();
199 if (!instigator)
200 return;
201
202 IEntity instigatorEntity = instigator.GetInstigatorEntity();
203 if (instigatorEntity == m_Player && m_Player.GetParent() != owner)
204 RequestBreakCourse(SCR_ETutorialBreakType.PLAYER_GRIEFING_VEHICLE);
205 }
206
207 //------------------------------------------------------------------------------------------------
208 void HandleGarbage(bool force = false)
209 {
210 if (!m_aGarbage)
211 return;
212
214 for (int i = m_aGarbage.Count()-1; i>=0; i--)
215 {
216 if (m_aGarbage[i] == null)
217 {
218 m_aGarbage.Remove(i);
219 continue;
220 }
221
222 if (!force && vector.DistanceSq(m_Player.GetOrigin(), m_aGarbage[i].GetOrigin()) < GARBAGE_DESPAWN_DISTANCE_SQ)
223 continue;
224
225 SCR_EntityHelper.DeleteEntityAndChildren(m_aGarbage[i]);
226 m_aGarbage.Remove(i);
227 }
228
229 if (m_aGarbage.IsEmpty())
230 m_aGarbage = null;
231 }
232
233 //------------------------------------------------------------------------------------------------
235 {
236 if (!m_aGarbage)
237 return;
238
239 m_aGarbage.RemoveItem(ent);
240 if (m_aGarbage.IsEmpty())
241 m_aGarbage = null;
242 }
243
244 //------------------------------------------------------------------------------------------------
245 void InsertIntoGarbage(string entityName)
246 {
247 IEntity ent = GetGame().GetWorld().FindEntityByName(entityName);
248
249 if (ent)
251 }
252
253 //------------------------------------------------------------------------------------------------
255 {
256 if (!m_aGarbage)
257 m_aGarbage = {};
258
259 m_aGarbage.Insert(ent);
260 }
261
262 //------------------------------------------------------------------------------------------------
263 void ChangeVehicleLockState(notnull IEntity vehicle, bool lock)
264 {
265 SCR_BaseLockComponent lockComp = SCR_BaseLockComponent.Cast(vehicle.FindComponent(SCR_BaseLockComponent));
266 if (!lockComp)
267 return;
268
269 lockComp.SetLocked(lock);
270 }
271
272 //------------------------------------------------------------------------------------------------
274 {
275 BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(m_Player.FindComponent(BaseWeaponManagerComponent));
276 if (!weaponManager)
277 return 0;
278
279 array<IEntity> weapons = {};
280 weaponManager.GetWeaponsList(weapons);
281
282 if (!weapons || weapons.IsEmpty())
283 return 0;
284
285 int ammoCount;
286 foreach (IEntity weapon : weapons)
287 {
288 ammoCount += GetAmmoCountForWeapon(weapon);
289 }
290
291 return ammoCount;
292 }
293
294 //------------------------------------------------------------------------------------------------
296 {
297 if (!weapon)
298 return 0;
299
301 if (!weaponComp)
302 return 0;
303
304 int ammoCount = 0;
305 BaseMuzzleComponent muzzle = weaponComp.GetCurrentMuzzle();
306 if (muzzle)
307 ammoCount = muzzle.GetAmmoCount();
308
309 BaseMagazineWell magWell = muzzle.GetMagazineWell();
310 if (magWell)
311 {
312 const typename magazineType = magWell.Type();
313
314 array<IEntity> foundItems = {};
315 GetPlayerInventory().FindItemsWithComponents(foundItems, {BaseMagazineComponent}, EStoragePurpose.PURPOSE_ANY);
316 foreach (IEntity item : foundItems)
317 {
318 auto magazine = BaseMagazineComponent.Cast(item.FindComponent(BaseMagazineComponent));
319 if (!magazine)
320 continue;
321
322 auto magazineWell = magazine.GetMagazineWell();
323 if (!magazineWell)
324 continue;
325
326 if (magazineWell.Type() == magazineType)
327 ammoCount += magazine.GetAmmoCount();
328 }
329 }
330
331 return ammoCount;
332 }
333
334 //------------------------------------------------------------------------------------------------
335 void LoadProgress(SCR_ETutorialCourses completedCourses)
336 {
337 m_eFinishedCourses = completedCourses;
338 }
339
340 //------------------------------------------------------------------------------------------------
342 {
343 ChimeraWorld world = ChimeraWorld.CastFrom(GetOwner().GetWorld());
344 if (!world)
345 return;
346
347 TimeAndWeatherManagerEntity manager = world.GetTimeAndWeatherManager();
348 if (!manager)
349 return;
350
351 m_fSavedTime = manager.GetEngineTime();
352 }
353
354 //------------------------------------------------------------------------------------------------
356 {
357 ChimeraWorld world = ChimeraWorld.CastFrom(GetOwner().GetWorld());
358 if (!world)
359 return 0;
360
361 TimeAndWeatherManagerEntity manager = world.GetTimeAndWeatherManager();
362 if (!manager)
363 return 0;
364
365 return manager.GetEngineTime() - m_fSavedTime;
366 }
367
368 //------------------------------------------------------------------------------------------------
373
374 //------------------------------------------------------------------------------------------------
375 void MoveCharacterIntoVehicle(notnull ChimeraCharacter character, notnull Vehicle vehicle, ECompartmentType compartmentType, int compartmentIndex = 0)
376 {
377 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
378 if (!compartmentAccess)
379 return;
380
381 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicle.FindComponent(SCR_BaseCompartmentManagerComponent));
382 if (!compartmentManager)
383 return;
384
385 array<BaseCompartmentSlot> outCompartments = {};
386 compartmentManager.GetCompartmentsOfType(outCompartments, compartmentType);
387
388 if (outCompartments)
389 compartmentAccess.GetInVehicle(vehicle, outCompartments[compartmentIndex], true, 0, ECloseDoorAfterActions.CLOSE_DOOR, false);
390
391 SCR_NarrativeComponent narrativeComponent = SCR_NarrativeComponent.Cast(character.FindComponent(SCR_NarrativeComponent));
392
393 if (!SCR_NarrativeComponent)
394 return;
395
396 narrativeComponent.Initialize(character);
397 }
398
399 //------------------------------------------------------------------------------------------------
404
405 //------------------------------------------------------------------------------------------------
407 {
408 if (!m_Player)
409 return;
410
412 if (!damageMan)
413 return;
414
415 damageMan.FullHeal();
416 }
417
418 //------------------------------------------------------------------------------------------------
420 {
422 return;
423
424 m_bCourseBreaking = true;
425
426 SCR_ETutorialCourses course = m_ActiveConfig.GetCourseType();
427 //SCR_AnalyticsApplication.GetInstance().TutorialCourseEnds(course, breakType);
428
429 m_bOutroBreak = course == SCR_ETutorialCourses.OUTRO;
430
431 GetGame().GetMenuManager().CloseAllMenus();
432
433 m_iBreakType = breakType;
434
435 // User or Course induced break, resulting into Fast travel
436 if (breakType == SCR_ETutorialBreakType.FORCED)
437 {
439 FastTravel(m_ActiveConfig.GetFastTravelPosition());
440 return;
441 }
442 else
443 {
444 ChimeraWorld world = GetGame().GetWorld();
445
446 if (world)
447 world.GetMusicManager().Play("SOUND_END_BAD");
448 }
449
450 // Player death of griefing, resulting into Respawn
451 EnableControls(false);
452
453 if (breakType != SCR_ETutorialBreakType.PLAYER_DEATH)
454 CreateWarningOverlay(breakType == SCR_ETutorialBreakType.PLAYER_GRIEFING_NPC);
455
456 Fadeout(true).GetOnCompleted().Insert(HandleRespawnBreak);
457 }
458
459 //------------------------------------------------------------------------------------------------
460 protected void HandleRespawnBreak()
461 {
463 m_OngoingFadeAnimation.GetOnCompleted().Remove(HandleRespawnBreak);
464
466
467 // If player died, respawn him as soon as possible
468 if (m_iBreakType == SCR_ETutorialBreakType.PLAYER_DEATH)
469 {
470 SpawnPlayer("Respawn_Ambulance");
471 return;
472 }
473
474 GetGame().GetCallqueue().CallLater(SpawnPlayer, PUNISHMENT_TIMEOUT, false, "FT_HUB");
475 }
476
477 //------------------------------------------------------------------------------------------------
479 {
480 SCR_HintManagerComponent.HideHint();
481 SCR_HintManagerComponent.ClearLatestHint();
482
483 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
484 if (editorManager && editorManager.IsOpened())
485 editorManager.Toggle();
486
488 foreach (SCR_NarrativeComponent narratedCharacter : m_aNarratedCharacters)
489 {
490 narratedCharacter.Initialize(narratedCharacter.GetOwner());
491 }
492
494 HandleGarbage(true);
495
498
501
503 m_OngoingFadeAnimation.GetOnCompleted().Remove(FinalizeBreak);
504
505 if (m_iBreakType == SCR_ETutorialBreakType.PLAYER_DEATH)
506 {
507 if (m_Stage)
508 GetGame().GetCallqueue().CallLater( m_Stage.PlayNarrativeCharacterStage, 2000, false, "Ambulance_Doctor", 1);
509 }
510
511 m_bCourseBreaking = false;
512
514 m_wPunishmentScreen.RemoveFromHierarchy();
515
516 Fadeout(false);
517
518 if (m_bOutroBreak)
519 {
521 m_bOutroBreak = false;
522 }
523 }
524
525 //------------------------------------------------------------------------------------------------
527 {
528 return m_bCourseBreaking;
529 }
530
531 //------------------------------------------------------------------------------------------------
532 //TODO: Look into gamemode, if it could be fixed
533 void EnableControls(bool enable)
534 {
535 if (!m_Player)
536 return;
537
538 CharacterControllerComponent characterController = m_Player.GetCharacterController();
539 if (!characterController)
540 return;
541
542 characterController.SetDisableViewControls(!enable);
543 characterController.SetDisableWeaponControls(!enable);
544 characterController.SetDisableMovementControls(!enable)
545 }
546
547 //------------------------------------------------------------------------------------------------
549 {
551 if (!hudManager)
552 return null;
553
554 m_wPunishmentScreen = hudManager.CreateLayout("{33548E2300BFF61C}UI/layouts/HUD/GameOver/Tutorial_Punishment.layout", EHudLayers.ALWAYS_TOP, 0);
556 return null;
557
558 TextWidget text = TextWidget.Cast(m_wPunishmentScreen.FindAnyWidget("GameOver_Description"));
559 if (text)
560 {
561 if (killedNPC)
562 text.SetText("#AR-Tutorial_Hint_CourseTerminatedByFriendlyFire");
563 else
564 text.SetText("#AR-Tutorial_Hint_CourseTerminatedByMisbehaving");
565 }
566
567 return m_wPunishmentScreen;
568 }
569
570 //------------------------------------------------------------------------------------------------
572 {
574 return false;
575
576 SCR_ETutorialArlandStageMasters courseType = m_ActiveConfig.GetCourseType();
577
578 return courseType != SCR_ETutorialCourses.FREE_ROAM && courseType != SCR_ETutorialCourses.INTRO && courseType != SCR_ETutorialCourses.OUTRO;
579 }
580
581 //------------------------------------------------------------------------------------------------
586
587 //------------------------------------------------------------------------------------------------
592
593 //------------------------------------------------------------------------------------------------
594 void PlayNarrativeCharacterStageDelayed(string characterName, int stage)
595 {
596 IEntity entity = GetGame().GetWorld().FindEntityByName(characterName);
597
598 if (!entity)
599 return;
600
601 SCR_NarrativeComponent narrative = SCR_NarrativeComponent.Cast(entity.FindComponent(SCR_NarrativeComponent));
602
603 if (!narrative)
604 return;
605
608
609 m_aNarratedCharacters.Insert(narrative);
610
611 narrative.PlayAnimation(true, "CMD_NarrativeStage", stage);
612 }
613
614 //------------------------------------------------------------------------------------------------
616 {
617 m_aMarkers.Insert(marker);
618 }
619
620 //------------------------------------------------------------------------------------------------
621 static SCR_TutorialGamemodeComponent GetInstance()
622 {
623 BaseGameMode gamemode = GetGame().GetGameMode();
624 if (!gamemode)
625 return null;
626
627 return SCR_TutorialGamemodeComponent.Cast(gamemode.FindComponent(SCR_TutorialGamemodeComponent));
628 }
629
630 //------------------------------------------------------------------------------------------------
635
636 //------------------------------------------------------------------------------------------------
637 //TODO> Perhaps simply going through all entities in inventory would be better
639 {
640 SCR_InventoryStorageManagerComponent inventory = GetPlayerInventory();
641 if (!inventory)
642 return null;
643
645 predicate.m_sSeachPrefab = prefabName;
646
647 IEntity item = inventory.FindItem(predicate);
648 if (item)
649 return item;
650
652 if (!storageComp)
653 return null;
654
655 item = storageComp.GetCurrentItem();
656 if (item && item.GetPrefabData().GetPrefabName() == prefabName)
657 return item;
658
659 array <IEntity> entities = storageComp.GetQuickSlotEntitiesOnly();
660 foreach (IEntity ent : entities)
661 {
662 if (!ent)
663 continue;
664
665 if (ent.GetPrefabData().GetPrefabName() == prefabName)
666 return ent;
667 }
668
669 return null;
670 }
671
672 //------------------------------------------------------------------------------------------------
673 bool IsEntityInPlayerInventory(string entityName)
674 {
675 IEntity ent = GetGame().GetWorld().FindEntityByName(entityName);
676 if (!ent)
677 return false;
678
679 return IsEntityInPlayerInventory(ent);
680 }
681
682 //------------------------------------------------------------------------------------------------
684 {
685 SCR_InventoryStorageManagerComponent inventory = GetPlayerInventory();
686 if (!inventory)
687 return false;
688
689 if (inventory.Contains(entity))
690 return true;
691
693 predicate.m_SearchEntity = entity;
694
695 IEntity item = inventory.FindItem(predicate);
696 if (item)
697 return true;
698
700 if (!storageComp)
701 return false;
702
703 item = storageComp.GetCurrentItem();
704 if (item == entity)
705 return true;
706
707 array <IEntity> entities = storageComp.GetQuickSlotEntitiesOnly();
708 foreach (IEntity ent : entities)
709 {
710 if (ent == entity)
711 return true;
712 }
713
714 return false;
715 }
716
717 //------------------------------------------------------------------------------------------------
718 SCR_InventoryStorageManagerComponent GetPlayerInventory()
719 {
720 if (!m_Player)
721 return null;
722
723 return SCR_InventoryStorageManagerComponent.Cast(m_Player.FindComponent(SCR_InventoryStorageManagerComponent));
724 }
725
726 //------------------------------------------------------------------------------------------------
728 {
730 if (!playerController)
731 return;
732
733 SCR_PlayerControllerGroupComponent playerGroupComp = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
734 if (!playerGroupComp)
735 return;
736
737 SCR_GroupsManagerComponent groupsManager = SCR_GroupsManagerComponent.GetInstance();
738 if (!groupsManager)
739 return;
740
742
743 SCR_AIGroup group = groupsManager.FindGroup(playerGroupComp.GetGroupID());
744 //create group, if there is none
745 if (!group)
746 group = SCR_GroupsManagerComponent.GetInstance().CreateNewPlayableGroup(factionComp.GetAffiliatedFaction());
747
748 playerGroupComp.RequestJoinGroup(group.GetGroupID());
749 groupsManager.SetGroupLeader(group.GetGroupID(), 1);
750
753
754 //SCR_GadgetManagerComponent.GetOnGadgetInitDoneInvoker().Insert(OnControllableEntitySpawned);
755 SCR_CommandingManagerComponent.GetInstance().ResetSlaveGroupWaypoints(1, m_Player);
756 }
757
758 //------------------------------------------------------------------------------------------------
759 void EnableArsenal(string entityName, bool enable)
760 {
761 IEntity entity = GetGame().GetWorld().FindEntityByName(entityName);
762 if (!entity)
763 return;
764
766 if (arsenalComp)
767 arsenalComp.SetArsenalEnabled(enable);
768 }
769
770 //------------------------------------------------------------------------------------------------
775
776 //------------------------------------------------------------------------------------------------
778 {
779 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
780 if (!taskSystem)
781 return null;
782
783 array <SCR_Task> tasks = {};
784 taskSystem.GetTasks(tasks);
785
786 string taskId;
787
788 foreach (SCR_Task task : tasks)
789 {
790 if (!task)
791 continue;
792
793 taskId = task.GetTaskID();
794 if (!SCR_StringHelper.IsEmptyOrWhiteSpace(taskId) && taskId.ToInt() == course)
795 return task;
796 }
797
798 return null;
799 }
800
801 //------------------------------------------------------------------------------------------------
802 protected void CreateCourseTask(SCR_ETutorialCourses courseType)
803 {
804 if (!m_CoursesConfig)
805 return;
806
807 if (GetCourseTask(courseType))
808 return;
809
810 SCR_TutorialCourse course = m_CoursesConfig.GetCourse(courseType);
811 if (!course)
812 return;
813
814 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
815 if (!taskSystem)
816 return;
817
819 if (courseType == SCR_ETutorialCourses.OUTRO)
820 {
821 IEntity posEnt = GetGame().GetWorld().FindEntityByName("SpawnPos_Captain_Table");
822 if (posEnt)
823 position = posEnt.GetOrigin();
824 }
825 else
826 {
827 foreach (SCR_TutorialInstructorComponent instructor : m_aInstructors)
828 {
829 if (!instructor || instructor.GetCourseType() != courseType)
830 continue;
831
832 position = instructor.GetOwner().GetOrigin();
833 break;
834 }
835 }
836
837 if (position == vector.Zero)
838 {
839 IEntity positionEntity = course.GetFastTravelPosition();
840 if (positionEntity)
841 position = positionEntity.GetOrigin();
842 }
843
844 SCR_Task task = taskSystem.CreateTask("{1D0F815858EE24AD}Prefabs/Tasks/BaseTask.et", course.GetCourseType().ToString(), course.GetTaskTitle(), course.GetTaskDescription(), position);
845 if (!task)
846 return;
847
848 task.SetTaskIconPath("{D43428C02A644C1B}UI/Imagesets/Tutorial-Courses/Tutorial-Courses.imageset");
849 task.SetTaskIconSetName(course.GetTaskIcon());
850 task.SetTaskVisibility(SCR_ETaskVisibility.NONE);
851 }
852
853 //------------------------------------------------------------------------------------------------
855 {
856 return m_bIsFastTraveling;
857 }
858
859 //------------------------------------------------------------------------------------------------
860 void SpawnPlayer(string spawnPositionName)
861 {
862 SCR_MapEntity mapEnt = SCR_MapEntity.Cast(GetGame().GetMapManager());
863 if (mapEnt)
864 mapEnt.CloseMap();
865
866 MenuManager menuManager = GetGame().GetMenuManager();
867 if (menuManager)
868 {
869 MenuBase mapMenu = menuManager.FindMenuByPreset(ChimeraMenuPreset.MapMenu);
870 if (mapMenu)
871 menuManager.CloseMenu(mapMenu);
872 }
873
875 if (!pc)
876 return;
877
878 pc.SetGadgetFocus(false);
879
880 IEntity spawnpos = GetGame().GetWorld().FindEntityByName(spawnPositionName);
881 if (!spawnpos)
882 return;
883
884 SCR_PlayerLoadoutComponent playerLoadoutComp = SCR_PlayerLoadoutComponent.Cast(pc.FindComponent(SCR_PlayerLoadoutComponent));
885 if (!playerLoadoutComp)
886 return;
887
888 SCR_BasePlayerLoadout loadout = playerLoadoutComp.GetLoadout();
889 if (!loadout)
890 return;
891
892 SCR_FreeSpawnData data = new SCR_FreeSpawnData(loadout.GetLoadoutResource(), spawnpos.GetOrigin(), spawnpos.GetAngles());
893 SCR_RespawnComponent.Cast(pc.FindComponent(SCR_RespawnComponent)).RequestSpawn(data);
894
895 spawnpos = spawnpos.GetChildren();
896 if (spawnpos)
897 SpawnAsset("PlayerVehicle", m_sPlayerVehicleResourceName, spawnpos);
898 }
899
900 //------------------------------------------------------------------------------------------------
901 SCR_TutorialInstructorComponent GetCourseInstructor(SCR_ETutorialCourses course)
902 {
903 foreach (SCR_TutorialInstructorComponent instructor : m_aInstructors)
904 {
905 if (!instructor)
906 continue;
907
908 if (instructor.GetCourseType() == course)
909 return instructor;
910 }
911
912 return null;
913 }
914
915 //------------------------------------------------------------------------------------------------
916 void GetInstructors(notnull array<SCR_TutorialInstructorComponent> instructors)
917 {
918 instructors.Copy(m_aInstructors);
919 }
920
921 //------------------------------------------------------------------------------------------------
922 void UnregisterInstructor(notnull SCR_TutorialInstructorComponent instructor)
923 {
924 if (m_aInstructors)
925 m_aInstructors.RemoveItem(instructor);
926 }
927
928 //------------------------------------------------------------------------------------------------
929 void RegisterInstructor(notnull SCR_TutorialInstructorComponent instructor)
930 {
931 SCR_Task task = GetCourseTask(instructor.GetCourseType());
932 if (task)
933 task.SetOrigin(instructor.GetOwner().GetOrigin());
934
935 if (m_aInstructors)
936 m_aInstructors.Insert(instructor);
937 }
938
939 //------------------------------------------------------------------------------------------------
941 {
942 if (!m_CoursesConfig)
943 return false;
944
945 #ifdef ENABLE_DIAG
946 if (m_bIgnoreCourseRequirements && courseType != SCR_ETutorialCourses.OUTRO)
947 return true;
948 #endif
949
950 SCR_TutorialCourse course = m_CoursesConfig.GetCourse(courseType);
951 if (!course)
952 return false;
953
954 return SCR_Enum.HasFlag(m_eFinishedCourses, course.GetRequiredCourses());
955 }
956
957 //------------------------------------------------------------------------------------------------
959 {
960 if (!m_CoursesConfig)
961 return;
962
963 SCR_TutorialCourse courseConf = m_CoursesConfig.GetCourse(course);
964 if (!courseConf)
965 return;
966
967 IEntity playerPos, vehiclePos;
968 playerPos = courseConf.GetFastTravelPosition();
969
970 while (playerPos)
971 {
972 if (playerPos.IsInherited(SCR_Position))
973 {
974 vehiclePos = playerPos.GetChildren();
975 break;
976 }
977
978 playerPos = playerPos.GetSibling();
979 }
980
981 if (playerPos)
982 FastTravel(playerPos);
983
984 if (vehiclePos)
985 SpawnAsset("PlayerVehicle", m_sPlayerVehicleResourceName, vehiclePos);
986 }
987
988 //------------------------------------------------------------------------------------------------
989 // Fast traveling
990 void FastTravel(notnull IEntity toEnt)
991 {
992 m_bIsFastTraveling = true;
993 m_FastTravelPosition = toEnt;
994
995 if (m_ActiveConfig.GetCourseType() == SCR_ETutorialCourses.FREE_ROAM)
996 m_Stage.UnregisterWaypoint("CampGreenhornSign");
997
998 Fadeout(true).GetOnCompleted().Insert(OnFastTravelFadeoutCompleted);
999 }
1000
1001 //------------------------------------------------------------------------------------------------
1003 {
1004 SCR_BaseGameMode gamemode = GetGameMode();
1005 if (!gamemode)
1006 return;
1007
1008 if (m_Player && m_Player.IsInVehicle())
1009 {
1010 CompartmentAccessComponent compartmentComp = m_Player.GetCompartmentAccessComponent();
1011 if (compartmentComp)
1012 {
1013 IEntity vehicle = compartmentComp.GetVehicleIn(m_Player);
1014 if (vehicle)
1015 vehicle.GetPhysics().SetVelocity("0 0 0");
1016
1017 compartmentComp.GetOutVehicle(EGetOutType.TELEPORT, -1, false, false);
1018
1019 //Call later for repeated attempt to finalize Fast Travel, after player leaves the vehicle
1020 GetGame().GetCallqueue().CallLater(OnFastTravelFadeoutCompleted, 1000);
1021 return;
1022 }
1023 }
1024
1026 gamemode.StartSpawnPreload(m_FastTravelPosition.GetOrigin());
1027 }
1028
1029 //------------------------------------------------------------------------------------------------
1031 {
1032 SCR_BaseGameMode gamemode = GetGameMode();
1033 if (!gamemode)
1034 return;
1035
1037
1038 vector transformation[4];
1039 m_FastTravelPosition.GetTransform(transformation);
1040
1042 if (!player)
1043 return;
1044
1045 ChimeraWorld world = GetGame().GetWorld();
1046 if (!world)
1047 return;
1048
1049 TimeAndWeatherManagerEntity tmwManager = world.GetTimeAndWeatherManager();
1050 if (!tmwManager)
1051 return;
1052
1053 tmwManager.SetTimeOfTheDay(tmwManager.GetTimeOfTheDay()+0.2);
1054
1055 if (!player.GetDamageManager().IsDestroyed())
1056 player.Teleport(transformation);
1057 else
1059
1060 m_bIsFastTraveling = false;
1061 m_FastTravelPosition = null;
1062 Fadeout(false);
1063 HealPlayer();
1064
1066
1067 if (hudManager)
1068 {
1070
1071 if (subtitlesDisplay)
1072 subtitlesDisplay.Show(false);
1073 }
1074
1075 m_OnFastTravelDone.Invoke();
1076 }
1077
1078 //------------------------------------------------------------------------------------------------
1083
1084 //------------------------------------------------------------------------------------------------
1085 protected void SetupVoiceSystem()
1086 {
1087 if (!m_VoiceoverSystem)
1089
1090 if (!m_ActiveConfig)
1091 return;
1092
1093 ResourceName voiceDataConfig = m_ActiveConfig.GetVoiceOverDataConfig();
1094 if (voiceDataConfig.IsEmpty())
1095 return;
1096
1097 m_VoiceoverSystem.SetData(voiceDataConfig);
1098 }
1099
1100 //------------------------------------------------------------------------------------------------
1102 {
1103 SCR_MapMarkerManagerComponent mapMarkerManager = SCR_MapMarkerManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_MapMarkerManagerComponent));
1104 if (!mapMarkerManager)
1105 return;
1106
1107 array <SCR_MapMarkerBase> markerArray = {};
1108 markerArray = mapMarkerManager.GetStaticMarkers();
1109 for (int index = markerArray.Count()-1; index >= 0; index--)
1110 {
1111 if (!markerArray.IsIndexValid(index) || !markerArray[index])
1112 continue;
1113
1114 mapMarkerManager.RemoveStaticMarker(markerArray[index]);
1115 }
1116
1117 // TODO: Fix the following:
1118 // Without keeping markers in this array the marker system loses last pointer during RemoveStaticMarker and produces a VME
1119 m_aMarkers.Clear();
1120 }
1121
1122 //------------------------------------------------------------------------------------------------
1125 {
1126 /* Achievement SWEAT_SAVES_BLOOD */
1128 if (!playerController)
1129 return;
1130
1131 SCR_AchievementsHandler handler = SCR_AchievementsHandler.Cast(playerController.FindComponent(SCR_AchievementsHandler));
1132 if (!handler)
1133 return;
1134
1135 handler.UnlockAchievement(AchievementId.SWEAT_SAVES_BLOOD);
1136 }
1137
1138 //------------------------------------------------------------------------------------------------
1142 void ShowMapDescriptor(string descriptorOwnerName, bool enable)
1143 {
1144 IEntity ent = GetGame().GetWorld().FindEntityByName(descriptorOwnerName);
1145 if (!ent)
1146 return;
1147
1148 SCR_MapDescriptorComponent descr = SCR_MapDescriptorComponent.Cast(ent.FindComponent(SCR_MapDescriptorComponent));
1149 if (!descr)
1150 return;
1151
1152 descr.Item().SetVisible(enable);
1153 }
1154
1155 //------------------------------------------------------------------------------------------------
1156 bool IsPlayerAimingInAngle(float angle, int tolerance)
1157 {
1158 if (!m_Player)
1159 return false;
1160
1161 CharacterControllerComponent charController = m_Player.GetCharacterController();
1162 if (!charController)
1163 return false;
1164
1165 CharacterInputContext inputContext = charController.GetInputContext();
1166 if (!inputContext)
1167 return false;
1168
1169 float aimAngle = Math.MapAngle(Math.RAD2DEG * inputContext.GetAimingAngles()[0], 360, 0, 360);
1170
1171 return Math.IsInRange(aimAngle, angle-tolerance, angle+tolerance);
1172 }
1173
1174 //------------------------------------------------------------------------------------------------
1177 {
1178 if (modeEntity.GetModeType() != EEditorMode.BUILDING)
1179 return;
1180
1182 if (!m_PlacingComponent)
1183 return;
1184
1185 m_PlacingComponent.GetOnPlaceEntityServer().Insert(OnEntitySpawned);
1186 }
1187
1188 //------------------------------------------------------------------------------------------------
1191 {
1192 if (!SCR_HintManagerComponent.GetInstance())
1193 return;
1194
1195 if (m_Stage)
1196 {
1197 SCR_HintUIInfo hintInfo = m_Stage.GetStageInfo().GetHint();
1198 if (hintInfo)
1199 SCR_HintManagerComponent.ShowHint(hintInfo, true);
1200 }
1201 }
1202
1203 //------------------------------------------------------------------------------------------------
1206 {
1207 if (!m_PlacingComponent)
1208 return null;
1209
1210 IEntity ent = m_PlacingComponent.GetOwner();
1211 if (!ent)
1212 return null;
1213
1215 }
1216
1217 //------------------------------------------------------------------------------------------------
1220 {
1222 if (!core)
1223 return;
1224
1225 SCR_EditorManagerEntity editorManager = core.GetEditorManager();
1226 if (!editorManager)
1227 return;
1228
1229 editorManager.GetOnModeAdd().Insert(OnModeAdded);
1230 editorManager.GetOnClosed().Insert(OnEditorClosed);
1231 }
1232
1233 //------------------------------------------------------------------------------------------------
1239
1240 //------------------------------------------------------------------------------------------------
1241 protected void OnEntitySpawned(int prefabID, SCR_EditableEntityComponent ent)
1242 {
1243 if (!ent)
1244 return;
1245
1246 m_OnEntitySpawned.Invoke(ent.GetOwner());
1247 }
1248
1249 //------------------------------------------------------------------------------------------------
1254
1255 //------------------------------------------------------------------------------------------------
1256 protected void OnObjectDestroyed(EDamageState state)
1257 {
1258 if (state == EDamageState.DESTROYED)
1260 }
1261
1262 //------------------------------------------------------------------------------------------------
1263 protected void OnInputDeviceIsGamepad(bool isGamepad)
1264 {
1265 if (!SCR_HintManagerComponent.GetInstance())
1266 return;
1267
1268 if (!SCR_HintManagerComponent.GetInstance().IsShown())
1269 return;
1270
1271 m_bIsUsingGamepad = isGamepad;
1272
1274 return;
1275
1277 GetGame().GetCallqueue().CallLater(OnInputDeviceChangedDelayed, 250);
1278 }
1279
1280 //------------------------------------------------------------------------------------------------
1282 {
1284 bool switchedToKeyboard = !m_bIsUsingGamepad;
1285 m_Stage.OnInputDeviceChanged(switchedToKeyboard);
1286 }
1287
1288 //------------------------------------------------------------------------------------------------
1291 {
1292 return m_Player;
1293 }
1294
1295 //------------------------------------------------------------------------------------------------
1297 {
1298 return m_bIsUsingGamepad;
1299 }
1300
1301 //------------------------------------------------------------------------------------------------
1304 WidgetAnimationOpacity Fadeout(bool fadeOut, float duration = 1, float soundDuration = duration)
1305 {
1306 if (!m_wFadeOut)
1307 {
1309 if (!hudManager)
1310 return null;
1311
1312 m_wFadeOut = ImageWidget.Cast(hudManager.CreateLayout(FADEOUT_LAYOUT, EHudLayers.OVERLAY));
1313
1314 if (!m_wFadeOut)
1315 return null;
1316 }
1317
1319 {
1321 }
1322 else
1323 {
1324 m_OngoingFadeAnimation.SetTargetValue(fadeOut);
1325 m_OngoingFadeAnimation.SetSpeed(duration);
1326 }
1327
1328 SetSoundFade(fadeOut, soundDuration);
1329
1331
1332 }
1333
1334 //------------------------------------------------------------------------------------------------
1340 IEntity SpawnAsset(string name, ResourceName type, IEntity spawnpoint = null, bool respawn = true)
1341 {
1342 if (!spawnpoint)
1343 spawnpoint = GetGame().GetWorld().FindEntityByName(string.Format("SpawnPos_%1", name));
1344
1345 if (!spawnpoint)
1346 return null;
1347
1348 IEntity oldEntity;
1349 if (name != string.Empty)
1350 oldEntity = GetGame().GetWorld().FindEntityByName(name);
1351
1352 if (oldEntity && respawn)
1353 {
1354 if (m_Player && m_Player.GetParent() == oldEntity)
1355 {
1356 oldEntity.SetName("OldPlayerVeh");
1357
1358 //Fix for edge case, where player leaves vehicle during induced course break. As vehicle got removed, so did the player...
1359 GetGame().GetCallqueue().CallLater(SCR_EntityHelper.DeleteEntityAndChildren, 1000, false, oldEntity);
1360 }
1361 else
1362 {
1363 SCR_EntityHelper.DeleteEntityAndChildren(oldEntity);
1364 }
1365 }
1366 else if (oldEntity)
1367 {
1368 return oldEntity;
1369 }
1370
1372 params.TransformMode = ETransformMode.WORLD;
1373 spawnpoint.GetWorldTransform(params.Transform);
1374 Resource res = Resource.Load(type);
1375
1376 if (!res)
1377 return null;
1378
1379 IEntity newEntity = GetGame().SpawnEntityPrefab(res, null, params);
1380 if (!newEntity)
1381 return null;
1382
1383 newEntity.SetName(name);
1384
1385 Vehicle veh = Vehicle.Cast(newEntity);
1386 if (veh)
1387 {
1388 Physics physicsComponent = veh.GetPhysics();
1389
1390 if (physicsComponent)
1391 physicsComponent.SetVelocity("0 -1 0");
1392 }
1393
1394 if (newEntity && newEntity.IsInherited(ChimeraCharacter))
1395 {
1396 SCR_DamageManagerComponent damManager = SCR_DamageManagerComponent.Cast(newEntity.FindComponent(SCR_DamageManagerComponent));
1397 if (!damManager)
1398 return newEntity;
1399
1400 damManager.GetOnDamage().Insert(OnCharacterDamaged);
1401 }
1402
1403 EnableRefunding(newEntity, false);
1404
1405 return newEntity;
1406 }
1407
1408 //------------------------------------------------------------------------------------------------
1411 {
1412 m_bIsMapOpen = true;
1413 }
1414
1415 //------------------------------------------------------------------------------------------------
1418 {
1419 m_bIsMapOpen = false;
1420 }
1421
1422 //------------------------------------------------------------------------------------------------
1425 {
1426 return m_bIsMapOpen;
1427 }
1428
1429 //------------------------------------------------------------------------------------------------
1434 {
1436 bool ret = false;
1437
1438 if (!comp)
1439 return false;
1440
1442 comp.GetMovementState(mState);
1443
1444 if (mState)
1445 ret = mState.m_CommandTypeId == command;
1446
1447 delete mState;
1448 return ret;
1449 }
1450
1451 //------------------------------------------------------------------------------------------------
1454 {
1456 }
1457
1458 //------------------------------------------------------------------------------------------------
1459 void SetFreeRoamActivation(int activations)
1460 {
1461 m_iFreeRoamActivations = activations;
1462 }
1463
1464 //------------------------------------------------------------------------------------------------
1469
1470 //------------------------------------------------------------------------------------------------
1473 {
1474 if (!m_Player)
1475 return;
1476
1478 if (!comp)
1479 return;
1480
1481 if (comp.IsInThirdPerson())
1482 {
1483 m_bUsed3PV = true;
1484 GetGame().GetCallqueue().Remove(Check3rdPersonViewUsed);
1485
1486 /*if (m_eStage == SCR_ECampaignTutorialArlandStage.WALL)
1487 GetGame().GetCallqueue().Remove(DelayedPopup);*/
1488 }
1489 }
1490
1491 //------------------------------------------------------------------------------------------------
1494 {
1495 return m_bUsed3PV;
1496 }
1497
1498 //------------------------------------------------------------------------------------------------
1507 void DelayedPopup(string text = "", string subtitle = "", float duration = SCR_PopUpNotification.DEFAULT_DURATION, string param1 = "", string param2 = "", string subtitleParam1 = "", string subtitleParam2 = "")
1508 {
1509 SCR_PopUpNotification.GetInstance().PopupMsg(text, duration, text2: subtitle, param1: param1, param2: param2, text2param1: subtitleParam1, text2param2: subtitleParam2, category: SCR_EPopupMsgFilter.TUTORIAL);
1510 }
1511
1512 //------------------------------------------------------------------------------------------------
1516 {
1517 if (m_Stage)
1518 m_Stage.OnStructureBuilt(base, structure);
1519 }
1520
1521 //------------------------------------------------------------------------------------------------
1522 //WAYPOINT LOGIC
1523 //------------------------------------------------------------------------------------------------
1525 {
1526 if (!m_WaypointDisplay)
1527 {
1529 if (!hudManager)
1530 return null;
1531
1533 }
1534
1535 return m_WaypointDisplay;
1536 }
1537
1538 //------------------------------------------------------------------------------------------------
1539 //STAGE LOGIC
1540 //------------------------------------------------------------------------------------------------
1541
1542 //------------------------------------------------------------------------------------------------
1546 void InsertStage(string stageName, int position = -1)
1547 {
1548 SCR_TutorialStageInfo stageToAdd = m_ActiveConfig.GetStageByName(stageName);
1549 if (!stageToAdd)
1550 return;
1551
1552 if (position > -1)
1553 m_aStageInfos.InsertAt(stageToAdd, position);
1554 else
1555 m_aStageInfos.InsertAt(stageToAdd, m_iActiveStage+1);
1556
1557 }
1558
1559 //------------------------------------------------------------------------------------------------
1562 {
1563 return m_iActiveStage;
1564 }
1565
1566 //------------------------------------------------------------------------------------------------
1568 {
1570 SCR_ETutorialCourses finishedCourse = m_ActiveConfig.GetCourseType();
1571
1572 if (!m_aStageInfos.IsIndexValid(m_iActiveStage))
1573 {
1574 array <SCR_ETutorialCourses> finishedCourses = {};
1575 SCR_Enum.GetEnumValues(SCR_ETutorialCourses, finishedCourses);
1576
1577 for (int i = finishedCourses.Count()-1; i >= 0; i--)
1578 {
1579 if (IsCourseAvailable(finishedCourses[i]))
1580 finishedCourses.Remove(i);
1581 }
1582
1583 //TODO: NULLCHECK m_ActiveConfig
1585
1586 for (int i = finishedCourses.Count()-1; i >= 0; i--)
1587 {
1588 if (!IsCourseAvailable(finishedCourses[i]))
1589 finishedCourses.Remove(i);
1590 }
1591
1592 SCR_HintManagerComponent.HideHint();
1593 SCR_HintManagerComponent.ClearLatestHint();
1594
1595 GenerateTasks();
1596
1597 string description;
1598 foreach (SCR_ETutorialCourses course : finishedCourses)
1599 {
1600 description += m_CoursesConfig.GetCourse(course).GetTaskTitle() + "<br/>";
1601 }
1602
1603 if (!description.IsEmpty())
1604 {
1605 SCR_HintUIInfo hintInfo = SCR_HintUIInfo.CreateInfo(description, "#AR-Tutorial_Hint_CoursesUnlocked", 7, EHint.UNDEFINED, EFieldManualEntryId.NONE, false);
1606 SCR_HintManagerComponent.ShowHint(hintInfo);
1607 }
1608
1609 if (m_ActiveConfig && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.INTRO && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.OUTRO)
1610 {
1611 SCR_PopUpNotification.GetInstance().PopupMsg("#AR-Tutorial_Popup_CourseFinished-UC", text2: m_ActiveConfig.GetTaskTitle(), duration: 7);
1612
1613 ChimeraWorld world = GetGame().GetWorld();
1614 MusicManager manager = world.GetMusicManager();
1615
1616 if (manager)
1617 manager.Play(SCR_SoundEvent.SOUND_ONBASECAPTURE);
1618
1619 }
1620
1621 //if (m_ActiveConfig && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.INTRO)
1622 // SCR_AnalyticsApplication.GetInstance().TutorialCourseEnds(finishedCourse, SCR_EAnalyticsCourseEndReason.COMPLETED);
1623
1624 m_iActiveStage = 0;
1625
1627 {
1629
1630 if (!m_bStagesComplete)
1631 {
1632 m_bStagesComplete = true;
1634 }
1635 }
1636 else
1637 {
1639 }
1640
1641 ChimeraWorld world = GetGame().GetWorld();
1642
1643 if (world)
1644 {
1645 if (finishedCourse == SCR_ETutorialCourses.OUTRO)
1646 world.GetMusicManager().Play("SOUND_END_GOOD");
1647 else if (finishedCourse != SCR_ETutorialCourses.INTRO && finishedCourse != SCR_ETutorialCourses.FREE_ROAM)
1648 world.GetMusicManager().Play("SOUND_COURSE_DONE");
1649 }
1650
1651 GetGame().GetSaveGameManager().RequestSavePoint(ESaveGameType.AUTO);
1652 return;
1653 }
1654
1656 }
1657
1658 //------------------------------------------------------------------------------------------------
1659 int GetStageIndexByName(string name)
1660 {
1661 if (!m_aStageInfos || m_aStageInfos.IsEmpty())
1662 return -1;
1663
1664 foreach (int i, SCR_TutorialStageInfo info : m_aStageInfos)
1665 {
1666 if (info.GetStageName() == name)
1667 return i;
1668 }
1669
1670 return -1;
1671 }
1672
1673 //------------------------------------------------------------------------------------------------
1674 void SetStage(string stageName)
1675 {
1676 SetStage(GetStageIndexByName(stageName));
1677 }
1678
1679 //------------------------------------------------------------------------------------------------
1681 void SetStage(int stage)
1682 {
1683 if (stage <= -1)
1684 return;
1685
1686 delete m_Stage;
1688
1689 // Run the next stage
1690 if (!m_aStageInfos)
1691 {
1693 return;
1694 }
1695
1696 if (!m_aStageInfos.IsIndexValid(stage))
1697 return;
1698
1699 m_Stage = SCR_BaseTutorialStage.Cast(GetGame().SpawnEntity(m_aStageInfos[stage].GetClassName().ToType()));
1700 m_Stage.Init(m_aStageInfos[stage]);
1701
1702 m_iActiveStage = stage;
1703 }
1704
1705 //------------------------------------------------------------------------------------------------
1707 void SetCourseConfig(SCR_ETutorialCourses config, string stageName = string.Empty, bool spawnAssets = true)
1708 {
1709 if (!m_CoursesConfig)
1710 return;
1711
1713
1714 //Finish any current course
1715 if (m_ActiveConfig)
1716 m_ActiveConfig.OnFinish();
1717
1718 //Clear old stages
1719 m_aStageInfos.Clear();
1720 delete m_Stage;
1721
1722 m_aNarratedCharacters = null;
1723
1725
1726 m_ActiveConfig = m_CoursesConfig.GetCourse(config);
1727 if (!m_ActiveConfig)
1728 return;
1729
1730 m_ActiveConfig.GetStages(m_aStageInfos);
1731
1732 if (spawnAssets)
1734
1735 if (m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.FREE_ROAM && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.INTRO && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.OUTRO)
1736 {
1737 IEntity position = m_ActiveConfig.GetFastTravelPosition();
1738 if (position)
1739 {
1740 position = position.GetChildren();
1741 IEntity playerVehicle = GetGame().GetWorld().FindEntityByName("PlayerVehicle");
1742 if (!playerVehicle || (vector.Distance(playerVehicle.GetOrigin(), position.GetOrigin()) >= 15))
1744 }
1745 }
1746
1748
1749 m_iActiveStage = 0;
1750 m_ActiveConfig.OnStart();
1751
1752 if (!SCR_StringHelper.IsEmptyOrWhiteSpace(stageName))
1753 InsertStage(stageName, 0);
1754
1755 SetStage(0);
1756
1759
1760 HideTasks(m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.FREE_ROAM);
1761
1762 if (config != SCR_ETutorialCourses.INTRO && config != SCR_ETutorialCourses.FREE_ROAM && config != SCR_ETutorialCourses.OUTRO)
1763 {
1764 ChimeraWorld world = GetGame().GetWorld();
1765
1766 if (world)
1767 world.GetMusicManager().Play("SOUND_COURSE_START");
1768 }
1769
1770 //if (config != SCR_ETutorialCourses.INTRO && config != SCR_ETutorialCourses.FREE_ROAM)
1771 // SCR_AnalyticsApplication.GetInstance().TutorialCourseStarts(config);
1772 }
1773
1774 //------------------------------------------------------------------------------------------------
1776 {
1777 if (!m_Stage || m_bCourseBreaking)
1778 return;
1779
1780 Instigator instigator = damageContext.instigator;
1781 if (!instigator)
1782 return;
1783
1784 //Handling of situation, where player crashes vehicle as driver and AI is passanger
1785 if (damageContext.damageType == EDamageType.COLLISION)
1786 {
1787 ChimeraCharacter instigatorEnt = ChimeraCharacter.Cast(instigator.GetInstigatorEntity());
1788 if (instigatorEnt && instigatorEnt.IsInVehicle() && instigatorEnt.GetParent() == damageContext.hitEntity.GetParent())
1789 {
1790 //No damage manager == no damage, so no need to punish
1792 if (!damManager)
1793 return;
1794
1795 //Do nothing unless character is bleeding and alive
1796 if (!damManager.IsBleeding() && !damManager.IsDestroyed())
1797 return;
1798
1800 return;
1801 }
1802 }
1803
1804 if (damageContext.damageSource)
1805 RequestBreakCourse(SCR_ETutorialBreakType.PLAYER_GRIEFING_NPC);
1806 }
1807
1808 //------------------------------------------------------------------------------------------------
1810 {
1811 SCR_DamageManagerComponent damManager = SCR_DamageManagerComponent.Cast(ent.FindComponent(SCR_DamageManagerComponent));
1812 if (!damManager)
1813 return false;
1814
1815 return damManager.IsDestroyed() || damManager.GetHealth() != damManager.GetMaxHealth();
1816 }
1817
1818 //------------------------------------------------------------------------------------------------
1820 {
1821 SCR_DamageManagerComponent damManager;
1822 IEntity position, entity;
1823
1824 array <SCR_TutorialCoursePrefabInfo> prefabInfos = {};
1825
1826 if (courseType != -1)
1827 {
1828 SCR_TutorialCourse course = m_CoursesConfig.GetCourse(courseType);
1829 if (!course)
1830 return;
1831
1832 course.GetPrefabs(prefabInfos);
1833 }
1834 else
1835 {
1836 m_ActiveConfig.GetPrefabs(prefabInfos);
1837 }
1838
1839 foreach (SCR_TutorialCoursePrefabInfo prefabInfo : prefabInfos)
1840 {
1841 entity = GetGame().GetWorld().FindEntityByName(prefabInfo.m_sEntityName);
1842 position = GetGame().GetWorld().FindEntityByName(prefabInfo.m_sSpawnPosName);
1843
1844 if ((entity && !prefabInfo.m_bRespawn) || !position)
1845 continue;
1846
1847 if (entity && (prefabInfo.m_bRespawnDamaged && !IsDamagedOrDestroyed(entity)))
1848 continue;
1849
1850 if (entity && prefabInfo.m_bRespawnDistance && (vector.Distance(entity.GetOrigin(), position.GetOrigin()) < prefabInfo.m_fRespawnMinimumDistance))
1851 {
1852 if (!IsDamagedOrDestroyed(entity))
1853 continue;
1854 }
1855
1856 SpawnAsset(prefabInfo.m_sEntityName, prefabInfo.m_sPrefabResourceName, position);
1857 }
1858 }
1859
1860 //------------------------------------------------------------------------------------------------
1862 {
1863 if (!m_ActiveConfig)
1864 return;
1865
1866 array <SCR_TutorialCoursePrefabInfo> prefabInfos = {};
1867 m_ActiveConfig.GetPrefabs(prefabInfos);
1868
1869 IEntity ent;
1870 foreach (SCR_TutorialCoursePrefabInfo prefabInfo : prefabInfos)
1871 {
1872 if (!prefabInfo.m_bDespawnAfterCourse)
1873 continue;
1874
1875 if (prefabInfo.m_sEntityName == string.Empty)
1876 continue;
1877
1878 ent = GetGame().GetWorld().FindEntityByName(prefabInfo.m_sEntityName);
1879 if (!ent)
1880 continue;
1881
1882 SCR_EntityHelper.DeleteEntityAndChildren(ent);
1883 }
1884 }
1885
1886 //------------------------------------------------------------------------------------------------
1887 //OVERRIDE EVENT AND METHODS RespawnPlayer
1888 //------------------------------------------------------------------------------------------------
1889 override void OnPlayerRegistered(int playerId)
1890 {
1891 super.OnPlayerRegistered(playerId);
1892
1893 // Attempt to spawn the player automatically, cease after spawn is successful in OnPlayerSpawned
1894 PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
1895
1896 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
1898 factionComp.RequestFaction(factionManager.GetFactionByKey("US"));
1899
1900 SCR_LoadoutManager loadoutManager = GetGame().GetLoadoutManager();
1901 SCR_PlayerLoadoutComponent loadoutComp = SCR_PlayerLoadoutComponent.Cast(playerController.FindComponent(SCR_PlayerLoadoutComponent));
1902 loadoutComp.RequestLoadout(loadoutManager.GetLoadoutByIndex(0));
1903
1904 if (!m_bFirstStageSet)
1905 {
1906 m_bFirstStageSet = true;
1907
1908 //TODO: @yuri pls fix for the future, very dirty indeed.
1909 GetGame().GetCallqueue().CallLater(Check3rdPersonViewUsed, 500, true);
1910 }
1911
1912 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
1913 if (editorManager)
1914 {
1915 editorManager.SetCanOpen(true, EEditorCanOpen.ALIVE);
1916 editorManager.AutoInit();
1917 }
1918
1919 AudioSystem.SetMasterVolume(AudioSystem.SFX, 0);
1920 }
1921
1922 //------------------------------------------------------------------------------------------------
1923 override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
1924 {
1925 m_Player = ChimeraCharacter.Cast(entity);
1927
1928 ChimeraWorld world = GetGame().GetWorld();
1929 if (!world)
1930 return;
1931
1932 GarbageSystem garbageSys = GarbageSystem.Cast(world.FindSystem(GarbageSystem));
1933 if (garbageSys)
1934 garbageSys.Flush(0);
1935
1936 if (m_ActiveConfig && m_ActiveConfig.GetCourseType() != SCR_ETutorialCourses.INTRO)
1937 Fadeout(false);
1938
1939 m_OnPlayerSpawned.Invoke();
1940
1941 if (world)
1942 world.GetMusicManager().Play("SOUND_ONSPAWN");
1943 }
1944
1945 //------------------------------------------------------------------------------------------------
1946 void PlayBedAnimation(bool fast)
1947 {
1949 if (!characterController)
1950 return;
1951
1952 IEntity position = GetGame().GetWorld().FindEntityByName("Respawn_Start");
1953 if (!position)
1954 return;
1955
1956 vector bedTransformation[4];
1957 position.GetTransform(bedTransformation);
1958
1959 if (fast)
1960 characterController.StartLoitering(position, 8, false, true, true, bedTransformation, false);
1961 else
1962 characterController.StartLoitering(position, 7, true, true, true, bedTransformation, false);
1963
1964 GetGame().GetCallqueue().CallLater(Fadeout, 1500, false, false, 1, 0);
1965 }
1966
1967 //------------------------------------------------------------------------------------------------
1968 //override void OnControllableDestroyed(IEntity entity, IEntity killerEntity, notnull Instigator killer)
1969 override void OnControllableDestroyed(notnull SCR_InstigatorContextData instigatorContextData)
1970 {
1971 IEntity victim = instigatorContextData.GetVictimEntity();
1972
1973 if (!victim)
1974 return;
1975
1976 //Played died
1977 if (victim == m_Player)
1978 {
1980 return;
1981 }
1982
1983 //Character died
1984 ChimeraCharacter character = ChimeraCharacter.Cast(victim);
1985 if (character)
1986 {
1987 IEntity killer = instigatorContextData.GetKillerEntity();
1988 //Ignore punishment if character is sitting in same vehicle as player.
1989 if ((character.IsInVehicle() && killer && character.GetParent() == killer.GetParent() && CanBreakCourse()) || m_ActiveConfig.GetCourseType() == SCR_ETutorialCourses.HELICOPTERS)
1991 else
1992 RequestBreakCourse(SCR_ETutorialBreakType.PLAYER_GRIEFING_NPC);
1993
1994 return;
1995 }
1996
1997 //Vehicle destroyed (and player is not sitting in it)
1999 if (vehDamManager)
2000 OnVehicleDamaged(vehDamManager);
2001 }
2002
2003 //------------------------------------------------------------------------------------------------
2004 protected override void OnGameModeStart()
2005 {
2007 if (hudManager)
2008 {
2009 m_wFadeOut = ImageWidget.Cast(hudManager.CreateLayout(FADEOUT_LAYOUT, EHudLayers.OVERLAY));
2010 if (m_wFadeOut)
2011 m_wFadeOut.SetOpacity(1);
2012 }
2013
2014 GenerateTasks();
2015
2016 IEntity position = GetGame().GetWorld().FindEntityByName("FT_DRIVING");
2017 if (position)
2018 {
2019 position = position.GetChildren();
2020 if (position)
2022 }
2023
2024 IEntity door = GetGame().GetWorld().FindEntityByName("TUT_BAR_DOOR_01");
2025 if (door)
2026 door.SetOrigin("0 -1000 0");
2027
2028 door = GetGame().GetWorld().FindEntityByName("TUT_BAR_DOOR_02");
2029 if (door)
2030 door.SetOrigin("0 -1000 0");
2031
2033 SpawnPlayer("Respawn_Start_Load");
2034 else
2035 SpawnPlayer("Respawn_Start");
2036
2037 #ifdef ENABLE_DIAG
2040 else if (m_bSkipIntro || SCR_Enum.HasFlag(m_eFinishedCourses, SCR_ETutorialCourses.INTRO))
2042 else
2044 #else
2047 else if (SCR_Enum.HasFlag(m_eFinishedCourses, SCR_ETutorialCourses.INTRO))
2049 else
2051 #endif
2052 }
2053
2054 //------------------------------------------------------------------------------------------------
2055 void HideTasks(bool hide)
2056 {
2057 SCR_TaskSystem taskSystem = SCR_TaskSystem.GetInstance();
2058 if (!taskSystem)
2059 return;
2060
2061 array <SCR_Task> tasks = {};
2062 taskSystem.GetTasks(tasks);
2063
2064 string taskId;
2065
2066 foreach (SCR_Task task : tasks)
2067 {
2068 if (!task)
2069 continue;
2070
2071 taskId = task.GetTaskID();
2072 if (SCR_StringHelper.IsEmptyOrWhiteSpace(taskId) || task.GetTaskID().ToInt() == SCR_ETutorialCourses.OUTRO)
2073 continue;
2074
2075 if (!IsCourseAvailable(taskId.ToInt()))
2076 continue;
2077
2078 if (hide)
2079 task.SetTaskVisibility(SCR_ETaskVisibility.NONE);
2080 else
2081 task.SetTaskVisibility(SCR_ETaskVisibility.EVERYONE);
2082 }
2083 }
2084
2085 //------------------------------------------------------------------------------------------------
2086 protected void GenerateTasks()
2087 {
2088 array <ref SCR_TutorialCourse> courses = {};
2089 m_CoursesConfig.GetConfigs(courses);
2090
2091 int courseType;
2092 SCR_Task task;
2093 string taskName;
2094
2095 foreach (SCR_TutorialCourse course : courses)
2096 {
2097 if (!course)
2098 continue;
2099
2100 courseType = course.GetCourseType();
2101
2102 if (course.CanCreateTask())
2103 CreateCourseTask(courseType);
2104
2105 if (SCR_Enum.HasFlag(m_eFinishedCourses, courseType))
2106 {
2107 task = SCR_TaskSystem.GetTaskFromTaskID(courseType.ToString());
2108 if (!task)
2109 continue;
2110
2111 taskName = task.GetTaskName();
2112 if (!taskName.Contains(TASK_COMPLETED_SUFFIX))
2113 task.SetTaskName(taskName + " " + TASK_COMPLETED_SUFFIX);
2114 }
2115 }
2116 }
2117
2118 //------------------------------------------------------------------------------------------------
2119 protected void CheckAreaRestrictions()
2120 {
2121 //TODO> Mouthful. Circumisse
2122 if (!m_ActiveConfig || m_ActiveConfig.GetCourseType() == SCR_ETutorialCourses.FREE_ROAM || !m_Player || m_bCourseBreaking)
2123 return;
2124
2125 SCR_TutorialStageInfo stageInfo = m_Stage.GetStageInfo();
2126 if (!stageInfo)
2127 return;
2128
2129 string areaRestrictionEntName = stageInfo.GetAreaRestrictionEntityOverride();
2130 if (SCR_StringHelper.IsEmptyOrWhiteSpace(areaRestrictionEntName))
2131 areaRestrictionEntName = m_ActiveConfig.GetCourseAreaCenterEntityName();
2132
2133 if (SCR_StringHelper.IsEmptyOrWhiteSpace(areaRestrictionEntName))
2134 return;
2135
2136 m_AreaRestrictionCenter = GetGame().GetWorld().FindEntityByName(areaRestrictionEntName);
2138 {
2139 m_bProtectionWarning = false;
2140 return;
2141 }
2142
2143 float warningDist = stageInfo.GetAreaRestrictionWarningOverride();
2144 if (warningDist == -1)
2145 warningDist = m_ActiveConfig.GetWarningDistance();
2146
2147 float breakDist = stageInfo.GetAreaRestrictionBreakingOverride();
2148 if (breakDist == -1)
2149 breakDist = m_ActiveConfig.GetCourseBreakDistance();
2150
2151 if (warningDist == -1 || breakDist == -1)
2152 return;
2153
2154 vector playerPos = m_Player.GetOrigin();
2155 if (vector.DistanceSq(playerPos, m_AreaRestrictionCenter.GetOrigin()) > (Math.Pow(warningDist, 2)))
2156 {
2157 if (vector.DistanceSq(playerPos, m_AreaRestrictionCenter.GetOrigin()) > (Math.Pow(breakDist, 2)))
2158 {
2159 m_bProtectionWarning = false;
2160 if (m_ActiveConfig.GetCourseType() == SCR_ETutorialCourses.INTRO)
2161 {
2164 return;
2165 }
2166
2168
2169 ChimeraWorld world = GetGame().GetWorld();
2170
2171 if (world)
2172 world.GetMusicManager().Play("SOUND_LEAVING_COURSE");
2173 }
2174 else if (!m_bProtectionWarning)
2175 {
2176 m_bProtectionWarning = true;
2177
2178 SCR_HintUIInfo hintInfo = SCR_HintUIInfo.CreateInfo("#AR-Tutorial_Hint_LeavingCourseArea", "#AR-Tutorial_Hint_Warning", 20, EHint.UNDEFINED, EFieldManualEntryId.NONE, true);
2179 if (hintInfo)
2180 SCR_HintManagerComponent.ShowHint(hintInfo);
2181 }
2182 }
2183 else if (m_bProtectionWarning)
2184 {
2185 SCR_HintManagerComponent.HideHint();
2186 SCR_HintManagerComponent.ClearLatestHint();
2187
2188 if (m_Stage)
2189 {
2190 SCR_HintUIInfo hintInfo = m_Stage.GetStageInfo().GetHint();
2191 if (hintInfo)
2192 SCR_HintManagerComponent.ShowHint(hintInfo);
2193 }
2194
2195 m_bProtectionWarning = false;
2196 }
2197 }
2198
2199 //------------------------------------------------------------------------------------------------
2200 protected void SetSoundFade(bool fadeOut, float duration = 0)
2201 {
2202 if (duration == 0)
2203 {
2204 AudioSystem.SetMasterVolume(AudioSystem.SFX, !fadeOut);
2205 AudioSystem.SetMasterVolume(AudioSystem.Dialog, !fadeOut);
2206
2208 m_bApplySoundFade = false;
2209 }
2210 else
2211 {
2212 m_fSoundInterpolationSpeed = 1 / duration;
2213
2214 if (fadeOut)
2216
2217 m_bApplySoundFade = true;
2218 }
2219 }
2220
2221 //------------------------------------------------------------------------------------------------
2222 protected void HandleSoundFade(float timeSlice)
2223 {
2224 if (!m_bApplySoundFade)
2225 return;
2226
2228
2229 m_fSoundVolume = Math.Clamp(m_fSoundVolume, 0, 1);
2230
2231 AudioSystem.SetMasterVolume(AudioSystem.SFX, m_fSoundVolume);
2232 AudioSystem.SetMasterVolume(AudioSystem.Dialog, m_fSoundVolume);
2233
2234 if (m_fSoundVolume == 1 || m_fSoundVolume == 0)
2235 m_bApplySoundFade = false;
2236 }
2237
2238 //------------------------------------------------------------------------------------------------
2239 protected override void EOnFrame(IEntity owner, float timeSlice)
2240 {
2241 //TODO: Optimize
2243
2244 HandleSoundFade(timeSlice);
2245
2246 if (m_aGarbage)
2247 HandleGarbage();
2248 }
2249
2250 //------------------------------------------------------------------------------------------------
2251 protected override void OnPostInit(IEntity owner)
2252 {
2253#ifdef ENABLE_DIAG
2254 // Cheat menu
2255 DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_MENU, "Tutorial", "");
2256 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DISABLE_COURSE_REQUIREMENTS, "", "Disable course reqs ", "Tutorial");
2257 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_SKIP_INTRO, "", "Skip intro sequence", "Tutorial");
2258 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_REGENERATE_TASKS, "", "Regenerate course tasks", "Tutorial");
2259 DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATIONS, "Course locations", "Tutorial");
2260 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_SKIP_AI_DRIVING, "", "Skip AI Driving", "Tutorial");
2261 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_FINISH_STAGE, "", "Finish current stage", "Tutorial");
2262 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_MOVE_TO_WP, "", "Move to waypoint", "Tutorial");
2263 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_SET_EVENING_TIME, "", "Set evening time", "Tutorial");
2264 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DUMP_STAGES_INTO_LOG, "", "Dump stages into log", "Tutorial");
2265 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_FINISH_EVERYTHING, "", "Finish all courses", "Tutorial");
2266 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DRAW_AREA_RESTRICTIONS, "", "Draw Area Restrictions", "Tutorial");
2267
2268 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_OBSTACLE, "", "OBSTACLE COURSE", "Course locations");
2269 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRING, "", "FIRING RANGE", "Course locations");
2270 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_ENGINEERING, "", "COMBAT ENGINEERING", "Course locations");
2271 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SEIZING, "", "SEIZING", "Course locations");
2272 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_AID, "", "FIRST AID", "Course locations");
2273 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_DRIVING, "", "DRIVING", "Course locations");
2274 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_NAVIGATION, "", "NAVIGATION", "Course locations");
2275 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_HELICOPTERS, "", "HELICOPTER PILOTING", "Course locations");
2276 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SPECIAL, "", "SPECIAL WEAPONS", "Course locations");
2277 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LONGRANGE, "", "LONG-DISTANCE SHOOTING", "Course locations");
2278 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRESUPPORT, "", "FIRE SUPPORT COURSE", "Course locations");
2279 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LEADERSHIP, "", "SQUAD LEADERSHIP", "Course locations");
2280 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_MAINTENANCE, "", "VEHICLE MAINTENANCE", "Course locations");
2281
2282 ConnectToDiagSystem(owner);
2283#endif
2284 if (!GetGame().InPlayMode())
2285 return;
2286
2288 if (!m_CoursesConfig)
2289 return;
2290
2291 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
2292 SetEventMask(owner, EntityEvent.FRAME);
2293
2295
2296 ScriptInvoker onVehicleDamageStateChanged = SCR_VehicleDamageManagerComponent.GetOnVehicleDamageStateChanged();
2297 if (onVehicleDamageStateChanged)
2298 onVehicleDamageStateChanged.Insert(OnVehicleDamaged);
2299
2301 if (core)
2302 core.Event_OnEditorManagerCreatedServer.Insert(SetupEditorModeListener);
2303
2305 if (gameMode)
2306 gameMode.PauseGame(false);
2307 }
2308
2309 //------------------------------------------------------------------------------------------------
2310 protected void LoadCoursesConfig()
2311 {
2312 Resource holder = BaseContainerTools.LoadContainer(m_sCoursesConfigResourceName);
2313 if (!holder)
2314 return;
2315
2316 BaseContainer container = holder.GetResource().ToBaseContainer();
2317 if (!container)
2318 return;
2319
2320 m_CoursesConfig = SCR_TutorialCoursesConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container));
2321 }
2322
2323#ifdef ENABLE_DIAG
2324 //------------------------------------------------------------------------------------------------
2325 void DrawAreaRestrictions()
2326 {
2328 return;
2329
2330 SCR_TutorialStageInfo stageInfo = m_Stage.GetStageInfo();
2331 float warningDist = stageInfo.GetAreaRestrictionWarningOverride();
2332 if (warningDist == -1)
2333 warningDist = m_ActiveConfig.GetWarningDistance();
2334
2335 Shape.CreateSphere(Color.YELLOW, ShapeFlags.ONCE | ShapeFlags.NOZWRITE | ShapeFlags.WIREFRAME, m_AreaRestrictionCenter.GetOrigin(), warningDist);
2336
2337 float breakDist = stageInfo.GetAreaRestrictionBreakingOverride();
2338 if (breakDist == -1)
2340
2341 Shape.CreateSphere(Color.RED, ShapeFlags.ONCE | ShapeFlags.NOZWRITE | ShapeFlags.WIREFRAME, m_AreaRestrictionCenter.GetOrigin(), breakDist);
2342 }
2343
2344 //------------------------------------------------------------------------------------------------
2345 void SkipAIDrive()
2346 {
2347 Vehicle jeep = Vehicle.Cast(GetGame().GetWorld().FindEntityByName("COMMANDING_JEEP"));
2348 if (!jeep)
2349 return;
2350
2351 IEntity newPos = GetGame().GetWorld().FindEntityByName("COMMANDING_CROSSROAD_STOP");
2352 if (!newPos)
2353 return;
2354
2355 vector transformation[4];
2356 newPos.GetTransform(transformation);
2357 jeep.SetTransform(transformation);
2358
2359 if (!jeep.GetPilot())
2361 }
2362
2363 //------------------------------------------------------------------------------------------------
2364 void TeleportToInstructor(SCR_ETutorialCourses course)
2365 {
2366 IEntity instructorEnt;
2367 foreach (SCR_TutorialInstructorComponent instructor : m_aInstructors)
2368 {
2369 if (!instructor || instructor.GetCourseType() != course)
2370 continue;
2371
2372 instructorEnt = instructor.GetOwner();
2373 }
2374
2375 if (!instructorEnt || !m_Player)
2376 return;
2377
2378 m_Player.SetOrigin(instructorEnt.GetOrigin());
2379 }
2380
2381 //------------------------------------------------------------------------------------------------
2382 void SetCourseCompleted(SCR_ETutorialCourses course)
2383 {
2384 m_eFinishedCourses = SCR_Enum.SetFlag(m_eFinishedCourses, course);
2385 GenerateTasks();
2386 }
2387
2388 //------------------------------------------------------------------------------------------------
2389 override void EOnDiag(IEntity owner, float timeSlice)
2390 {
2391 super.EOnDiag(owner, timeSlice);
2392
2393 // Cheat menu
2394 m_bIgnoreCourseRequirements = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DISABLE_COURSE_REQUIREMENTS);
2395 m_bSkipIntro = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_SKIP_INTRO);
2396
2397 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DUMP_STAGES_INTO_LOG))
2398 {
2399 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DUMP_STAGES_INTO_LOG, 0);
2400
2401 Print("***STAGE LIST***");
2402 foreach (int i, SCR_TutorialStageInfo stageInfo : m_aStageInfos)
2403 {
2404 if (i == GetActiveStageIndex())
2405 PrintFormat(">> %1 - %2 - %3", i, stageInfo.GetClassName(), stageInfo.GetStageName());
2406 else
2407 PrintFormat("|| %1 - %2 - %3", i, stageInfo.GetClassName(), stageInfo.GetStageName());
2408 }
2409 Print("***-***");
2410 }
2411
2412 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_REGENERATE_TASKS))
2413 {
2414 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_REGENERATE_TASKS, 0);
2415 HideTasks(false);
2416 }
2417
2418 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_FINISH_STAGE))
2419 {
2420 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_FINISH_STAGE, 0);
2422 }
2423
2424 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_MOVE_TO_WP))
2425 {
2426 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_MOVE_TO_WP, 0);
2427
2428 if (!m_Stage)
2429 return;
2430
2431 SCR_Waypoint wp = m_Stage.GetWaypoint();
2432 if (wp)
2433 {
2434 m_Player.SetOrigin(wp.GetPosition());
2435 }
2436 }
2437
2438 // COURSE TELEPORTS
2439 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_OBSTACLE))
2440 {
2441 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_OBSTACLE, 0);
2442 TeleportToInstructor(SCR_ETutorialCourses.OBSTACLE_COURSE);
2443 }
2444
2445 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRING))
2446 {
2447 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRING, 0);
2448 TeleportToInstructor(SCR_ETutorialCourses.SHOOTING_RANGE);
2449 }
2450
2451 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_ENGINEERING))
2452 {
2453 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_ENGINEERING, 0);
2454 TeleportToInstructor(SCR_ETutorialCourses.COMBAT_ENGINEERING);
2455 }
2456
2457 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SEIZING))
2458 {
2459 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SEIZING, 0);
2460 TeleportToInstructor(SCR_ETutorialCourses.CONFLICT);
2461 }
2462
2463 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_AID))
2464 {
2465 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_AID, 0);
2466 TeleportToInstructor(SCR_ETutorialCourses.FIRST_AID);
2467 }
2468
2469 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_DRIVING))
2470 {
2471 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_DRIVING, 0);
2472 TeleportToInstructor(SCR_ETutorialCourses.DRIVING);
2473 }
2474
2475 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_NAVIGATION))
2476 {
2477 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_NAVIGATION, 0);
2478 TeleportToInstructor(SCR_ETutorialCourses.NAVIGATION);
2479 }
2480
2481 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_HELICOPTERS))
2482 {
2483 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_HELICOPTERS, 0);
2484 TeleportToInstructor(SCR_ETutorialCourses.HELICOPTERS);
2485 }
2486
2487 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SPECIAL))
2488 {
2489 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_SPECIAL, 0);
2490 TeleportToInstructor(SCR_ETutorialCourses.SPECIAL_WEAPONS);
2491 }
2492
2493 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LONGRANGE))
2494 {
2495 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LONGRANGE, 0);
2496 TeleportToInstructor(SCR_ETutorialCourses.LONG_RANGE_SHOOTING);
2497 }
2498
2499 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRESUPPORT))
2500 {
2501 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_FIRESUPPORT, 0);
2502 TeleportToInstructor(SCR_ETutorialCourses.FIRE_SUPPORT);
2503 }
2504
2505 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LEADERSHIP))
2506 {
2507 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_LEADERSHIP, 0);
2508 TeleportToInstructor(SCR_ETutorialCourses.SQUAD_LEADERSHIP);
2509 }
2510
2511 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_MAINTENANCE))
2512 {
2513 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_LOCATION_MAINTENANCE, 0);
2514 TeleportToInstructor(SCR_ETutorialCourses.VEHICLE_MAINTENANCE);
2515 }
2516
2517 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_SKIP_AI_DRIVING))
2518 {
2519 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_COURSE_SKIP_AI_DRIVING, 0);
2520 SkipAIDrive();
2521 }
2522
2523 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_FINISH_EVERYTHING))
2524 {
2525 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_FINISH_EVERYTHING, 0);
2526
2527 array <int> courses = {};
2528 SCR_Enum.GetEnumValues(SCR_ETutorialCourses, courses);
2529
2530 foreach (int course : courses)
2531 {
2532 if (course == SCR_ETutorialCourses.OUTRO)
2533 continue;
2534
2535 SetCourseCompleted(course);
2536 }
2537
2538 if (!m_bStagesComplete)
2539 {
2540 m_bStagesComplete = true;
2542 }
2543
2545 }
2546
2547 m_bDrawAreaRestrictions = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_NEWTUTORIAL_DRAW_AREA_RESTRICTIONS);
2548 if (m_bDrawAreaRestrictions)
2549 DrawAreaRestrictions();
2550 }
2551#endif
2552
2553 //------------------------------------------------------------------------------------------------
2554 override void OnDelete(IEntity owner)
2555 {
2556 super.OnDelete(owner);
2557 DisconnectFromDiagSystem(owner);
2558
2559 SetSoundFade(false);
2560 }
2561
2562 //------------------------------------------------------------------------------------------------
2563 // destructor
2565 {
2567 m_wPunishmentScreen.RemoveFromHierarchy();
2568
2569 if (m_wFadeOut)
2570 m_wFadeOut.RemoveFromHierarchy();
2571
2572 ScriptInvoker onVehicleDamageStateChanged = SCR_VehicleDamageManagerComponent.GetOnVehicleDamageStateChanged();
2573 if (onVehicleDamageStateChanged)
2574 onVehicleDamageStateChanged.Remove(OnVehicleDamaged);
2575
2576 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
2577
2578 if (m_fSavedViewDistance != 0)
2579 GetGame().SetViewDistance(m_fSavedViewDistance);
2580 }
2581}
ECharacterCommandIDs
ChimeraMenuPreset
Menu presets.
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ECompartmentType
EFieldManualEntryId
used to grab the first id-matching Field Manual entry
EHint
Definition EHint.c:11
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override void OnGameModeStart()
ChimeraCharacter m_Player
void OnEditorClosed()
Method called when character has a shovel in hands and any editor mode is closed.
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
ScriptInvoker GetOnEntitySpawned()
IEntity SpawnEntity(ResourceName entityResourceName, notnull IEntity slotOwner)
ref ScriptInvoker m_OnEntitySpawned
void SCR_CommandingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void OnInputDeviceIsGamepad(bool isGamepad)
float distance
EDamageType type
vector position
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_ETutorialBreakType
SCR_ETutorialCourses
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Get all prefabs that have the spawner data
void SCR_FactionManager(IEntitySource src, IEntity parent)
void FastTravel()
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
void OnControllableDestroyed(IEntity entity, IEntity killerEntity, Instigator instigator, notnull SCR_InstigatorContextData instigatorContextData)
SCR_MapGadgetComponentClass m_bIsMapOpen
Map gadget component.
override void EOnFrame(IEntity owner, float timeSlice)
SCR_PositionClass GenericEntityClass SCR_Position(IEntitySource src, IEntity parent)
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
IEntity SpawnAsset()
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
SCR_ETaskVisibility
Definition SCR_Task.c:24
void SCR_Task(IEntitySource src, IEntity parent)
Definition SCR_Task.c:1938
ChimeraCharacter GetPlayer()
int GetFreeRoamActivations()
void DespawnCourseAssets()
SCR_TutorialCourse m_ActiveConfig
SCR_InventoryStorageManagerComponent GetPlayerInventory()
void ChangeVehicleLockState(notnull IEntity vehicle, bool lock)
void ShowMapDescriptor(string descriptorOwnerName, bool enable)
ResourceName m_sPlayerVehicleResourceName
ImageWidget m_wFadeOut
float GetTimeElapsed()
ref array< IEntity > m_aGarbage
void OnModeAdded(SCR_EditorModeEntity modeEntity)
void OnObjectDestroyed(EDamageState state)
void SetCourseConfig(SCR_ETutorialCourses config, string stageName=string.Empty, bool spawnAssets=true)
void SpawnPlayer(string spawnPositionName)
ref array< SCR_TutorialInstructorComponent > m_aInstructors
SCR_BaseTutorialStage GetCurrentStage()
void RegisterInstructor(notnull SCR_TutorialInstructorComponent instructor)
float GetSavedViewDistance()
SCR_PlacingEditorComponent m_PlacingComponent
void OnCharacterDamaged(BaseDamageContext damageContext)
bool GetWas3rdPersonViewUsed()
ref ScriptInvoker m_OnFastTravelDone
const string TASK_COMPLETED_SUFFIX
void EnableControls(bool enable)
void InsertIntoGarbage(string entityName)
SCR_TutorialCourse GetActiveConfig()
void UnregisterInstructor(notnull SCR_TutorialInstructorComponent instructor)
WidgetAnimationOpacity GetOngoingFadeAnimation()
SCR_ETutorialCourses m_eFinishedCourses
void CreateCourseTask(SCR_ETutorialCourses courseType)
void EnableArsenal(string entityName, bool enable)
void OnEntitySpawned(int prefabID, SCR_EditableEntityComponent ent)
void CheckAreaRestrictions()
void RequestBreakCourse(SCR_ETutorialBreakType breakType)
bool IsDamagedOrDestroyed(notnull IEntity ent)
void Check3rdPersonViewUsed()
void GetInstructors(notnull array< SCR_TutorialInstructorComponent > instructors)
float m_fSavedViewDistance
void PlayNarrativeCharacterStageDelayed(string characterName, int stage)
void SetFreeRoamActivation(int activations)
void HideTasks(bool hide)
ScriptInvoker GetOnPlayerSpawned()
SCR_BaseTutorialStage m_Stage
void OnStructureBuilt(SCR_CampaignMilitaryBaseComponent base, IEntity structure)
Widget m_wPunishmentScreen
void OnFastTravelPreloadFinished()
int GetAmmoCountForWeapon(IEntity weapon)
void HandleSoundFade(float timeSlice)
void BlockBuildingModeAccess(notnull IEntity providerEntity, bool block)
float m_fSoundInterpolationSpeed
void OnInputDeviceChangedDelayed()
void ~SCR_TutorialGamemodeComponent()
void DelayedPopup(string text="", string subtitle="", float duration=SCR_PopUpNotification.DEFAULT_DURATION, string param1="", string param2="", string subtitleParam1="", string subtitleParam2="")
ref array< SCR_VehicleDamageManagerComponent > m_aDamagedVehicles
ref array< ref SCR_MapMarkerBase > m_aMarkers
bool m_fDelayedControlSchemeChangeRunning
void IncrementFreeRoamActivation()
IEntity m_FastTravelPosition
void InsertStage(string stageName, int position=-1)
IEntity m_AreaRestrictionCenter
SCR_PlacingEditorComponent GetPlacingComponent()
const int PUNISHMENT_TIMEOUT
void MoveCharacterIntoVehicle(notnull ChimeraCharacter character, notnull Vehicle vehicle, ECompartmentType compartmentType, int compartmentIndex=0)
const int GARBAGE_DESPAWN_DISTANCE_SQ
void EnableRefunding(IEntity ent, bool enable)
SCR_PreviewEntityEditorComponent GetPreviewEntityComponent()
void HandleRespawnBreak()
void OnVehicleDamaged(SCR_VehicleDamageManagerComponent damageManager)
ref array< ref SCR_TutorialStageInfo > m_aStageInfos
void RemoveFromGarbage(IEntity ent)
bool IsPlayerAimingInAngle(float angle, int tolerance)
void SetSoundFade(bool fadeOut, float duration=0)
void FastTravelToCourse(SCR_ETutorialCourses course)
bool IsCourseBreaking()
bool CheckCharacterStance(ECharacterCommandIDs command)
SCR_ETutorialBreakType m_iBreakType
const string FADEOUT_LAYOUT
SCR_ETutorialCourses GetFinishedCourses()
SCR_TutorialCoursesConfig GetCoursesConfig()
ref ScriptInvoker m_OnPlayerSpawned
SCR_WaypointDisplay GetWaypointDisplay()
WidgetAnimationOpacity Fadeout(bool fadeOut, float duration=1, float soundDuration=duration)
void OnFastTravelFadeoutCompleted()
void RegisterMarker(notnull SCR_MapMarkerBase marker)
void SpawnCourseAssets(SCR_ETutorialCourses courseType=-1)
SCR_TutorialInstructorComponent GetCourseInstructor(SCR_ETutorialCourses course)
ScriptInvoker GetOnFastTravelDone()
void LoadProgress(SCR_ETutorialCourses completedCourses)
void SetupEditorModeListener()
IEntity FindPrefabInPlayerInventory(ResourceName prefabName)
void SaveViewDistance(float distance)
ref array< SCR_NarrativeComponent > m_aNarratedCharacters
WidgetAnimationOpacity m_OngoingFadeAnimation
void SetStage(string stageName)
void PlayBedAnimation(bool fast)
int GetStageIndexByName(string name)
void RemovePlayerMapMarkers()
SCR_VoiceoverSystem m_VoiceoverSystem
void SetupTargets(string parentTargetName, out array< SCR_FiringRangeTarget > targets=null, ETargetState setupState=-1, bool setupAutoReset=true)
SCR_WaypointDisplay m_WaypointDisplay
Widget CreateWarningOverlay(bool killedNPC)
SCR_Task GetCourseTask(SCR_ETutorialCourses course)
void HandlePlayerGroup()
void RepairWorldVehicles()
void HandleGarbage(bool force=false)
bool m_bProtectionWarning
bool IsCourseAvailable(SCR_ETutorialCourses courseType)
bool IsEntityInPlayerInventory(string entityName)
ref SCR_TutorialCoursesConfig m_CoursesConfig
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum EVehicleType IEntity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external Managed FindComponent(typename typeName)
proto external void SetOrigin(vector orig)
proto external vector GetAngles()
Same as GetYawPitchRoll(), but returns rotation vector around X, Y and Z axis.
proto external vector GetOrigin()
proto external Physics GetPhysics()
proto external IEntity GetChildren()
proto external BaseWorld GetWorld()
proto external void SetName(string name)
proto external void GetTransform(out vector mat[])
proto external EntityPrefabData GetPrefabData()
proto external IEntity GetParent()
proto external string GetName()
proto external IEntity GetSibling()
Definition Math.c:13
proto external MenuBase FindMenuByPreset(ScriptMenuPresetEnum preset)
Finds first menu/dialog with given preset index, or nullptr when there is no such menu opened.
proto external bool CloseMenu(MenuBase menu)
Put menu into queue for closing (which is processed during next MenuManeger update).
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void OnControllableEntitySpawned(IEntity controlledEntity, notnull SCR_GadgetManagerComponent gadgetManager)
int GetGroupID()
static SCR_ArsenalComponent FindArsenalComponent(notnull IEntity entity, bool getFromSlotted=true)
void SetArsenalEnabled(bool enable, bool isOverwrite=true)
bool PauseGame(bool pause, SCR_EPauseReason reason=SCR_EPauseReason.SYSTEM)
OnPreloadFinishedInvoker GetOnPreloadFinished()
void StartSpawnPreload(vector position)
SCR_Waypoint GetWaypoint(int index=0)
SCR_TutorialStageInfo GetStageInfo()
void StartLoitering(IEntity loiterEntity, int loiteringType, bool holsterWeapon, bool allowRootMotion, bool alignToPosition, vector targetPosition[4]={ "1 0 0", "0 1 0", "0 0 1", "0 0 0" }, bool disableInput=false, SCR_LoiterCustomAnimData customAnimData=SCR_LoiterCustomAnimData.Default)
override void FullHeal(bool ignoreHealingDOT=true)
bool IsBleeding()
the official and globally used way of checking if bleeding tests for any PERSISTENT damage effects of...
array< IEntity > GetQuickSlotEntitiesOnly()
gets all entities in quickslots, and nulls in arrays for non-entity or empty slots
Core component to manage SCR_EditorManagerEntity.
SCR_EditorManagerEntity GetEditorManager()
SCR_InfoDisplay FindInfoDisplay(typename type)
Return hud component of given type.
static SCR_HUDManagerComponent GetHUDManager()
Widget CreateLayout(ResourceName path, EHudLayers layer, int zOrder=0)
static SCR_HintUIInfo CreateInfo(string description, string name, float duration, EHint type, EFieldManualEntryId fieldManualEntry, bool isTimerVisible)
void CloseMap()
Close the map.
bool RequestLoadout(SCR_BasePlayerLoadout loadout)
Takes care of dynamic and static onscreen popups.
void PopupMsg(string text, float duration=DEFAULT_DURATION, string text2="", int prio=-1, string param1="", string param2="", string param3="", string param4="", string text2param1="", string text2param2="", string text2param3="", string text2param4="", string sound="", SCR_EPopupMsgFilter category=SCR_EPopupMsgFilter.ALL, WorldTimestamp progressStart=null, WorldTimestamp progressEnd=null)
static const float DEFAULT_DURATION
static SCR_PopUpNotification GetInstance()
static bool IsEmptyOrWhiteSpace(string input)
SCR_ETutorialCourses GetCourseType()
int GetPrefabs(out notnull array< SCR_TutorialCoursePrefabInfo > outArray)
SCR_ETutorialCourses GetRequiredCourses()
static void SetLingerDuration(float duration)
How long should subtitles stay visible after the sound ended (seconds).
static SCR_VoiceoverSystem GetInstance()
vector GetPosition()
Get waypoint position. Attached entity is prioritized over static position.
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
void EntitySpawnParams()
Definition gameLib.c:130
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnDiag(IEntity owner, float timeSlice)
SCR_EditableEntityComponent GetControlledEntity()
AchievementId
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
ShapeFlags
Definition ShapeFlags.c:13
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
EEditorCanOpen
Layers allowing editor to be opened. All of them have to be activated (certain exceptions may apply w...
EntityEvent
Various entity events.
Definition EntityEvent.c:14
override void OnPlayerRegistered(int playerId)
proto external PlayerController GetPlayerController()
EDamageType
Definition EDamageType.c:13
EDamageState
EStoragePurpose
ESaveGameType
T2 param2
Definition tuple.c:92
Tuple param1
ECloseDoorAfterActions
EGetOutType
Definition EGetOutType.c:13
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134