Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
AttachToSlotManagerCinematicTrack.c
Go to the documentation of this file.
1[CinematicTrackAttribute(name:"AttachToSlot Track", description:"Track used for attaching entities to Slot Manager")]
3{
4
5 [Attribute("")]
6 string m_sEntityToAttach;
7
8 [Attribute("")]
9 string m_sSlotName;
10
11 [Attribute("0 0 0")]
12 vector m_Position;
13
14 [Attribute("0 0 0")]
15 vector m_Rotation;
16
17 [Attribute("1.0", params:"0.01 100.0")]
18 float m_fScale;
19
20 private GenericEntity m_GeneralEntity;
21 private GenericEntity m_EntityToAttach;
22 private World globalWorld;
23
24 override void OnInit(World world)
25 {
26 // Find particle entity by using name of track
27 findEntity(world);
28 m_EntityToAttach = GenericEntity.Cast(world.FindEntityByName(m_sEntityToAttach));
29 globalWorld = world;
30 }
31
32 void findEntity(World world)
33 {
34 // Find particle entity by using name of track
35 TStringArray strs = new TStringArray;
36 GetTrackName().Split("_", strs, true);
37
38 m_GeneralEntity = GenericEntity.Cast(world.FindEntityByName(strs.Get(0)));
39 }
40
41 override void OnApply(float time)
42 {
43
44 if (globalWorld)
45 {
46 //Finding effect entity each frame for keep working in edit time
47 findEntity(globalWorld);
48
49 if (m_sEntityToAttach == "player" && GetGame().GetPlayerController())
50 m_EntityToAttach = SCR_ChimeraCharacter.Cast(GetGame().GetPlayerController().GetControlledEntity());
51 else
52 m_EntityToAttach = GenericEntity.Cast(globalWorld.FindEntityByName(m_sEntityToAttach));
53 }
54
55 //Attaching entity to slot
56 if (m_GeneralEntity && m_EntityToAttach)
57 {
58 SlotManagerComponent slotManager = SlotManagerComponent.Cast(m_GeneralEntity.FindComponent(SlotManagerComponent));
59
60 if (slotManager)
61 {
62 EntitySlotInfo entityInSlot = slotManager.GetSlotByName(m_sSlotName);
63
64 if(entityInSlot)
65 {
66 entityInSlot.AttachEntity(m_EntityToAttach);
67 vector matrix[4];
68 Math3D.AnglesToMatrix(m_Rotation, matrix);
69 matrix[3] = m_Position;
70 Math3D.MatrixScale(matrix,m_fScale);
71 entityInSlot.SetAdditiveTransformLS(matrix);
72 m_GeneralEntity.Update();
73 m_EntityToAttach.Update();
74 }
75 }
76 }
77 }
78}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Adds ability to attach an object to a slot.
Definition World.c:16
SCR_EditableEntityComponent GetControlledEntity()
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()
array< string > TStringArray
Definition Types.c:385