Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GlobalUnconsciousnessEditorAttribute.c
Go to the documentation of this file.
3{
4 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
5 {
6 //If opened in global attributes
7 BaseGameMode gamemode = BaseGameMode.Cast(item);
8 if (!gamemode)
9 return null;
10
11 SCR_GameModeHealthSettings gameModeHealthSettings = SCR_GameModeHealthSettings.Cast(gamemode.FindComponent(SCR_GameModeHealthSettings));
12 if (!gameModeHealthSettings)
13 return null;
14
15 return SCR_BaseEditorAttributeVar.CreateBool(gameModeHealthSettings.IsUnconsciousnessPermitted());
16 }
17
18 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
19 {
20 if (!var)
21 return;
22
23 BaseGameMode gamemode = BaseGameMode.Cast(item);
24 if (!gamemode)
25 return;
26
27 SCR_GameModeHealthSettings gameModeHealthSettings = SCR_GameModeHealthSettings.Cast(gamemode.FindComponent(SCR_GameModeHealthSettings));
28 if (!gameModeHealthSettings)
29 return;
30
31 bool value = var.GetBool();
32
33 //Notification
34 if (item && value != gameModeHealthSettings.IsUnconsciousnessPermitted())
35 {
36 if (value)
37 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_UNCONSCIOUSNESS_ENABLED, playerID);
38 else
39 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_UNCONSCIOUSNESS_DISABLED, playerID);
40 }
41
42 gameModeHealthSettings.SetUnconsciousnessPermitted(value);
43
44 //Neutralize character if unconsciousness is disabled and character is already unconscious
45 if (value)
46 return;
47
48 array<SCR_ChimeraCharacter> characters = SCR_CharacterRegistrationComponent.GetChimeraCharacters();
49 if (!characters)
50 return;
51
52 foreach (SCR_ChimeraCharacter character: characters)
53 {
54 SCR_CharacterDamageManagerComponent characterDamageManager = SCR_CharacterDamageManagerComponent.Cast(character.GetDamageManager());
55 if (!characterDamageManager)
56 continue;
57
58 CharacterControllerComponent controller = character.GetCharacterController();
59 if (!controller)
60 continue;
61
62 ECharacterLifeState lifeState = controller.GetLifeState();
63 if (lifeState == ECharacterLifeState.DEAD)
64 continue;
65
66 if (!characterDamageManager.IsDamageHandlingEnabled())
67 continue;
68
69 if (lifeState == ECharacterLifeState.INCAPACITATED)
70 characterDamageManager.Kill(Instigator.CreateInstigatorGM());
71 }
72 }
73};
ENotification
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_CharacterRegistrationComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
static SCR_BaseEditorAttributeVar CreateBool(bool value)
ECharacterLifeState