7 [
Attribute(defvalue:
"15",
desc:
"Height in meters that will be used to check if deployment position is under something.\nNot used if deployment user action is not selected to prevent indoors placement",
params:
"0 inf 0.01",
category:
"Validation")]
10 [
Attribute(defvalue:
"1",
desc:
"If this entity should be deleted when it is deployed",
category:
"Setup")]
13 [
Attribute(
desc:
"If only currently loaded magazines should be dropped when this entity is deleted",
category:
"Setup")]
16 [
Attribute(
desc:
"If all stored items should be dropped when this entity is deleted",
category:
"Setup")]
20 protected ref array<ref SCR_DeployableVariantContainer>
m_aVariants;
25 [
Attribute(
desc:
"If forward vector of spawned entity should face the player (by default it will face away from player)",
category:
"Setup")]
53 if (variant.GetVariantId() == variantId)
156 if (GenericTerrainEntity.Cast(collidingBody))
163 UIInfo uiInfo = iic.GetUIInfo();
164 if (uiInfo && uiInfo.GetName().IsEmpty())
172 if (!editableEntityComp)
176 if (!scriptedUiInfo || scriptedUiInfo.GetName().IsEmpty())
198 protected static const LocalizedString SEARCH_FAIL_REASON_MISSING_PART =
"#AR-UserAction_Assemble_MissingPart";
200 protected static const ResourceName CAN_BUILD_MATERIAL =
"{56EBF5038622AC95}Assets/Conflict/CanBuild.emat";
201 protected static const ResourceName CANNOT_BUILD_MATERIAL =
"{14A9DCEA57D1C381}Assets/Conflict/CannotBuild.emat";
202 protected static const ResourceName TRANSPARENT_MATERIAL =
"{8FBC3A6E946F056E}Common/Materials/Default_Transparent.emat";
204 protected static const float MINOR_SAFETY_OFFSET = 0.05;
211 protected static bool s_bShowBoundingBoxDebug;
216 array<ref WB_UIMenuItem> items = {
new WB_UIMenuItem(
"Toggle replacement prefabs bounding box visibility", 0) };
227 s_bShowBoundingBoxDebug = !s_bShowBoundingBoxDebug;
228 GenericWorldEntity world =
GetGame().GetWorldEntity();
232 IEntity child = world.GetChildren();
233 SCR_MultiPartDeployableItemComponent comp;
236 comp = SCR_MultiPartDeployableItemComponent.Cast(child.
FindComponent(SCR_MultiPartDeployableItemComponent));
238 DrawBoundingBoxDebug(child);
253 void DrawBoundingBoxDebug(notnull
IEntity owner)
258 m_DebugShapeMgr.Clear();
259 if (!s_bShowBoundingBoxDebug)
268 Color color =
new Color(r, g, b, a);
270 array<ref SCR_DeployableVariantContainer> variants =
data.GetVariants();
271 foreach (
int i, SCR_DeployableVariantContainer variant : variants)
277 if (mins == vector.Zero && maxs == vector.Zero)
280 owner.GetTransform(mat);
281 mat[3] = mat[3] + owner.VectorToParent(
m_VariantContainer.GetAdditionaPlacementOffset());
285 mat[3] = mat[3] + MINOR_SAFETY_OFFSET * mat[1];
287 Shape shape = Shape.Create(
ShapeType.BBOX, color.PackToInt(), shapeFlags, mins, maxs);
290 shape.SetMatrix(mat);
291 m_DebugShapeMgr.Add(shape);
294 switch (Math.Mod(i, 3))
297 r = Math.Min(r + 51, 255);
301 g = Math.Min(g + 51, 255);
305 b = Math.Min(b + 51, 255);
309 color =
new Color(r, g, b, a);
316 override void _WB_AfterWorldUpdate(
IEntity owner,
float timeSlice)
318 DrawBoundingBoxDebug(owner);
357 return data.IsFrontFacingPlayer();
418 if (useDataFromOwnerPosition)
422 param.Exclude = owner;
448 return m_VariantContainer.IsSurfaceValid(surfaceEnt, worldPosition, surfaceNorm, nodeIndex, colliderIndex, surfaceProps, surfaceMaterial, colliderName);
481 if (!partReq.IsRequirementMet(difference))
483 failReason =
WidgetManager.Translate(SEARCH_FAIL_REASON_MISSING_PART, difference.ToString(), partReq.GetMissingPartName());
520 if (partReq.EvaluateFoundEntity(origin, distToEnt, foundPrefab, ent))
544 if (!
m_VariantContainer.GetReplacementPrefabBoundingBox(paramOBB.Mins, paramOBB.Maxs))
547 vector mat[4] = transform;
551 array<IEntity> excludeArray = {owner,
data.GetPreviewEntity()};
556 if (partReq.GetFoundEntities())
557 excludeArray.InsertAll(partReq.GetFoundEntities());
561 paramOBB.Mat[0] = mat[0];
562 paramOBB.Mat[1] = mat[1];
563 paramOBB.Mat[2] = mat[2];
564 paramOBB.Start = mat[3] + MINOR_SAFETY_OFFSET * paramOBB.Mat[1];
566 paramOBB.ExcludeArray = excludeArray;
574 m_DebugShapeMgr.Clear();
577 int color =
Color.RED;
578 if (!paramOBB.TraceEnt)
581 Shape shape =
Shape.Create(
ShapeType.BBOX, color, shapeFlags, paramOBB.Mins, paramOBB.Maxs);
584 mat[0] = paramOBB.Mat[0];
585 mat[1] = paramOBB.Mat[1];
586 mat[2] = paramOBB.Mat[2];
587 mat[3] = paramOBB.Start;
588 shape.SetMatrix(mat);
589 m_DebugShapeMgr.Add(shape);
593 if (!paramOBB.TraceEnt)
596 reason =
data.GetSpaceValidationFailureReason(paramOBB.TraceEnt);
608 traceParam.Start = transform[3] + (
vector.Up * MINOR_SAFETY_OFFSET);
609 traceParam.End = traceParam.Start + (
vector.Up *
data.GetIndoorsCheckHeight());
612 traceParam.Exclude = owner;
615 return traceParam.TraceEnt;
636 if (replacementPrefab.IsEmpty())
640 if (!resource.IsValid())
648 VObject vObj = resourceObject.ToVObject();
652 previewEnt.SetObject(vObj,
string.Empty);
656 previewEnt =
GetGame().SpawnEntityPrefab(resource, world);
668 vector mat[4] = transform;
694 if (
data.GetPreviewState() == state)
709 m_DebugShapeMgr.Clear();
715 data.SetPreviewState(state);
729 if (e.GetRootParent() ==
GetOwner())
741 if (!e.GetPrefabData())
770 array<IEntity> excludeArray = {owner, userEntity};
771 param.ExcludeArray = excludeArray;
778 if (!
IsSurfaceValid(param.TraceEnt, m_aOriginalTransform[3], param.TraceNorm, param.NodeIndex, param.ColliderIndex, param.SurfaceProps, param.TraceMaterial, param.ColliderName))
783 params.Transform = m_aOriginalTransform;
784 params.TransformMode = ETransformMode.WORLD;
787 if (!resource.IsValid())
791 if (!m_ReplacementEntity)
794 m_PreviousOwner = userEntity;
797 int playerID = playerMgr.GetPlayerIdFromControlledEntity(userEntity);
798 SetAuthor(m_ReplacementEntity, playerID);
802 SCR_MultiPartDeployableItemComponent deployableComp = SCR_MultiPartDeployableItemComponent.Cast(m_ReplacementEntity.FindComponent(SCR_MultiPartDeployableItemComponent));
804 deployableComp.SurfaceMonitoringInit(param.TraceEnt);
807 array<ref SCR_AdditionalDeployablePart> additionalPartsToSpawn =
m_VariantContainer.GetAdditionalPrefabList();
808 if (additionalPartsToSpawn)
813 SCR_DeployableInventoryItemInventoryComponent spawnedDIIC;
816 additionalPrefab.SpawnPrefabs(playerID, userEntity,
params);
824 if (
data &&
data.IsSoundEnabled() && !reload)
830 if (m_OnDeployedStateChanged)
841 static void SetAuthor(notnull
IEntity ent,
int playerID)
843 SCR_EditableEntityComponent editableComp = SCR_EditableEntityComponent.Cast(ent.FindComponent(SCR_EditableEntityComponent));
865 if (parentDamageManager)
873 if (editableComponent)
890 if (!observedHitZone)
893 if (surfaceDamageManager)
894 observedHitZone =
SCR_HitZone.Cast(surfaceDamageManager.GetDefaultHitZone());
901 if (editableComponent)
916 beaviour =
data.GetMonitoringBehaviour();
937 dmgMgrComp.HandleDamage(damageContext);
942 if (m_OnDeployedStateChanged)
945 RplComponent.DeleteRplEntity(owner,
false);
955 if (damagedHitZone.GetDamageState() !=
EDamageState.DESTROYED)
991 vector right = transform[1] * directionTrans[0];
992 vector forward = transform[1] * right;
997 if (
data &&
data.IsFrontFacingPlayer())
999 transform[0] = forward;
1000 transform[2] = right;
1004 transform[0] = -forward;
1005 transform[2] = -right;
1016 if (!partReq.ShouldDeleteFoundEntities())
1019 for (
int i = partReq.GetNumberOfFoundEntities() - 1; i >= 0; i--)
1021 if (!partReq.DeleteFoundEntity(i, m_PreviousOwner))
1022 Print(
"WARNING: SCR_MultiPartDeployableItemComponent => Deletion of required entity failed as this entity doesnt exist anymore",
LogLevel.WARNING);
1033 if (
data.IsDeletedWhenDeployed())
1035 if (
data.MustDropAllStoredItems())
1037 TryRemoveAllItemsFromStorage(owner, m_PreviousOwner);
1038 TryRemoveMagazineFromWeapons(owner, m_PreviousOwner);
1040 else if (
data.MustDropLoadedMagazines())
1042 TryRemoveMagazineFromWeapons(owner, m_PreviousOwner);
1061 if (damageMgr && !
float.AlmostEqual(damageMgr.GetHealthScaled(), 1))
1063 SCR_MultiPartDeployableItemComponent deployableComp = SCR_MultiPartDeployableItemComponent.Cast(m_ReplacementEntity.FindComponent(SCR_MultiPartDeployableItemComponent));
1065 deployableComp.SetReplacmentPrefabHealthScaled(damageMgr.GetHealthScaled());
1071 static void TryRemoveMagazineFromWeapons(notnull
IEntity owner, notnull
IEntity user)
1073 InventoryStorageManagerComponent storage = InventoryStorageManagerComponent.Cast(user.FindComponent(InventoryStorageManagerComponent));
1077 BaseMuzzleComponent muzzleComp = BaseMuzzleComponent.Cast(owner.FindComponent(BaseMuzzleComponent));
1078 if (muzzleComp && !muzzleComp.IsDisposable())
1080 BaseMagazineComponent currentMagazine = muzzleComp.GetMagazine();
1081 InventoryItemComponent magIIC;
1082 if (currentMagazine)
1083 magIIC = InventoryItemComponent.Cast(currentMagazine.GetOwner().
FindComponent(InventoryItemComponent));
1085 InventoryStorageSlot parentSlot;
1087 parentSlot = magIIC.GetParentSlot();
1089 BaseInventoryStorageComponent magContainer;
1091 magContainer = parentSlot.GetStorage();
1094 storage.TryRemoveItemFromStorage(currentMagazine.GetOwner(), magContainer);
1097 array<Managed> weaponSlots = {};
1098 owner.FindComponents(WeaponSlotComponent, weaponSlots);
1099 if (weaponSlots.IsEmpty())
1103 WeaponSlotComponent weaponSlot;
1104 InventoryStorageSlot slot;
1105 foreach (Managed managedComp : weaponSlots)
1107 weaponSlot = WeaponSlotComponent.Cast(managedComp);
1111 slot = weaponSlot.GetSlotInfo();
1115 weapon = slot.GetAttachedEntity();
1119 TryRemoveMagazineFromWeapons(weapon, user);
1125 static void TryRemoveAllItemsFromStorage(notnull
IEntity owner, notnull
IEntity user)
1127 InventoryStorageManagerComponent storageMgr = InventoryStorageManagerComponent.Cast(user.FindComponent(InventoryStorageManagerComponent));
1131 BaseInventoryStorageComponent storage = BaseInventoryStorageComponent.Cast(owner.FindComponent(BaseInventoryStorageComponent));
1135 array<IEntity> outItems = {};
1136 storage.GetAll(outItems);
1137 foreach (
IEntity item : outItems)
1139 storageMgr.TryRemoveItemFromStorage(item, storage);
1163 if (
data.IsDeletedWhenDeployed())
1164 m_ReplacementEntity = null;
1166 super.OnDelete(owner);
1177 if (
data.IsDeletedWhenDeployed() && m_ReplacementEntity)
1178 ent = m_ReplacementEntity;
1199 soundMan.CreateAndPlayAudioSource(ent,
SCR_SoundEvent.SOUND_DEPLOY);
1201 soundMan.CreateAndPlayAudioSource(ent,
SCR_SoundEvent.SOUND_UNDEPLOY);
1205 protected override bool RplSave(ScriptBitWriter writer)
1208 writer.WriteBool(hasData);
1219 reader.ReadBool(hasData);
void SCR_BaseDebrisSmallEntity(IEntitySource src, IEntity parent)
ArmaReforgerScripted GetGame()
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override bool RplSave(ScriptBitWriter writer)
RplComponent m_RplComponent
bool Deploy(SCR_EMobileAssemblyStatus status, int playerId=0, bool silent=false)
SCR_CharacterSoundComponentClass GetComponentData()
SCR_ESurfaceMonitoringBehaviour
Get all prefabs that have the spawner data
void VisualizeReplacementEntity(inout vector transform[4], vector direction=vector.Zero)
SCR_MultiPartDeployableItemComponentClass m_VariantContainer
void OnMonitoredSurfaceDeleted(IEntity deletedEntity)
void OnMonitoredSurfaceDamageStateChanged(SCR_HitZone damagedHitZone)
bool CheckSurfaceTilt(vector up, bool useDataFromOwnerPosition=false)
void ComputeTransform(inout vector transform[4], vector direction)
void SetPreviewState(SCR_EPreviewState state)
vector GetAdditionaPlacementOffset()
bool CheckAvailableSpace(inout vector transform[4], vector direction=vector.Zero, out LocalizedString reason=string.Empty)
bool FindRequiredElements(out string failReason, vector position=-vector.One)
vector GetAdditionaPlacementRotation()
bool GetFrontTowardPlayer()
bool FetchVariantData(int variant)
bool EvaluateFoundEntity(IEntity ent)
void DelayedDeletion()
Method used to delte this entity but after some delay to ensure that other logic can execute correctl...
bool IsUsingPartPositionAndRotation()
bool FilterTracedEntities(notnull IEntity e, vector start="0 0 0", vector dir="0 0 0")
void SetReplacmentPrefabHealthScaled(float newHealthValue)
0-1 scaled amount of health that replacement prefab will have upon deployment
void TransferDamageValues()
Method meant to be used to transfer information about health between this entity and deployed entity.
ref array< ref SCR_RequiredDeployablePart > m_aFoundElements
float m_fReplacementPrefabHealthScaled
void OnMonitoredSurfaceDismantled(bool newState, SCR_BaseDeployableInventoryItemComponent component)
void SurfaceMonitoringInit(notnull IEntity surface)
float GetReplacementPrefabHealthScaled()
bool IsSurfaceValid(IEntity surfaceEnt, vector worldPosition, vector surfaceNorm, int nodeIndex, int colliderIndex, SurfaceProperties surfaceProps, string surfaceMaterial, string colliderName)
void StopMonitoringSurface(IEntity ent, SCR_HitZone observedHitZone=null, SCR_BaseDeployableInventoryItemComponent deployableComp=null)
void ExecuteObservationBehaviour(SCR_ESurfaceMonitoringBehaviour beaviour=-1)
bool CheckIfPositionIsIndoors(inout vector transform[4])
Method that is meant to be called by clients to check if spawn position will be under something.
void ClearCache()
Clears the information about currently handled variant.
int GetCurrentlyCachedVariantId()
override void RPC_PlaySoundOnDeployBroadcast(bool deploy)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
event void _WB_OnContextMenu(IEntity owner, int id)
User has chosen any of your menu item from editor's "Component" menu which you have recently provided...
event array< ref WB_UIMenuItem > _WB_GetContextMenuItems(IEntity owner)
An opportunity to append items into editor's "Component" context menu. Do not call editor API here!
proto external EntityFlags GetFlags()
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external int Update()
proto external BaseWorld GetWorld()
proto external bool SetTransform(vector mat[4])
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external EntityPrefabData GetPrefabData()
proto external IEntity GetParent()
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
proto external IEntity GetSibling()
proto external vector VectorToParent(vector vec)
proto external IEntity GetRootParent()
Object holding reference to resource. In destructor release the resource.
Base class which all deployable inventory items inherit from.
SCR_DeployableItemState GetOnDeployedStateChanged()
void SetAuthor(int playerID)
ScriptInvokerEntity GetOnDeleted()
SCR_UIInfo GetInfo(IEntity owner=null)
static void SetMaterial(IEntity entity, ResourceName material, bool recursively=true)
ScriptInvoker GetOnDamageStateChanged(bool createNew=true)
bool m_bRemoveLoadedMagazineWhenDeleted
SCR_ESurfaceMonitoringBehaviour m_eSurfaceObservationBehaviour
bool m_bFrontTowardPlayer
IEntity GetPreviewEntity()
bool m_bDeleteThisPartOnDeployment
float IsDeletedWhenDeployed()
SCR_ESurfaceMonitoringBehaviour GetMonitoringBehaviour()
bool MustDropLoadedMagazines()
void SetPreviewState(SCR_EPreviewState newState)
const LocalizedString REASON_NO_SPACE
SCR_EPreviewState GetPreviewState()
const LocalizedString REASON_OBSTRUCTED_BY
array< ref SCR_DeployableVariantContainer > GetVariants()
LocalizedString GetSpaceValidationFailureReason(notnull IEntity collidingBody)
SCR_EPreviewState m_ePreviewState
bool IsFrontFacingPlayer()
SCR_DeployableVariantContainer GetVariantContainer(int variantId)
bool m_bRemoveAllItemsWhenDeleted
int GetPreviewVariantId()
void ~SCR_MultiPartDeployableItemComponentClass()
const LocalizedString REASON_NO_SPACE_TERRAIN
float GetIndoorsCheckHeight()
bool MustDropAllStoredItems()
ref array< ref SCR_DeployableVariantContainer > m_aVariants
float m_fIndoorsCheckHeight
void SetPreviewEntity(notnull IEntity ent, int variantId)
static bool GetTerrainBasis(vector pos, out vector result[4], BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
Instance of created debug visualizer.
UIInfo - allows to define UI elements.
EPhysicsLayerPresets
Enum is filled by C++ by data in project config PhysicsSettings.LayerPresets.
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityFlags
Various entity flags.