Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PostProcessCameraComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Camera", description: "")]
3 {
4 }
5 
8 {
9  [Attribute()]
10  private ref array<ref SCR_CameraPostProcessEffect> m_Effects;
11 
13 
14  //------------------------------------------------------------------------------------------------
19  {
20  foreach (SCR_CameraPostProcessEffect effect: m_Effects)
21  {
22  if (type == effect.GetType())
23  return effect;
24  }
25  return null;
26  }
27 
28  //------------------------------------------------------------------------------------------------
29  protected void OnCameraActivate()
30  {
31  foreach (SCR_CameraPostProcessEffect effect: m_Effects)
32  {
33  effect.CreateEffect(m_Camera.GetCameraIndex());
34  }
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  protected void OnCameraDeactivate()
39  {
40  foreach (SCR_CameraPostProcessEffect effect: m_Effects)
41  {
42  effect.DeleteEffect();
43  }
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  // constructor
51  void SCR_PostProcessCameraComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
52  {
53  m_Camera = SCR_CameraBase.Cast(ent);
54  if (!m_Camera)
55  return;
56 
57  m_Camera.GetOnCameraActivate().Insert(OnCameraActivate);
58  m_Camera.GetOnCameraDeactivate().Insert(OnCameraDeactivate);
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  // destructor
64  {
65  if (!m_Camera)
66  return;
67 
68  m_Camera.GetOnCameraActivate().Remove(OnCameraActivate);
69  m_Camera.GetOnCameraDeactivate().Remove(OnCameraDeactivate);
70  }
71 }
72 
73 [BaseContainerProps(), SCR_BaseContainerCustomTitleEnum(PostProcessEffectType, "m_Type")]
75 {
76  [Attribute(defvalue: "0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(PostProcessEffectType))]
77  private PostProcessEffectType m_Type;
78 
79  [Attribute(uiwidget: UIWidgets.Slider, params: "0 19 1")]
80  private int m_iPriority;
81 
82  [Attribute(params: "emat")]
83  private ResourceName m_MaterialPath;
84 
85  private int m_iCameraId;
86  private Material m_Material;
87 
88  //------------------------------------------------------------------------------------------------
90  PostProcessEffectType GetType()
91  {
92  return m_Type;
93  }
94 
95  //------------------------------------------------------------------------------------------------
98  void SetParam(string param, float value)
99  {
100  if (m_Material)
101  m_Material.SetParam(param, value);
102  }
103 
104  //------------------------------------------------------------------------------------------------
107  void ResetParam(string param)
108  {
109  if (m_Material)
110  m_Material.ResetParam(param);
111  }
112 
113  //------------------------------------------------------------------------------------------------
114  void SetMaterial()
115  {
116  SetMaterial(m_MaterialPath);
117  }
118 
119  //------------------------------------------------------------------------------------------------
121  void SetMaterial(ResourceName material)
122  {
123  GetGame().GetWorld().SetCameraPostProcessEffect(m_iCameraId, m_iPriority, m_Type, material);
124 
125  m_Material = Material.GetMaterial(material);
126  if (!m_Material)
127  {
128  Print(string.Format("Error when loading post-process material '%1'! Please check effect priority.", material), LogLevel.ERROR);
129  DeleteEffect();
130  return;
131  }
132  }
133 
134  //------------------------------------------------------------------------------------------------
137  void CreateEffect(int cameraId)
138  {
139  if (SCR_Global.IsEditMode())
140  return;
141 
142  m_iCameraId = cameraId;
143  SetMaterial();
144  }
145 
146  //------------------------------------------------------------------------------------------------
148  void DeleteEffect()
149  {
150  if (SCR_Global.IsEditMode())
151  return;
152 
153  GetGame().GetWorld().SetCameraPostProcessEffect(m_iCameraId, m_iPriority, PostProcessEffectType.None, "");
154 
155  m_iCameraId = 0;
156  m_Material = null;
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  // destructor
162  {
163  DeleteEffect();
164  }
165 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition: SCR_CampaignHintStorage.c:22
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_Camera
private SCR_CameraBase m_Camera
Definition: SCR_PostProcessCameraComponent.c:12
SCR_PostProcessCameraComponent
void SCR_PostProcessCameraComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_PostProcessCameraComponent.c:51
Attribute
SCR_PostProcessCameraComponentClass SCR_BaseCameraComponentClass Attribute()] private ref array< ref SCR_CameraPostProcessEffect > m_Effects
Post-process effect of scripted camera.
SCR_CameraPostProcessEffect
Definition: SCR_PostProcessCameraComponent.c:74
SCR_PostProcessCameraComponentClass
Definition: SCR_PostProcessCameraComponent.c:2
SCR_CameraBase
Definition: SCR_CameraBase.c:9
OnCameraActivate
protected void OnCameraActivate()
activation
Definition: SCR_PostProcessCameraComponent.c:29
m_Type
protected EEditableEntityType m_Type
Definition: SCR_EntitiesToolbarEditorUIComponent.c:3
SCR_Global
Definition: Functions.c:6
m_Material
protected ResourceName m_Material
Definition: SCR_BaseAreaMeshComponent.c:27
OnCameraDeactivate
protected void OnCameraDeactivate()
deactivation
Definition: SCR_PostProcessCameraComponent.c:38
SCR_BaseCameraComponent
SCR_CameraBaseClass SCR_BaseCameraComponent
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
FindEffect
SCR_CameraPostProcessEffect FindEffect(PostProcessEffectType type)
Definition: SCR_PostProcessCameraComponent.c:18
~SCR_PostProcessCameraComponent
void ~SCR_PostProcessCameraComponent()
Definition: SCR_PostProcessCameraComponent.c:63
m_iPriority
int m_iPriority
Definition: SCR_AITalkRequest.c:28
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_BaseCameraComponentClass
Definition: SCR_BaseCameraComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180