4 [
Attribute(
"0",
desc:
"If false then the object has no physics to move itself. If true it means the entity is a vehicle (or part of a vehicle) and it can be moved via physics which means it checks the rigid body if it has a velocity and does not allow to be used if it has",
category:
"General Settings")]
5 protected bool m_bIsVehicle;
7 [
Attribute(
"1",
desc:
"If true it will send out a notification if the user uses it. The Inherented class does need to support notifications for it to be send",
category:
"Specific Settings")]
8 protected bool m_bSendNotificationOnUse;
10 [
Attribute(
"0",
desc:
"If true it allows the support station to get the 'FactionAffiliationComponent' from parent. This is only done when no 'FactionAffiliationComponent' is found on self and main use case is for vehicle compartments. Only used if 'FactionUsageCheck' is set",
category:
"Faction Settings")]
11 protected bool m_bAllowGetFactionFromParent;
13 [
Attribute(
"{9DD9C6279F4489B4}Sounds/Editor/SupportStations/SupportStations_Vehicles.acp",
desc:
"File that contains the sound effect",
params:
"acp",
category:
"On use Audio")]
14 protected ResourceName m_sOnUseSoundEffectFile;
16 [
Attribute(
desc:
"Sound effect played when executing is done. Broadcast to players. Leave empty if no sfx",
category:
"On use Audio")]
17 protected string m_sOnUseSoundEffectEventName;
19 [
Attribute(
desc:
"Sound played from from user on successfully action. (Some support station might play action on action owner instead of user). Leave empty to not play any voice effects",
category:
"On use Audio")]
20 protected string m_sCharacterVoiceEventOnUse;
23 protected int m_iCharacterVoicePriority;
25 protected ref SCR_AudioSourceConfiguration m_OnUseAudioSourceConfiguration;
30 bool GetSendNotificationOnUse()
38 bool CanMoveWithPhysics()
47 bool AllowGetFactionFromParent()
56 SCR_AudioSourceConfiguration GetOnUseAudioConfig()
59 if (!m_OnUseAudioSourceConfiguration)
68 if (!CanMoveWithPhysics())
81 void GetCharacterVoiceSoundEventVariables(out
string characterVoiceEventOnUse, out
int characterVoicePriority)
90 [
Attribute(
"0",
desc:
"Priority dictates the array order when trying to get the first availible support station. Higher priority means it is closer to the start of the array. Think of grabbing a composition refuel station before a vehicle refuel station.", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(
ESupportStationPriority),
category:
"General Settings")]
93 [
Attribute(
"7",
desc:
"In meters, Range in which the entity which the player interacts is needs to be. If -1 it will not add itself to the Support Station Manager and can only be used by the action manager that is also a component of the entity this component is part of, note that the action manager will also never check if any are around it only the component on the entity.",
category:
"General Settings")]
99 [
Attribute(
"0",
desc:
"When executing the action and isUsingSupplies this is the base supply cost of the action regardless of any additional supply costs. 0 to have no upfront cost (note inherented classes might still have their own supply cost calculation)",
params:
"0 inf 1",
category:
"Supplies")]
102 [
Attribute(
"0",
desc:
"If Supply station has range it can ignore itself. If you set this false it will also grab itself when looking for stations in range. Think of a fuel tank able to refuel itself. If this is true it cannot if this is false it can. Not that compartments on vehicles are seen as seperate. So a fuel provider cannot refuel itself but it can still refuel the truck for driving",
category:
"Specific Settings")]
105 [
Attribute(
desc:
"Offset of the center of the support station. Note the Area Mesh zone will only visualise this correctly on runtime not in workbench", uiwidget: UIWidgets.Coords,
params:
"inf inf 0 purpose=coords space=entity",
category:
"Specific Settings")]
108 [
Attribute(
desc:
"Set faction of user that can use Support Station, will be ignored if non are selected. Requires a 'FactionAffiliationComponent' on the Support Station or (or 'AllowGetFactionFromParent' is true on vehicle compartments). It will always allow interaction if user does not have 'FactionAffiliationComponent'. Default faction is the faction associated with the Initial Support Station faction. Flags are checked in order. DISALLOW ON null is only checked when Default faction check is not set.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(
ESupportStationFactionUsage),
category:
"Faction Settings")]
111 [
Attribute(
desc:
"Action name when executing the action. Note that if this is left empty then the default ActionManager action name is used",
category:
"General Settings")]
140 FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
142 OnExecute(actionOwner, actionUser, playerId, action);
148 protected void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out
int playerId)
152 ownerId = Replication.FindId(owner.FindComponent(RplComponent));
154 if (ownerId == Replication.INVALID_ID)
156 IEntity parent = owner.GetParent();
158 ownerId = Replication.FindId(parent.FindComponent(RplComponent));
163 userId = Replication.FindId(user.FindComponent(RplComponent));
167 playerId = playerManager.GetPlayerIdFromControlledEntity(user);
171 protected void GetEntitiesFromID(RplId ownerId, RplId userId, out IEntity owner, out IEntity user)
173 RplComponent rpl = RplComponent.Cast(Replication.FindItem(ownerId));
175 owner = rpl.GetEntity();
177 rpl = RplComponent.Cast(Replication.FindItem(userId));
179 user = rpl.GetEntity();
184 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
187 IEntity actionOwner, actionUser;
194 ActionsManagerComponent actionManager = ActionsManagerComponent.Cast(actionOwner.FindComponent(ActionsManagerComponent));
200 OnExecute(actionOwner, actionUser, userPlayerId, action);
229 SoundComponent soundComponent = SoundComponent.Cast(soundOwner.FindComponent(SoundComponent));
235 if (soundComponent.GetEventIndex(audioConfig.m_sSoundEventName) > 0)
238 soundComponent.SoundEventOffset(audioConfig.m_sSoundEventName, action.GetLocalPositionAction());
240 soundComponent.SoundEventOffset(audioConfig.m_sSoundEventName, vector.Zero);
246 Print(
string.Format(
"'SCR_BaseSupportStationComponent': Trying to play sound for '%1' but sound either sound event '%2' or more likely sound file '%3' is not included on the SoundComponent! SCR_SoundManagerEntity is used instead but that means position of sound is not updated if entity moves while sound is playing.", soundOwner, audioConfig.m_sSoundEventName, audioConfig.m_sSoundProject), LogLevel.WARNING);
252 if (!soundManagerEntity)
256 soundOwner.GetTransform(transform);
259 transform[3] = action.GetWorldPositionAction();
261 transform[3] = soundOwner.GetOrigin();
264 soundManagerEntity.CreateAndPlayAudioSource(soundOwner, audioConfig, transform);
275 CommunicationSoundComponent communicationSoundComponent = CommunicationSoundComponent.Cast(character.FindComponent(CommunicationSoundComponent));
276 if (!communicationSoundComponent)
284 string characterVoiceEventOnUse;
285 int characterVoicePriority;
288 classData.GetCharacterVoiceSoundEventVariables(characterVoiceEventOnUse, characterVoicePriority);
292 communicationSoundComponent.SoundEventPriority(characterVoiceEventOnUse, characterVoicePriority,
true);
407 return m_eSupportStationPriority;
425 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
474 return m_Physics.GetVelocity() != vector.Zero ||
m_Physics.GetAngularVelocity() != vector.Zero;
490 FactionAffiliationComponent userFactionAffiliation = FactionAffiliationComponent.Cast(user.FindComponent(FactionAffiliationComponent));
491 if (!userFactionAffiliation)
495 Faction userFaction = userFactionAffiliation.GetAffiliatedFaction();
506 if (supportStationFaction)
526 if (!supportStationFaction)
585 if (Replication.IsClient())
603 protected bool HasEnoughSupplies(IEntity actionOwner, IEntity actionUser,
int supplyAmountToCheck)
609 if (Replication.IsClient())
648 return resourceComponent && resourceComponent.IsResourceTypeEnabled();
665 return SCR_ResourceComponent.FindResourceComponent(owner);
724 return classData && classData.GetSendNotificationOnUse();
736 return classData.GetOnUseAudioConfig();
750 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicle.FindComponent(SCR_BaseCompartmentManagerComponent));
751 if (!compartmentManager)
753 IEntity parent = vehicle.GetParent();
755 compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(parent.FindComponent(SCR_BaseCompartmentManagerComponent));
757 if (!compartmentManager)
765 array<IEntity> occupants = {};
766 compartmentManager.GetOccupants(occupants);
767 CompartmentAccessComponent compartmentAccess;
771 foreach (IEntity occupant : occupants)
773 playerID = playerManager.GetPlayerIdFromControlledEntity(occupant);
776 playerIds.Insert(playerID);
795 if (checkIfHasDamageSystem)
798 SCR_DamageManagerComponent damageManager = SCR_DamageManagerComponent.Cast(
GetOwner().FindComponent(SCR_DamageManagerComponent));
803 if (hitZoneContainer)
839 if (!supportStationManager)
842 supportStationManager.RemoveSupportStation(
this);
848 if (!supportStationManager)
851 supportStationManager.AddSupportStation(
this);
864 SCR_DamageManagerComponent damageManager = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
883 if (hitZoneContainer)
920 reader.ReadBool(enabled);
934 Print(
"'" +
GetOwner().
GetName() +
"' No Support Station type assigned in the inherented class. Overwrite the 'GetSupportStationType()' function and do not use the base class!", LogLevel.ERROR);
945 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(
GetOwner());
946 if (resourceComponent)
966 if (resourceComponent)
970 Print(
"'SCR_BaseSupportStationComponent' 'EOnInit': '" +
GetOwner() +
"' Support Station is set to use supplies but the consumer configuration in m_ResourceConsumer is missing", LogLevel.ERROR);
977 Print(
"'SCR_BaseSupportStationComponent' 'EOnInit': '" +
GetOwner() +
"' Support Station is set to use supplies but it has no SCR_ResourceComponent", LogLevel.ERROR);
987 if (classData && classData.CanMoveWithPhysics())
989 Vehicle vehicle = Vehicle.Cast(owner);
991 vehicle = Vehicle.Cast(owner.GetParent());
1004 if (classData && classData.AllowGetFactionFromParent())
1006 IEntity parent = owner.GetParent();
1013 Print(
string.Format(
"'SCR_BaseSupportStationComponent' of type '%1' has Faction usage check set to not ignore but is missing a 'FactionAffiliationComponent'",
typename.EnumToString(
ESupportStationType,
GetSupportStationType())), LogLevel.ERROR);
1024 if (!supportStationManager)
1027 if (owner.IsLoaded())
1028 Print(
"'SCR_BaseSupportStationComponent' Support station on entity that exists in world when loaded has range but no 'SCR_SupportStationManagerComponent' availible on GameMode. So it won't work!", LogLevel.WARNING);
1031 Debug.Error2(
"SCR_BaseSupportStationComponent",
"Support station exists with range but no 'SCR_SupportStationManagerComponent' availible on GameMode!");
1037 supportStationManager.AddSupportStation(
this);
1050 SetEventMask(owner, EntityEvent.INIT);
1076 if (!supportStationManager)
1079 supportStationManager.RemoveSupportStation(
this);
1083 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(owner);
1084 if (!resourceComponent && owner.GetParent())
1085 resourceComponent = SCR_ResourceComponent.FindResourceComponent(owner.GetParent());
1087 if (resourceComponent)
1099 SCR_BaseSupportStationComponent foundSupportStation;
1100 array<Managed> supportStations = {};
1104 entity.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1107 foreach (Managed supportStation : supportStations)
1109 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1110 if (!foundSupportStation)
1113 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1114 return foundSupportStation;
1121 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
1124 array<EntitySlotInfo> slotInfos = {};
1125 slotManager.GetSlotInfos(slotInfos);
1130 slotEntity = slotInfo.GetAttachedEntity();
1134 slotEntity.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1136 foreach (Managed supportStation : supportStations)
1138 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1139 if (!foundSupportStation)
1142 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1143 return foundSupportStation;
1152 IEntity child = entity.GetChildren();
1156 child.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1159 foreach (Managed supportStation : supportStations)
1161 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1162 if (!foundSupportStation)
1165 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1166 return foundSupportStation;
1169 child = child.GetSibling();
1178 parent = entity.GetParent();
1182 parent.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1185 foreach (Managed supportStation : supportStations)
1187 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1188 if (!foundSupportStation)
1191 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1192 return foundSupportStation;
1201 parent = entity.GetParent();
1206 if (foundSupportStation)
1207 return foundSupportStation;
1215 rootParent = entity.GetRootParent();
1219 rootParent.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1222 foreach (Managed supportStation : supportStations)
1224 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1225 if (!foundSupportStation)
1228 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1229 return foundSupportStation;
1238 rootParent = entity.GetRootParent();
1243 if (foundSupportStation)
1244 return foundSupportStation;
1251 parent = entity.GetParent();
1256 IEntity child = parent.GetChildren();
1261 if (child == entity)
1263 child = child.GetSibling();
1267 child.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1270 foreach (Managed supportStation : supportStations)
1272 foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1273 if (!foundSupportStation)
1276 if (
type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() ==
type)
1277 return foundSupportStation;
1280 child = child.GetSibling();