Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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.")]
6
7class 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 //------------------------------------------------------------------------------------------------
92 int GetRepairCost()
93 {
94 return m_iRepairCost;
95 }
96
97 //------------------------------------------------------------------------------------------------
100 void SetHitEvaluation(bool canEvaluate)
101 {
102 m_bCanEvaluateHit = canEvaluate;
103 }
104}
RplComponent m_RplComponent
int m_iRepairCost
Cost of repair.
SCR_DestructionMultiPhaseComponent m_DestMultiComp
SCR_CampaignServiceCompositionComponent m_ServiceCompositionComp
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
enum EVehicleType IEntity
proto external int ClearEventMask(notnull IEntity owner, int mask)
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external Managed FindComponent(typename typeName)
void EOnInit(IEntity owner)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14