Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignBuildingNetworkComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Building", description: "Handles client > server communication in Building. Should be attached to PlayerController.")]
2 class SCR_CampaignBuildingNetworkComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_CampaignBuildingNetworkComponent : ScriptComponent
7 {
8  //------------------------------------------------------------------------------------------------
12  void AddBuildingValue(int buildingValue, notnull IEntity compositionOutline)
13  {
14  RplComponent comp = RplComponent.Cast(compositionOutline.FindComponent(RplComponent));
15  if (!comp)
16  return;
17 
18  Rpc(RpcAsk_AddBuildingValue, buildingValue, comp.Id());
19  }
20 
21  //------------------------------------------------------------------------------------------------
25  void RemoveEditorMode(int playerID, IEntity provider)
26  {
27  RplComponent comp = RplComponent.Cast(provider.FindComponent(RplComponent));
28  if (!comp)
29  return;
30 
31  Rpc(RpcAsk_RemoveEditorMode, playerID, comp.Id());
32  }
33 
34  //------------------------------------------------------------------------------------------------
40  void RequestEnterBuildingMode(IEntity provider, int playerID, bool UserActionActivationOnly, bool UserActionUsed)
41  {
42  RplComponent providerRplComp = RplComponent.Cast(provider.FindComponent(RplComponent));
43  if (!providerRplComp)
44  return;
45 
46  Rpc(RpcAsk_RequestEnterBuildingMode, providerRplComp.Id(), playerID, UserActionActivationOnly, UserActionUsed);
47  }
48 
49  //------------------------------------------------------------------------------------------------
52  void DeleteCompositionByUserAction(notnull IEntity composition)
53  {
54  RplComponent comp = RplComponent.Cast(composition.FindComponent(RplComponent));
55  if (!comp)
56  return;
57 
59  }
60 
61  //------------------------------------------------------------------------------------------------
66  void SendDeleteNotification(notnull IEntity composition, int playerId, int callsign)
67  {
68  RplComponent comp = RplComponent.Cast(composition.FindComponent(RplComponent));
69  if (!comp)
70  return;
71 
72  Rpc(RpcAsk_SendDeleteNotification, comp.Id(), playerId, callsign);
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  void SetClientLock(bool lock, IEntity provider)
77  {
78  RplComponent comp = RplComponent.Cast(provider.FindComponent(RplComponent));
79  if (!comp)
80  return;
81 
82  Rpc(RpcDo_SetClientLock, lock, comp.Id());
83  }
84 
85  //------------------------------------------------------------------------------------------------
87  [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
88  protected void RpcDo_SetClientLock(bool lock, RplId compId)
89  {
90  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(compId));
91  if (!rplComp)
92  return;
93 
94  IEntity provider = rplComp.GetEntity();
95  if (!provider)
96  return;
97 
98  SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
99  if (providerComponent)
100  providerComponent.SetCooldownClientLock(lock);
101  }
102 
103  //------------------------------------------------------------------------------------------------
107  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
108  protected void RpcAsk_AddBuildingValue(int buildingValue, RplId compId)
109  {
110  IEntity compositionOutline = GetProviderFormRplId(compId);
111  if (!compositionOutline)
112  return;
113 
114  SCR_CampaignBuildingLayoutComponent layoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(compositionOutline.FindComponent(SCR_CampaignBuildingLayoutComponent));
115  if (!layoutComponent)
116  return;
117 
118  layoutComponent.AddBuildingValue(buildingValue);
119  }
120 
121  //------------------------------------------------------------------------------------------------
125  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
126  protected void RpcAsk_RemoveEditorMode(int playerID, RplId compId)
127  {
128  IEntity provider = GetProviderFormRplId(compId);
129  if (!provider)
130  return;
131 
132  BaseGameMode gameMode = GetGame().GetGameMode();
133 
134  SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
135  if (!buildingManagerComponent)
136  return;
137 
138  SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
139  if (!providerComponent)
140  return;
141 
142  bool isActiveUser = buildingManagerComponent.RemovePlayerIdFromProvider(playerID, providerComponent);
143  buildingManagerComponent.RemoveProvider(playerID, providerComponent, isActiveUser);
144  }
145 
146  //------------------------------------------------------------------------------------------------
152  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
153  protected void RpcAsk_RequestEnterBuildingMode(RplId rplProviderId, int playerID, bool UserActionActivationOnly, bool UserActionUsed)
154  {
155  IEntity provider = GetProviderFormRplId(rplProviderId);
156  if (!provider)
157  return;
158 
159  BaseGameMode gameMode = GetGame().GetGameMode();
160  SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
161  if (!buildingManagerComponent)
162  return;
163 
164  buildingManagerComponent.GetEditorMode(playerID, provider, UserActionActivationOnly, UserActionUsed);
165  }
166 
167  //------------------------------------------------------------------------------------------------
170  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
171  protected void RpcAsk_DeleteCompositionByUserAction(RplId rplCompositionId)
172  {
173  IEntity composition = GetProviderFormRplId(rplCompositionId);
174  if (!composition)
175  return;
176 
177  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(composition.GetRootParent().FindComponent(SCR_EditableEntityComponent));
178  if (editableEntity)
179  editableEntity.Delete();
180  else
181  RplComponent.DeleteRplEntity(composition, false);
182  }
183 
184  //------------------------------------------------------------------------------------------------
189  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
190  protected void RpcAsk_SendDeleteNotification(RplId rplCompositionId, int playerId, int callsign)
191  {
192  IEntity composition = GetProviderFormRplId(rplCompositionId);
193  if (!composition)
194  return;
195 
196  SCR_Faction faction = SCR_Faction.Cast(SCR_FactionManager.SGetPlayerFaction(playerId));
197  if (!faction)
198  return;
199 
200  SCR_NotificationsComponent.SendToFaction(faction, true, ENotification.EDITOR_SERVICE_DISASSEMBLED, playerId, rplCompositionId, callsign);
201  }
202 
203  //------------------------------------------------------------------------------------------------
206  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
207  protected void RpcAsk_AddXPReward(int playerId)
208  {
209  BaseGameMode gameMode = GetGame().GetGameMode();
210  if (!gameMode)
211  return;
212 
213  SCR_XPHandlerComponent compXP = SCR_XPHandlerComponent.Cast(gameMode.FindComponent(SCR_XPHandlerComponent));
214  if (!compXP)
215  return;
216 
217  compXP.AwardXP(playerId, SCR_EXPRewards.FREE_ROAM_BUILDING_BUILT);
218  }
219 
220  //------------------------------------------------------------------------------------------------
223  void AddXPReward(int playerId)
224  {
225  Rpc(RpcAsk_AddXPReward, playerId);
226  }
227 
228  //------------------------------------------------------------------------------------------------
231  IEntity GetProviderFormRplId(RplId rplProviderId)
232  {
233  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(rplProviderId));
234  if (!rplComp)
235  return null;
236 
237  return rplComp.GetEntity();
238  }
239 }
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
DeleteCompositionByUserAction
void DeleteCompositionByUserAction(notnull IEntity composition)
Definition: SCR_CampaignBuildingNetworkComponent.c:52
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
RpcAsk_AddXPReward
protected void RpcAsk_AddXPReward(int playerId)
Definition: SCR_CampaignBuildingNetworkComponent.c:207
RemoveEditorMode
void RemoveEditorMode(int playerID, IEntity provider)
Definition: SCR_CampaignBuildingNetworkComponent.c:25
SendDeleteNotification
void SendDeleteNotification(notnull IEntity composition, int playerId, int callsign)
Definition: SCR_CampaignBuildingNetworkComponent.c:66
RpcAsk_SendDeleteNotification
protected void RpcAsk_SendDeleteNotification(RplId rplCompositionId, int playerId, int callsign)
Definition: SCR_CampaignBuildingNetworkComponent.c:190
RpcAsk_RemoveEditorMode
protected void RpcAsk_RemoveEditorMode(int playerID, RplId compId)
Definition: SCR_CampaignBuildingNetworkComponent.c:126
RpcAsk_RequestEnterBuildingMode
protected void RpcAsk_RequestEnterBuildingMode(RplId rplProviderId, int playerID, bool UserActionActivationOnly, bool UserActionUsed)
Definition: SCR_CampaignBuildingNetworkComponent.c:153
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
ENotification
ENotification
Definition: ENotification.c:4
RpcAsk_DeleteCompositionByUserAction
protected void RpcAsk_DeleteCompositionByUserAction(RplId rplCompositionId)
Definition: SCR_CampaignBuildingNetworkComponent.c:171
RpcDo_SetClientLock
protected void RpcDo_SetClientLock(bool lock, RplId compId)
Set a cooldown lock on client.
Definition: SCR_CampaignBuildingNetworkComponent.c:88
RpcAsk_AddBuildingValue
protected void RpcAsk_AddBuildingValue(int buildingValue, RplId compId)
Definition: SCR_CampaignBuildingNetworkComponent.c:108
SetClientLock
void SetClientLock(bool lock, IEntity provider)
Definition: SCR_CampaignBuildingNetworkComponent.c:76
AddBuildingValue
SCR_CampaignBuildingNetworkComponentClass ScriptComponentClass AddBuildingValue(int buildingValue, notnull IEntity compositionOutline)
Definition: SCR_CampaignBuildingNetworkComponent.c:12
GetProviderFormRplId
IEntity GetProviderFormRplId(RplId rplProviderId)
Definition: SCR_CampaignBuildingNetworkComponent.c:231
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_EXPRewards
SCR_EXPRewards
Definition: SCR_XPHandlerComponent.c:403
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
RequestEnterBuildingMode
void RequestEnterBuildingMode(IEntity provider, int playerID, bool UserActionActivationOnly, bool UserActionUsed)
Definition: SCR_CampaignBuildingNetworkComponent.c:40
SCR_CampaignBuildingNetworkComponentClass
Definition: SCR_CampaignBuildingNetworkComponent.c:2
AddXPReward
void AddXPReward(int playerId)
Definition: SCR_CampaignBuildingNetworkComponent.c:223
SCR_Faction
Definition: SCR_Faction.c:6
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180