3[
EntityEditorProps(
category:
"GameScripted/Editor", description:
"Slot in which entities can be placed in", color:
"255 0 0 255")]
6 [
Attribute(defvalue:
"-1",
category:
"Slot",
desc:
"Forced rotation step. 0 means unlimited rotation, -1 disables rotation.")]
7 private float m_fRotationStep;
13 float GetRotationStep()
15 return m_fRotationStep;
38 if (GetOccupant())
return null;
41 if (!
game)
return null;
46 spawnParams.TransformMode = ETransformMode.WORLD;
57 string resourceName = resource.GetResource().GetResourceName();
59 if (!baseEntity)
return null;
62 SetOccupant(baseEntity);
65 bool updateNavmesh =
true;
66 if (verticalMode != -1)
72 SCR_RefPreviewEntity.SpawnAndApplyReference(entity,
params);
73 updateNavmesh =
false;
99 float GetRotationStep()
102 if (!prefabData)
return 0;
104 return prefabData.GetRotationStep();
113 SCR_CompositionSlotManagerComponent manager = SCR_CompositionSlotManagerComponent.GetInstance();
116 return manager.GetOccupant(
this);
120 Debug.Error2(
Type().
ToString(),
"Cannot get slot occupant, SCR_CompositionSlotManagerComponent is missing in the game mode entity!");
130 SCR_CompositionSlotManagerComponent manager = SCR_CompositionSlotManagerComponent.GetInstance();
133 return manager.IsOccupied(
this);
137 Debug.Error2(
Type().
ToString(),
"Cannot check if a slot is occupied, SCR_CompositionSlotManagerComponent is missing in the game mode entity!");
147 void SetOccupant(
IEntity occupant)
149 SCR_CompositionSlotManagerComponent manager = SCR_CompositionSlotManagerComponent.GetInstance();
152 manager.SetOccupant(
this, occupant);
156 Debug.Error2(
Type().
ToString(),
"Cannot set slot occupant, SCR_CompositionSlotManagerComponent is missing in the game mode entity!");
169 const string NAME_FORMAT =
"%1_%2";
170 const int ITERATOR_DIGITS = 3;
171 const int ITERATORS_LIMIT = 1000;
176 pos[1] =
GetWorld().GetSurfaceY(pos[0], pos[2]);
177 if (entitySource.GetParent())
182 api.SetVariableValue(src, null,
"coords", pos.ToString(
false));
190 src.Get(
"angles",
angles);
191 api.SetVariableValue(src, null,
"angles",
"0 " +
angles[1] +
" 0");
195 vector pos = transform[3];
198 vector min, max, posChild;
200#ifdef SLOT_ENTITY_DEBUG
201 m_DebugShapes.Clear();
204 for (
int i, count = entitySource.GetNumChildren(); i < count; i++)
207 child = api.SourceToEntity(childSrc);
210 float posY = -
float.MAX;
211 childSrc.Get(
"angles",
angles);
212 angles[2] = _WB_GetAngle(api, pos + transform[0] * min[0], pos + transform[0] * max[0], posY);
213 angles[0] = -_WB_GetAngle(api, pos + transform[2] * min[2], pos + transform[2] * max[2], posY);
219 api.SetVariableValue(childSrc, null,
"coords", posChild.ToString(
false));
220 api.SetVariableValue(childSrc, null,
"angles",
string.Format(
"%1 %2 %3",
angles[0],
angles[1],
angles[2]));
225 float dis =
vector.Distance(posA, posB);
232 posA[1] = api.GetTerrainSurfaceY(posA[0], posA[2]);
233 posB[1] = api.GetTerrainSurfaceY(posB[0], posB[2]);
236 posY =
Math.Max(posY, posCenter[1]);
238#ifdef SLOT_ENTITY_DEBUG
244 return Math.Tan((posB[1] - posA[1]) / dis) *
Math.RAD2DEG;
249 array<ref WB_UIMenuItem> items = {
new WB_UIMenuItem(
"Snap and orient to terrain", 0) };
264 api.BeginEntityAction();
266 _WB_SnapToTerrain(entitySource);
267 _WB_OrientToTerrain(entitySource);
268 api.EndEntityAction();
274 api.BeginEntityAction();
275 api.EndEntityAction();
280#ifdef SLOT_ENTITY_DEBUG
281 protected ref array<ref Shape> m_DebugShapes = {};
288 if (!api.UndoOrRedoIsRestoring())
291 _WB_OrientToTerrain(entitySource);
ArmaReforgerScripted GetGame()
ref array< string > angles
ResourceName resourceName
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
bool IsOccupied()
Returns true, if slot is occupied.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
event array< ref WB_UIMenuItem > _WB_GetContextMenuItems()
An opportunity to append items into editor's "Entity" context menu. Do not call editor API here!
proto external WorldEditorAPI _WB_GetEditorAPI()
This returns world editor API, which is safe to use from editor events bellow.
event bool _WB_OnKeyChanged(BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
event void _WB_OnContextMenu(int id)
User has chosen any of your menu item from editor's "Entity" menu which you have recently provided in...
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external vector GetOrigin()
proto external vector GetWorldTransformAxis(int axis)
See IEntity::GetTransformAxis.
proto external void GetBounds(out vector mins, out vector maxs)
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
proto external BaseWorld GetWorld()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external EntityPrefabData GetPrefabData()
proto external string GetName()
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
proto external vector CoordToLocal(vector coord)
Object holding reference to resource. In destructor release the resource.
void RequestNavmeshRebuildEntity(IEntity entity)
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
Network packet of variables for entity placing and transformation.
static SCR_EditorPreviewParams CreateParams(vector transform[4], RplId parentID=Replication.INVALID_ID, EEditorTransformVertical verticalMode=EEditorTransformVertical.SEA, bool isUnderwater=false, SCR_EditableEntityComponent target=null, EEditableEntityInteraction targetInteraction=EEditableEntityInteraction.NONE)
Instance of created debug visualizer.
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
EEditorTransformVertical
Vertical transformation mode.
EntityFlags
Various entity flags.
RespawnSystemComponentClass GameComponentClass vector vector rotation
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native bool IsEmpty()