Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 = CharacterControllerComponent.Cast(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.CreateInstigator(null));
71  }
72  }
73 };
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
Instigator
Definition: Instigator.c:6
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
ENotification
ENotification
Definition: ENotification.c:4
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_CharacterRegistrationComponent
void SCR_CharacterRegistrationComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_CharacterRegistrationComponent.c:48
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_GlobalUnconsciousnessEditorAttribute
Definition: SCR_GlobalUnconsciousnessEditorAttribute.c:2