Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignServiceEntityComponent.c
Go to the documentation of this file.
1 #define ENABLE_BASE_DESTRUCTION
2 [EntityEditorProps(category: "GameScripted/Campaign", description: "This component handles a destruction of entity in composition and how it affects composition operability.")]
3 class SCR_CampaignServiceEntityComponentClass : ScriptComponentClass
4 {
5 }
6 
7 class SCR_CampaignServiceEntityComponent : ScriptComponent
8 {
10  [Attribute("50", UIWidgets.Slider, "How much of service operability this entity represents", "0 100 1")]
11  protected int m_iEntityOperabilityPart;
12 
14  [Attribute("50", UIWidgets.Slider, "Cost of repair", "0 1000 1")]
15  protected int m_iRepairCost;
16 
17  protected SCR_CampaignServiceCompositionComponent m_ServiceCompositionComp;
18  protected SCR_DestructionMultiPhaseComponent m_DestMultiComp;
19  protected bool m_bCanEvaluateHit = true;
20  protected RplComponent m_RplComponent;
21  private static const int INITIAL_STATE = 0;
22 
23  //------------------------------------------------------------------------------------------------
24  override void OnPostInit(IEntity owner)
25  {
26  SetEventMask(owner, EntityEvent.INIT);
27  }
28 
29  //------------------------------------------------------------------------------------------------
30  override void EOnInit(IEntity owner)
31  {
32  m_DestMultiComp = SCR_DestructionMultiPhaseComponent.Cast(owner.FindComponent(SCR_DestructionMultiPhaseComponent));
33  if (!m_DestMultiComp)
34  return;
35 #ifdef ENABLE_BASE_DESTRUCTION
36  m_DestMultiComp.GetOnDamageInvoker().Insert(EvaluateHit);
37 #endif
38 
39  IEntity parentComp = SCR_EntityHelper.GetMainParent(owner);
40  if (!parentComp)
41  return;
42 
43  m_ServiceCompositionComp = SCR_CampaignServiceCompositionComponent.Cast(parentComp.FindComponent(SCR_CampaignServiceCompositionComponent));
44  m_RplComponent = RplComponent.Cast(parentComp.FindComponent(RplComponent));
45  ClearEventMask(owner, EntityEvent.INIT);
46  }
47 
48  //------------------------------------------------------------------------------------------------
50  void EvaluateHit()
51  {
52  if (IsProxy())
53  return;
54 
56  return;
57 
58 #ifdef ENABLE_BASE_DESTRUCTION
59  if (m_DestMultiComp.GetDestroyed())
60  {
61  SetHitEvaluation(false);
62  m_ServiceCompositionComp.ChangeOperability(m_iEntityOperabilityPart);
63  m_DestMultiComp.ReplicateDestructibleState();
64  }
65 #endif
66  }
67 
68 #ifdef ENABLE_BASE_DESTRUCTION
69  //------------------------------------------------------------------------------------------------
71  void RepairEntity()
72  {
74  return;
75 
76  m_DestMultiComp.GoToDamagePhase(INITIAL_STATE, false);
77  m_DestMultiComp.ReplicateDestructibleState(true);
78  m_ServiceCompositionComp.ChangeOperability(-m_iEntityOperabilityPart);
79  SetHitEvaluation(true);
80  }
81 #endif
82 
83  //------------------------------------------------------------------------------------------------
85  bool IsProxy()
86  {
87  return (m_RplComponent && m_RplComponent.IsProxy());
88  }
89 
90  //------------------------------------------------------------------------------------------------
93  {
94  return m_iRepairCost;
95  }
96 
97  //------------------------------------------------------------------------------------------------
100  void SetHitEvaluation(bool canEvaluate)
101  {
102  m_bCanEvaluateHit = canEvaluate;
103  }
104 }
m_iRepairCost
protected int m_iRepairCost
Cost of repair.
Definition: SCR_CampaignServiceEntityComponent.c:15
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
SetHitEvaluation
void SetHitEvaluation(bool canEvaluate)
Definition: SCR_CampaignServiceEntityComponent.c:100
RepairEntity
void RepairEntity()
Repair entity (called on Server)
Definition: SCR_CampaignServiceEntityComponent.c:71
GetRepairCost
int GetRepairCost()
Definition: SCR_CampaignServiceEntityComponent.c:92
m_ServiceCompositionComp
protected SCR_CampaignServiceCompositionComponent m_ServiceCompositionComp
Definition: SCR_CampaignServiceEntityComponent.c:17
EvaluateHit
void EvaluateHit()
Definition: SCR_CampaignServiceEntityComponent.c:50
m_DestMultiComp
protected SCR_DestructionMultiPhaseComponent m_DestMultiComp
Definition: SCR_CampaignServiceEntityComponent.c:18
Attribute
SCR_CampaignServiceEntityComponentClass ScriptComponentClass Attribute("50", UIWidgets.Slider, "How much of service operability this entity represents", "0 100 1")] protected int m_iEntityOperabilityPart
How much is the service operability reduced when this entity is destroyed.
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_CampaignServiceEntityComponent.c:24
m_bCanEvaluateHit
protected bool m_bCanEvaluateHit
Definition: SCR_CampaignServiceEntityComponent.c:19
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_CampaignServiceEntityComponent.c:30
SCR_CampaignServiceEntityComponentClass
Definition: SCR_CampaignServiceEntityComponent.c:3
m_RplComponent
protected RplComponent m_RplComponent
Definition: SCR_CampaignServiceEntityComponent.c:20
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
IsProxy
bool IsProxy()
Definition: SCR_CampaignServiceEntityComponent.c:85