Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HealthEditorAttribute.c
Go to the documentation of this file.
1 
6 {
7  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
8  {
9  //~ With the new health system health can no longer be set with just a slider.
10  //~ Todo: Create health system for individual parts that can be damaged
11  return null;
12 
13  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
14  if (!editableEntity)
15  return null;
16 
17  if (!IsValidEntityType(editableEntity.GetEntityType()))
18  return null;
19 
20  IEntity owner = editableEntity.GetOwner();
21  if (!owner)
22  return null;
23 
24  DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
25  if (!damageComponent)
26  return null;
27 
28  if (damageComponent.GetState() == EDamageState.DESTROYED)
29  return null;
30 
31  return SCR_BaseEditorAttributeVar.CreateFloat(Math.Round(damageComponent.GetHealthScaled() * 100));
32  }
33  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
34  {
35  if (!var)
36  return;
37  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
38 
39  IEntity owner = editableEntity.GetOwner();
40  if (!owner)
41  return;
42 
43  DamageManagerComponent damageComponent = DamageManagerComponent.Cast(owner.FindComponent(DamageManagerComponent));
44  if (!damageComponent)
45  return;
46 
47  if (!damageComponent.IsDamageHandlingEnabled())
48  return;
49 
50  float health = (var.GetFloat() / 100);
51 
52  HitZone defaultHitzone = damageComponent.GetDefaultHitZone();
53 
54  defaultHitzone.SetHealthScaled(health);
55  }
56 };
HitZone
Definition: HitZone.c:12
SCR_ValidTypeBaseValueListEditorAttribute
Definition: SCR_ValidTypeBaseValueListEditorAttribute.c:2
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_HealthEditorAttribute
Definition: SCR_HealthEditorAttribute.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
DamageManagerComponent
Definition: DamageManagerComponent.c:12
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