Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_VehicleTrackDecalComponent.c
Go to the documentation of this file.
1// Spawns Track Decal
2
3[ComponentEditorProps(category: "GameScripted/Test", description:"SCR_VehicleTrackDecal")]
7
9{
10 [Attribute("", UIWidgets.ResourceNamePicker, desc: "Material for track decal", params: "emat")]
11 private ResourceName m_TrackMaterial;
12
13 [Attribute( "0.5", UIWidgets.EditBox, "Minimal lateral slip of wheel" )]
14 float m_fMinimalLateralSlip;
15
16 [Attribute( "0.5", UIWidgets.EditBox, "Minimal longitudinal slip of wheel" )]
17 float m_fMinimalLongitudinalSlip;
18
19 VehicleWheeledSimulation m_VehicleWheeledSimulation;
20
21 ref array<ref TrackDecalFactory> m_TrackDecals;
22 int m_iWheelCount = 0;
23
24 //------------------------------------------------------------------------------------------------
25 override void OnPostInit(IEntity owner)
26 {
27 // Don't run this component on console app
28 if (System.IsConsoleApp())
29 {
30 Deactivate(owner);
31 return;
32 }
33
34 SetEventMask(owner, EntityEvent.INIT);
35 }
36
37 //------------------------------------------------------------------------------------------------
38 override void EOnInit(IEntity owner)
39 {
40 super.EOnInit(owner);
41 GenericEntity generic_entity = GenericEntity.Cast(owner);
42
43 if(generic_entity)
44 {
45 m_VehicleWheeledSimulation = VehicleWheeledSimulation.Cast(generic_entity.FindComponent(VehicleWheeledSimulation));
46 m_iWheelCount = m_VehicleWheeledSimulation.WheelCount();
47 }
48
49 m_TrackDecals = new array<ref TrackDecalFactory>();
50 m_TrackDecals.Resize(m_iWheelCount);
51
52 for(int i = 0; i < m_iWheelCount; i++)
53 {
54 m_TrackDecals[i] = new TrackDecalFactory(m_TrackMaterial, 0.25, 10);
55 }
56
57 SetEventMask(owner, EntityEvent.FRAME);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 override void EOnFrame(IEntity owner, float timeSlice)
62 {
63 for(int i = 0; i < m_iWheelCount; i++)
64 {
65 UpdateTrack(owner, i);
66 }
67 }
68
69 void UpdateTrack(IEntity owner, int wheelIdx)
70 {
71 float lateralSlip = m_VehicleWheeledSimulation.WheelGetLateralSlip(wheelIdx);
72 float latitudeSlip = m_VehicleWheeledSimulation.WheelGetLongitudinalSlip(wheelIdx);
73
74 bool shouldAddTrackDecal = m_VehicleWheeledSimulation.WheelHasContact(wheelIdx) && (lateralSlip >= m_fMinimalLateralSlip || latitudeSlip >= m_fMinimalLongitudinalSlip);
75
76 if(!shouldAddTrackDecal)
77 {
78 m_TrackDecals[wheelIdx].FinalizeDecal(0.25);
79 return;
80 }
81
82 vector position = m_VehicleWheeledSimulation.WheelGetContactPosition(wheelIdx);
83 vector normal = m_VehicleWheeledSimulation.WheelGetContactNormal(wheelIdx);
84 IEntity contactEntity = m_VehicleWheeledSimulation.WheelGetContactEntity(wheelIdx);
85
86 m_TrackDecals[wheelIdx].AddPoint(contactEntity, position, normal, 1.0);
87 }
88};
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void Deactivate()
vector position
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external Managed FindComponent(typename typeName)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14