Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WorldEntityDelegateEditorComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3{
4 static override array<typename> Requires(IEntityComponentSource src)
5 {
7 }
8};
9
14{
15 [Attribute(params: "et")]
17
19 protected SCR_EditableWorldEntityComponent m_Delegate;
21 protected bool m_bHasDelegate;
23
29 {
30 RplComponent rplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
31 if (rplComponent)
32 {
33 RplId rplId = rplComponent.Id();
35 }
36 else
37 {
38 // Could be a door. They are not necessarily replicated.
40 if (doorComponent)
42 }
43 }
44
45 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
46 protected void PerformFirstActionServer(RplId rplId)
47 {
50 }
51 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
57
58 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
59 protected void PerformFirstActionBroadcast(RplId rplId)
60 {
61 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(rplId));
62 if (rplComponent == null)
63 return;
64 IEntity owner = rplComponent.GetEntity();
66 ScriptedUserAction action = ScriptedUserAction.Cast(actionsManager.GetFirstAction());
67 action.PerformAction(owner, GetOwner());
68 }
69 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
71 {
72 IEntity owner = GetGame().GetWorld().FindEntityByID(entId);
73 if (owner == null)
74 return;
76 ScriptedUserAction action = ScriptedUserAction.Cast(actionsManager.GetFirstAction());
77 action.PerformAction(owner, GetOwner());
78 }
79
80 override protected void EOnFrame(IEntity owner, float timeSlice)
81 {
82 IEntity traceEntity = m_MenuLayout.GetTraceEntity();
83
84 if (traceEntity != m_TraceEntity)
85 {
86 //--- Check if world entity deserves a delegate
87 m_bHasDelegate = false;
88 if (traceEntity)
89 {
91 if (!editableEntity || !editableEntity.HasEntityState(EEditableEntityState.INTERACTIVE))
92 {
94 if (actionsManager && actionsManager.GetActionsCount() == 1)
95 {
96 ScriptedUserAction action = ScriptedUserAction.Cast(actionsManager.GetFirstAction());
97 m_bHasDelegate = action && action.CanBePerformed(GetManager());
98
100 {
101 //--- Get action offset
102 array<UserActionContext> contexts = {};
103 actionsManager.GetContextList(contexts);
104 vector transform[4];
105 contexts[0].GetTransformationModel(transform);
106 m_vLocalOffset = transform[3];
107 }
108 }
109 }
110 }
111
112 m_TraceEntity = traceEntity;
113
114 if (m_bHasDelegate)
115 {
116 m_Delegate.RestoreParentEntity();
117 m_Delegate.SetOwnerScripted(GenericEntity.Cast(m_TraceEntity));
118 }
119 else
120 {
121 m_Delegate.RemoveParentEntity();
122 m_Delegate.SetOwnerScripted(null);
123 }
124 }
125
126 //--- Update position to bounding center
128 {
129 vector pos = m_TraceEntity.CoordToParent(m_vLocalOffset);
130 m_Delegate.GetOwner().SetOrigin(pos);
131
132 //-- Set delegate entity as hovered when just hovering over mesh
133 if (traceEntity == m_TraceEntity)
134 {
136 hoverFilter.SetEntityUnderCursor(m_Delegate, true);
137 }
138 }
139 }
140 override protected void EOnEditorActivate()
141 {
142 IEntity delegateEntity = GetGame().SpawnEntityPrefab(Resource.Load(m_EntityPrefab));
143 m_Delegate = SCR_EditableWorldEntityComponent.Cast(SCR_EditableEntityComponent.GetEditableEntity(delegateEntity));
144 if (!m_Delegate)
145 {
146 Print(string.Format("Cannot create world entity delegate from prefab @\"%1\", it doesn't have SCR_EditableWorldEntityComponent!"), LogLevel.WARNING);
147 RplComponent.DeleteRplEntity(delegateEntity, false);
148 return;
149 }
150
153 }
154 override protected void EOnEditorDeactivate()
155 {
156 if (m_Delegate)
157 m_Delegate.Delete();
159 }
160};
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
proto external bool CanBePerformed(IEntity user)
Can this action be performed by the user?
proto external int ClearEventMask(notnull IEntity owner, int mask)
proto external int SetEventMask(notnull IEntity owner, int mask)
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external EntityID GetID()
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Replication item identifier.
Definition RplId.c:14
void SCR_BaseEditorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_EditorManagerEntity GetManager()
bool HasEntityState(EEditableEntityState state)
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
void SetEntityUnderCursor(SCR_EditableEntityComponent entity, bool isDelegate=false)
proto external GenericEntity GetOwner()
Get owner entity.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EEditableEntityState
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14