37 enum EGadgetAnimVariable
52 class SCR_GadgetComponent : ScriptGameComponent
54 [
Attribute(
"", UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EGadgetAnimVariable),
desc:
"Gadget anim variable",
category:
"Gadget")]
55 protected EGadgetAnimVariable m_eAnimVariable;
57 [
Attribute(
"0 0 0", UIWidgets.Coords,
desc:
"Adjusted position of prefab within equipment slot, for when items placed intto a same slot have different sizes like flashlights",
category:
"Gadget")]
58 protected vector m_vEquipmentSlotOffset;
61 protected bool m_bActivated =
false;
62 protected EGadgetMode m_iMode = EGadgetMode.ON_GROUND;
67 EGadgetAnimVariable GetAnimVariable()
69 return m_eAnimVariable;
91 IEntity parentOwner, owner;
93 BaseInventoryStorageComponent storageComp = oldSlot.GetStorage();
95 parentOwner = storageComp.GetOwner();
97 parentOwner = oldSlot.GetOwner();
101 while (owner !=
null)
104 owner = owner.GetParent();
107 if ( !SCR_ChimeraCharacter.Cast(parentOwner) )
110 else if (oldSlot ==
null)
112 IEntity parentOwner, owner;
114 BaseInventoryStorageComponent storageComp = newSlot.GetStorage();
116 parentOwner = storageComp.GetOwner();
118 parentOwner = newSlot.GetOwner();
122 while (owner !=
null)
125 owner = owner.GetParent();
129 if ( !SCR_ChimeraCharacter.Cast(parentOwner) )
138 void OnModeChanged(EGadgetMode mode, IEntity charOwner)
154 protected void ModeSwitch(EGadgetMode mode, IEntity charOwner)
159 if (mode == EGadgetMode.ON_GROUND)
168 protected void ModeClear(EGadgetMode mode)
176 ConnectToGadgetsSystem();
183 DisconnectFromGadgetsSystem();
198 if ( mode == EGadgetMode.IN_HAND || (mode == EGadgetMode.IN_SLOT &&
IsVisibleEquipped()) )
201 if (mode != EGadgetMode.IN_HAND)
205 if (slot && animAttr)
208 animAttr.GetAdditiveTransformLS(matLS);
209 matLS[3] = matLS[3] + m_vEquipmentSlotOffset;
210 slot.SetAdditiveTransformLS(matLS);
214 if (equipSlot && equipSlot.IsOccluded())
216 itemComponent.HideOwner();
221 itemComponent.ShowOwner();
226 if (mode == EGadgetMode.ON_GROUND)
227 itemComponent.ShowOwner();
229 itemComponent.HideOwner();
241 RplComponent rplComponent = RplComponent.Cast(
m_CharacterOwner.FindComponent(RplComponent));
242 if (!rplComponent || !rplComponent.IsOwner())
246 rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
247 if (rplComponent && rplComponent.IsProxy())
271 controller.SetGadgetFocus(enable);
277 IEntity GetCharacterOwner()
287 return EGadgetType.NONE;
293 EGadgetMode GetMode()
342 void Update(
float timeSlice);
346 protected void ConnectToGadgetsSystem()
348 World world =
GetOwner().GetWorld();
353 gadgetSystem.Register(
this);
357 protected void DisconnectFromGadgetsSystem()
359 World world =
GetOwner().GetWorld();
364 gadgetSystem.Unregister(
this);
368 override bool RplSave(ScriptBitWriter writer)
370 writer.WriteIntRange(m_iMode, 0, EGadgetMode.LAST-1);
376 override bool RplLoad(ScriptBitReader reader)
378 reader.ReadIntRange(m_iMode, 0, EGadgetMode.LAST-1);
386 override void OnDelete(IEntity owner)
388 DisconnectFromGadgetsSystem();
390 super.OnDelete(owner);
396 SetEventMask( owner, EntityEvent.INIT);
400 invComp.m_OnParentSlotChangedInvoker.Insert(OnParentSlotChanged);