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")]
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;
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;
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;
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")]
66 protected int m_iMaterialAnimationFrame = 0;
69 protected float m_fMaterialAnimationFrameCalculator = 0;
72 override protected void EOnFrame(IEntity owner,
float timeSlice)
75 m_fMaterialAnimationFrameCalculator += m_fAnimationSpeed * timeSlice;
78 m_iMaterialAnimationFrame = m_fMaterialAnimationFrameCalculator;
81 if (m_iMaterialAnimationFrame >= m_iEndFrame)
86 m_fMaterialAnimationFrameCalculator = m_iStartingFrame;
87 m_iMaterialAnimationFrame = m_iStartingFrame;
92 ClearEventMask(EntityEvent.FRAME);
93 ClearFlags(EntityFlags.VISIBLE,
true);
101 else if (m_iActionWhenDone ==
EActionWhenDone.DELETE_SELF_AND_CHILDREN)
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);
117 m_iStartingFrame -= 1;
120 m_fMaterialAnimationFrameCalculator = m_iStartingFrame;
121 m_iMaterialAnimationFrame = m_iStartingFrame;
123 SetEventMask(EntityEvent.FRAME);