Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CustomMaterialAnimatorEntity.c
Go to the documentation of this file.
1 
47 [EntityEditorProps(category: "GameScripted/MaterialAnimation", description: "This entity plays .emat animations consistently from the given starting frame to the given end frame. After the animation is done it can: Loop (default), hide the entity, delete the entity or delete the entity and children")]
48 class SCR_CustomMaterialAnimatorEntityClass: GenericEntityClass
49 {
50 };
52 {
53  [Attribute("1", params: "1 99999999", category: "Material Animation", desc: "Starting frame (texture in emat Albedo Map) of the animation. If m_bDeleteWhenDone is false then it will also restart on this frame again, Use in combination with m_iEndFrameIndex to play specific sections of the material animation. The first frame is 1 (so it is not an index)")]
54  protected int m_iStartingFrame;
55 
56  [Attribute("-1", params: "-1 99999999", category: "Material Animation", desc: "At which frame (texture in the Albedo Map) should the animation stop playing (loop again or destroy entity). This should never be higher then Albedo Map texture count else there might be unintentional consequences.")]
57  protected int m_iEndFrame;
58 
59  [Attribute("60", params: "0.001 99999999", category: "Material Animation", desc: "Use this to change the speed of the animation. Higher value means faster animation, if you have 60 frames and this value is 60 then the animation will be done in 1 second")]
60  protected float m_fAnimationSpeed;
61 
62  [Attribute(defvalue: "0", category: "Material Animation", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EActionWhenDone), desc: "What will happen when the animation is done? By default it will loop but can also set to: Hide entity (sets visiblity flag), delete entity and delete entity & children")]
63  protected EActionWhenDone m_iActionWhenDone;
64 
65  //~ This value is the actual varriable the emat will read. See the top of this script how to set up the emat.
66  protected int m_iMaterialAnimationFrame = 0;
67 
68  //~ This value is used to calculate the next m_iMaterialAnimationFrame
69  protected float m_fMaterialAnimationFrameCalculator = 0;
70 
71 
72  override protected void EOnFrame(IEntity owner, float timeSlice)
73  {
74  //~ Increase the frame calculater
75  m_fMaterialAnimationFrameCalculator += m_fAnimationSpeed * timeSlice;
76 
77  //~ Set frame to converted int of calculator. The m_iMaterialAnimationFrame is the actual value the emat will read
78  m_iMaterialAnimationFrame = m_fMaterialAnimationFrameCalculator;
79 
80  //End of animation reached
81  if (m_iMaterialAnimationFrame >= m_iEndFrame)
82  {
83  //~ Animation done, Loop again to m_iStartingFrame
84  if (m_iActionWhenDone == EActionWhenDone.LOOP)
85  {
86  m_fMaterialAnimationFrameCalculator = m_iStartingFrame;
87  m_iMaterialAnimationFrame = m_iStartingFrame;
88  }
89  //~ Animation done, remove on Frame and hide the entity
90  else if (m_iActionWhenDone == EActionWhenDone.HIDE)
91  {
92  ClearEventMask(EntityEvent.FRAME);
93  ClearFlags(EntityFlags.VISIBLE, true);
94  }
95  //~ Animation done delete self
96  else if (m_iActionWhenDone == EActionWhenDone.DELETE_SELF)
97  {
98  delete this;
99  }
100  //~ Animation done delete self and children
101  else if (m_iActionWhenDone == EActionWhenDone.DELETE_SELF_AND_CHILDREN)
102  {
103  SCR_EntityHelper.DeleteEntityAndChildren(this);
104  }
105  }
106  }
107 
108  void SCR_CustomMaterialAnimatorEntity(IEntitySource src, IEntity parent)
109  {
110  if (m_iEndFrame < 1)
111  Print("'SCR_CustomMaterialAnimatorEntity': 'm_iEndFrame' is not set correctly! Check the textures in the Albedo Map of the emat to find out what to set the 'm_iEndFrame' value to", LogLevel.WARNING);
112  else if (m_iStartingFrame > m_iEndFrame)
113  Print("'SCR_CustomMaterialAnimatorEntity': 'm_iStartingFrame' is higher then 'm_iEndFrame', make sure 'm_iStartingFrame' is lower then 'm_iEndFrame'!", LogLevel.WARNING);
114 
115 
116  //~ System works with indexes so while varriables follow the same logic as the albinoMap starting at frame 1 and ending at count. The actual logic starts at index 0 and ends at count -1.
117  m_iStartingFrame -= 1;
118  m_iEndFrame -= 1;
119 
120  m_fMaterialAnimationFrameCalculator = m_iStartingFrame;
121  m_iMaterialAnimationFrame = m_iStartingFrame;
122 
123  SetEventMask(EntityEvent.FRAME);
124  }
125 };
126 
128 {
129  LOOP = 0,
130  HIDE = 1,
133 };
134 
135 
136 
137 
138 
139 
140 
141 
142 
SCR_CustomMaterialAnimatorEntity
Definition: SCR_CustomMaterialAnimatorEntity.c:51
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
HIDE
@ HIDE
Definition: SCR_CustomMaterialAnimatorEntity.c:130
LOOP
@ LOOP
Definition: SCR_CustomMaterialAnimatorEntity.c:129
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_CustomMaterialAnimatorEntityClass
Definition: SCR_CustomMaterialAnimatorEntity.c:48
DELETE_SELF
@ DELETE_SELF
Definition: SCR_CustomMaterialAnimatorEntity.c:131
Attribute
typedef Attribute
Post-process effect of scripted camera.
EActionWhenDone
EActionWhenDone
Definition: SCR_CustomMaterialAnimatorEntity.c:127
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
DELETE_SELF_AND_CHILDREN
@ DELETE_SELF_AND_CHILDREN
Definition: SCR_CustomMaterialAnimatorEntity.c:132
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180