1[
EntityEditorProps(
category:
"GameScripted/Editor", description:
"Image generator for pecific subset of entities", color:
"255 0 0 255")]
18 protected ref array<EEditableEntityLabel>
m_Labels;
23 [
Attribute(
"0",
desc:
"Order in which the position will be evaluated.\nHigher numbers are processed first.",
category:
"Configuration")]
32 [
Attribute(
desc:
"Position the entity by center of its bounding box, not by center of the prefab.",
category:
"Configuration")]
35 [
Attribute(
desc:
"When enabled, the prefab must fit into camera view. When that's not the game, another camera tied to the position will be searched for.",
category:
"Configuration")]
38 [
Attribute(
desc:
"Names of camera entities belonging to this position. Multiple positions could refer to the same camera.",
category:
"Configuration")]
87 [
Attribute(defvalue:
"Clear", uiwidget:
UIWidgets.ComboBox,
category:
"Environment", enums: { ParamEnum(
"Clear",
"Clear"), ParamEnum(
"Cloudy",
"Cloudy"), ParamEnum(
"Overcast",
"Overcast"), ParamEnum(
"Rainy",
"Rainy") },
desc:
"Area shape")]
88 private string m_sWeatherState;
90 [
Attribute(
desc:
"Default pose that should be used if no faction specific pose is defined",
category:
"Animation - Character")]
93 [
Attribute(
desc:
"List of pose for each faction. Use default pose if selected character faction pose is not defined",
category:
"Animation - Character")]
97 protected ref array<SCR_CameraBase> m_aCameras = {};
98 protected SCR_EditorImagePositionEntity m_Parent;
99 protected ref SCR_SortedArray<SCR_EditorImagePositionEntity> m_aSubPositions =
new SCR_SortedArray<SCR_EditorImagePositionEntity>();
101 protected ref array<IEntity> m_aCurrentNearbyEntities = {};
102 protected ref array<IEntity> m_aOriginalNearbyEntities = {};
103 protected string m_sNewWeaponMesh;
104 protected string m_sCurrentWeaponMesh;
123 bool IsSuitable(array<EEditableEntityLabel> labels)
128 if (!labels.Contains(label))
139 SCR_EditorImagePositionEntity FindSuitableSubPosition(SCR_SortedArray<SCR_EditorImagePositionEntity> subPositions, array<EEditableEntityLabel> labels)
141 for (
int i = subPositions.Count() - 1; i >= 0; i--)
143 if (subPositions.GetValue(i).IsSuitable(labels))
144 return subPositions.GetValue(i);
153 bool ActivatePosition(ResourceName prefab)
161 m_Entity =
GetGame().SpawnEntityPrefab(Resource.Load(prefab), GetWorld(), spawnParams);
164 Debug.Error2(
Type().
ToString(),
string.Format(
"Error when creating prefab '%1'!", prefab));
169 SCR_SlotCompositionComponent composition = SCR_SlotCompositionComponent.Cast(
m_Entity.FindComponent(SCR_SlotCompositionComponent));
172 SCR_EditableEntityComponent editableComposition = SCR_EditableEntityComponent.GetEditableEntity(
m_Entity);
178 ChimeraWorld world = GetWorld();
179 TimeAndWeatherManagerEntity envManager = world.GetTimeAndWeatherManager();
185 envManager.TimeToHoursMinutesSeconds(
m_fTime * 24, h, m, s);
186 envManager.SetHoursMinutesSeconds(h, m, s,
false);
190 BaseWeatherStateTransitionManager weatherTransitionManager = envManager.GetTransitionManager();
191 if (weatherTransitionManager)
193 WeatherStateTransitionNode transitionNode = weatherTransitionManager.CreateStateTransition(m_sWeatherState, 0, 1);
194 transitionNode.SetLooping(
true);
196 weatherTransitionManager.EnqueueStateTransition(transitionNode,
false);
197 weatherTransitionManager.RequestStateTransitionImmediately(transitionNode);
218 GetGame().GetCallqueue().CallLater(ActivateGroupPosition, 1000,
false, group, spawnParams);
222 SCR_EditableCharacterComponent character = SCR_EditableCharacterComponent.Cast(
m_Entity.FindComponent(SCR_EditableCharacterComponent));
224 ActivateCharacterPosition(prefab);
230 SCR_Global.GetWorldBoundsWithChildren(
m_Entity, min, max);
231 vector bCenter = min + (max - min) * 0.5;
240 Physics phys =
m_Entity.GetPhysics();
242 phys.SetActive(
true);
246 SCR_CameraBase camera;
250 SCR_Global.GetWorldBoundsWithChildren(
m_Entity, min, max);
251 array<vector> corners = {
253 Vector(min[0], min[1], max[2]),
254 Vector(min[0], max[1], min[2]),
255 Vector(max[0], min[1], min[2]),
256 Vector(max[0], max[1], min[2]),
257 Vector(max[0], min[1], max[2]),
258 Vector(min[0], max[1], max[2]),
262 foreach (SCR_CameraBase cameraCandidate : m_aCameras)
264 bool isInView =
true;
265 for (
int i = 0; i < 8; i++)
267 if (!cameraCandidate.IsInView(corners[i]))
275 camera = cameraCandidate;
282 camera = m_aCameras[0];
287 CameraManager cameraManager =
GetGame().GetCameraManager();
289 cameraManager.SetCamera(camera);
292 Debug.Error2(
Type().
ToString(),
string.Format(
"No camera which would fit '%1' found on position '%2'!", prefab, GetPositionName()));
299 void DeactivatePosition()
301 UpdateNearbyEntities();
302 foreach (
IEntity entity : m_aCurrentNearbyEntities)
304 if (!m_aOriginalNearbyEntities.Contains(entity))
309 protected void AddSubPosition(SCR_EditorImagePositionEntity subPosition)
311 m_aSubPositions.Insert(subPosition.GetPriority(), subPosition);
313 protected void UpdateNearbyEntities()
315 m_aCurrentNearbyEntities.Clear();
320 m_aCurrentNearbyEntities.Insert(e);
323 protected string GetPositionName()
334 event void EOnImagePositonActivate(
IEntity entity)
340 if (SCR_Global.IsEditMode(
this))
343 SCR_EditorImageGeneratorEntity manager = SCR_EditorImageGeneratorEntity.GetInstance();
346 Debug.Error2(
Type().
ToString(),
"SCR_EditorImageGeneratorEntity is missing in the world!");
353 m_Parent.AddSubPosition(
this);
358 SCR_CameraBase camera;
363 camera = SCR_CameraBase.Cast(GetWorld().FindEntityByName(
m_aCameraNames[i]));
364 if (camera && !m_aCameras.Contains(camera))
365 m_aCameras.Insert(camera);
372 camera = SCR_CameraBase.Cast(child);
373 if (camera && !m_aCameras.Contains(camera))
374 m_aCameras.Insert(camera);
379 if (m_aCameras.IsEmpty())
381 Print(
"SCR_EditorImagePositionEntity is missing child entity of type SCR_CameraBase!",
LogLevel.WARNING);
385 manager.AddPosition(
this);
389 UpdateNearbyEntities();
390 m_aOriginalNearbyEntities.Copy(m_aCurrentNearbyEntities);
397 void SCR_EditorImagePositionEntity(IEntitySource src,
IEntity parent)
399 m_Parent = SCR_EditorImagePositionEntity.Cast(parent);
401 if (SCR_Global.IsEditMode(
this))
406 if (!resource.IsValid())
412 SetObject(resource.GetResource().ToVObject(),
"");
423 void ~SCR_EditorImagePositionEntity()
425 WorldEditorAPI api = _WB_GetEditorAPI();
426 if (api && api.IsEntitySelected(api.EntityToSource(
this)))
427 SCR_EditorImageGeneratorEntity.AddSelectedPosition(
this);
431 override int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
433 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
437 override void _WB_AfterWorldUpdate(
float timeSlice)
443 for (
int i = 0, count =
m_Labels.Count(); i < count; i++)
461 DebugTextWorldSpace.Create(GetWorld(), name,
DebugTextFlags.CENTER |
DebugTextFlags.FACE_CAMERA |
DebugTextFlags.ONCE, pos[0], pos[1], pos[2], fontSize, Color.WHITE,
ARGBF(1, 0.5, 0, 1));
469 protected void ActivateCharacterPosition(ResourceName prefab)
472 SCR_EditorImagePositionCharacterPose pose = CurrentPose(
m_Entity);
474 Resource characterResource = Resource.Load(prefab);
475 ResourceName weaponIK = CharacterWeaponIK(characterResource, pose);
480 if (forceWeaponType >= 0)
482 InventoryStorageManagerComponent inventoryStorage = InventoryStorageManagerComponent.Cast(
m_Entity.FindComponent(InventoryStorageManagerComponent));
483 if (inventoryStorage)
485 array<IEntity> items = {};
486 for (
int i = inventoryStorage.GetItems(items) - 1; i >= 0; i--)
488 BaseWeaponComponent weapon = BaseWeaponComponent.Cast(items[i].FindComponent(BaseWeaponComponent));
492 if (weapon.GetWeaponType() == forceWeaponType)
494 m_sNewWeaponMesh = items[i].GetVObject().GetResourceName();
500 BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(
m_Entity.FindComponent(BaseWeaponManagerComponent));
503 BaseWeaponComponent currentWeapon = weaponManager.GetCurrentWeapon();
505 m_sCurrentWeaponMesh = currentWeapon.GetOwner().
GetVObject().GetResourceName();
511 CloneCharacter(
m_Entity, transform);
518 protected SCR_EditorImagePositionCharacterPose CurrentPose(notnull
IEntity entity, SCR_EditorImagePositionEntity
position =
this)
524 SCR_EditableCharacterComponent editable = SCR_EditableCharacterComponent.Cast(entity.FindComponent(SCR_EditableCharacterComponent));
527 Print(
"No editable entity for: " + entity.GetName(),
LogLevel.WARNING);
531 SCR_UIInfo uiInfoBase = editable.GetInfo();
537 SCR_EditableEntityUIInfo uiInfo = SCR_EditableEntityUIInfo.Cast(editable.GetInfo());
540 Print(
"No uiinfo for: " + entity.GetName(),
LogLevel.WARNING);
547 foreach (SCR_EditorImagePositionCharacterPose pose :
position.m_aFactionPoses)
559 protected void SetPose(
IEntity entity, notnull SCR_EditorImagePositionCharacterPose pose, ResourceName armsIK)
561 ResourceName poseGraph = pose.GetPoseGraph();
562 ResourceName poseInstance = pose.GetPosesInstance();
563 string startNode = pose.GetStartNode();
565 if (poseGraph.IsEmpty() && poseInstance.IsEmpty() && startNode.IsEmpty())
568 PreviewAnimationComponent animComponent = PreviewAnimationComponent.Cast(entity.
FindComponent(PreviewAnimationComponent));
569 animComponent.SetGraphResource(entity, poseGraph, poseInstance, startNode);
575 int poseVar = animComponent.BindIntVariable(pose.GetPosVar());
578 Debug.Error2(
Type().
ToString(),
string.Format(
"Unable to set character pose at positon '%1'!", GetPositionName()));
583 animComponent.SetIntVariable(poseVar, pose.GetPosId());
586 int armIkVar = pose.BindAnimValueInteger(animComponent,
ANIM_ARM_IK);
589 animComponent.SetIntVariable(armIkVar, pose.GetArmIK());
590 animComponent.SetHandsIKPose(entity, armsIK);
599 protected ResourceName CharacterWeaponIK(Resource characterResource, SCR_EditorImagePositionCharacterPose pose)
603 array<ref array<IEntityComponentSource>> weaponSlotComponents = {};
604 array<string> componentTypeArray = {
"CharacterWeaponSlotComponent" };
605 int weaponSlotCount = SCR_BaseContainerTools.FindComponentSources(characterResource, componentTypeArray, weaponSlotComponents);
607 array<IEntityComponentSource> weaponSlotComponentSources = weaponSlotComponents.Get(0);
608 if (!weaponSlotComponentSources)
609 return ResourceName.Empty;
611 foreach (IEntityComponentSource weaponSlotComponent : weaponSlotComponentSources)
613 ResourceName weaponPrefab;
614 if (!weaponSlotComponent.Get(
"WeaponTemplate", weaponPrefab))
615 return ResourceName.Empty;
620 Resource resource = Resource.Load(weaponPrefab);
621 if (!resource.IsValid())
624 IEntitySource weaponSource = SCR_BaseContainerTools.FindEntitySource(resource);
629 IEntityComponentSource weaponComponentSource = SCR_BaseContainerTools.FindComponentSource(resource, WeaponComponent);
630 if (!weaponComponentSource)
635 if (forcedWeaponType != -1)
638 weaponComponentSource.Get(
"WeaponType", weaponType);
645 IEntityComponentSource weaponEntitySource = SCR_ComponentHelper.GetInventoryItemComponentSource(weaponSource);
647 BaseContainer attributesContainer = weaponEntitySource.GetObject(
"Attributes");
649 BaseContainer animAttributes = attributesContainer.GetObject(
"ItemAnimationAttributes");
651 ResourceName animIkResourceName;
652 animAttributes.Get(
"AnimationIKPose", animIkResourceName);
653 return animIkResourceName;
656 return ResourceName.Empty;
660 protected void CloneCharacter(out
IEntity character, vector transform[4])
662 InventoryItemComponent inventoryComponent = InventoryItemComponent.Cast(character.FindComponent(InventoryItemComponent));
663 if (!inventoryComponent)
667 IEntity clone = inventoryComponent.CreatePreviewEntity(GetWorld(), GetWorld().GetCurrentCameraId());
672 if (m_sNewWeaponMesh != m_sCurrentWeaponMesh)
674 IEntity currentWeapon, newWeapon;
675 TNodeId currentPivot, newPivot;
676 vector currentLocalTransform[4], newLocalTransform[4];
684 if (mesh.GetResourceName() == m_sCurrentWeaponMesh)
686 currentWeapon = child;
690 if (mesh.GetResourceName() == m_sNewWeaponMesh)
700 clone.
AddChild(newWeapon, currentPivot);
703 clone.
AddChild(currentWeapon, newPivot);
707 SCR_EntityHelper.DeleteEntityAndChildren(character);
723 array<AIAgent> agents = {};
724 int agentCount = group.GetAgents(agents);
726 if (agentCount > m_aSubPositions.Count())
732 m_Entity =
GetGame().SpawnEntity(GenericEntity, GetWorld(), spawnParams);
735 SCR_SortedArray<SCR_EditorImagePositionEntity> subPositions =
new SCR_SortedArray<SCR_EditorImagePositionEntity>();
736 subPositions.CopyFrom(m_aSubPositions);
737 SCR_EditorImagePositionEntity subPosition;
740 for (
int i = 0; i < agentCount; i++)
742 member = agents[i].GetControlledEntity();
745 SCR_EditableEntityComponent editableMember = SCR_EditableEntityComponent.GetEditableEntity(member);
746 SCR_EditableEntityUIInfo info = SCR_EditableEntityUIInfo.Cast(editableMember.
GetInfo());
747 array<EEditableEntityLabel> memberLabels = {};
752 subPosition = FindSuitableSubPosition(subPositions, memberLabels);
756 SCR_EditorImagePositionCharacterPose pose = CurrentPose(member, subPosition);
758 Resource characterResource = BaseContainerTools.CreateContainerFromInstance(member);
759 ResourceName weaponIK = CharacterWeaponIK(characterResource, pose);
762 subPositions.RemoveValues(subPosition);
763 subPosition.GetTransform(transform);
765 CloneCharacter(member, transform);
767 subPosition.SetPose(member, pose, weaponIK);
768 subPosition.EOnImagePositonActivate(member);
772 PrintFormat(
"Cannot capture group member @\"%1\"! Unable to find suitable sub-position for %1!", member.
GetPrefabData().GetPrefabName(), level:
LogLevel.WARNING);
776 SCR_EntityHelper.DeleteEntityAndChildren(group);
GetTransformResult JsonApiStruct GetTransform(notnull const BlenderRestAPI connection, string object_name)
string FactionKey
Faction unique identifier type.
ArmaReforgerScripted GetGame()
void SCR_AIGroup(IEntitySource src, IEntity parent)
enum EAITargetInfoCategory m_Entity
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
ref array< ref SCR_EditorImagePositionCharacterPose > m_aFactionPoses
ResourceName m_PreviewMesh
ref array< string > m_aCameraNames
ResourceName m_sPosesGraph
ref SCR_EditorImagePositionCharacterPose m_DefaultPose
ref array< EEditableEntityLabel > m_Labels
ResourceName m_sArmIKResource
bool m_bUseBoundingCenter
ResourceName m_sPosesInstance
EWeaponType m_eForceWeaponType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void GetChildren(out array< SCR_ScenarioFrameworkLayerBase > children)
enum EVehicleType IEntity
proto external Managed FindComponent(typename typeName)
proto external bool SetLocalTransform(vector mat[4])
See IEntity::SetTransform. Returns false, if there is no change in transformation.
proto external int AddChild(notnull IEntity child, TNodeId pivot, EAddChildFlags flags=EAddChildFlags.AUTO_TRANSFORM)
Add Entity to hierarchy. Pivot is pivot index, or -1 for center of parent.
proto external IEntity GetChildren()
proto external bool SetTransform(vector mat[4])
proto external EntityPrefabData GetPrefabData()
proto external TNodeId GetPivot()
Returns pivot ID from hierarchy component.
proto external IEntity GetSibling()
proto external VObject GetVObject()
Returns visual object set to this Entity. No reference is added.
proto external void GetLocalTransform(out vector mat[])
See IEntity::GetTransform.
void SetMemberSpawnDelay(int memberSpawnDelay)
void SetTransformWithChildren(vector transform[4])
SCR_UIInfo GetInfo(IEntity owner=null)
FactionKey GetFactionKey()
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
EWeaponType GetForceWeaponType()
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
SCR_EditorImagePositionEntityClass ANIM_TIME_STEP
EntityEvent
Various entity events.
int TNodeId
Node global id is a hash of name of the node.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native vector Vector(float x, float y, float z)
proto native bool IsEmpty()
func QueryEntitiesCallback
proto int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.