3 [
Attribute(
"100",
UIWidgets.Auto,
desc:
"If connected charges are outside of this range then they will not detonate. -1 == unlimited",
params:
"-1 inf")]
13class SCR_DetonatorGadgetComponent : SCR_GadgetComponent
15 [
RplProp(onRplName:
"OnNumberOfConnectedChargesChanged")]
16 protected int m_iNumberOfConnectedCharges;
19 protected ref array<RplId> m_aConnectedCharges = {};
40 return m_iNumberOfConnectedCharges;
47 return m_aConnectedCharges;
55 return m_aConnectedCharges.Contains(
Replication.FindItemId(explosiveChargeComp));
63 return m_aConnectedCharges.Contains(explosiveChargeCompId);
78 if (
data.GetmaxDetonationRange() == -1)
81 if (!explosiveChargeComp)
87 vector chargePos = explosiveChargeComp.GetOwner().GetOrigin();
88 if (
vector.Distance(pos, chargePos) >
data.GetmaxDetonationRange())
106 if (
data.GetmaxDetonationRange() == -1)
109 if (!m_aConnectedCharges.Contains(explosiveChargeCompId))
113 if (!explosiveChargeComp)
128 if (m_iNumberOfConnectedCharges < 1)
147 if (!charController.CanPlayItemGesture() && charController.GetInspectEntity() !=
GetOwner())
151 RplComponent rplComponent = RplComponent.Cast(
m_User.FindComponent(RplComponent));
152 if (!rplComponent || !rplComponent.IsOwner())
156 rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
157 if (rplComponent && rplComponent.IsProxy())
193 animParams.SetAllowMovementDuringAction(
true);
194 animParams.SetKeepInHandAfterSuccess(
true);
195 animParams.SetCommandID(itemActionId);
196 animParams.SetCommandIntArg(1);
198 charController.TryUseItemOverrideParams(animParams);
239 SCR_ExplosiveTriggerComponent trigger;
242 for (
int i = m_iNumberOfConnectedCharges -1; i >= 0; i--)
245 if (!explosiveChargeComp)
247 m_aConnectedCharges.Remove(i);
260 trigger.UseTrigger();
262 m_aConnectedCharges.Remove(i);
265 m_iNumberOfConnectedCharges = m_aConnectedCharges.Count();
298 soundComp.SoundEvent(soundName);
306 if (m_aConnectedCharges.Contains(explosiveChargeCompId))
309 m_aConnectedCharges.Insert(explosiveChargeCompId);
310 m_iNumberOfConnectedCharges++;
321 int index = m_aConnectedCharges.Find(chargeCompToDisconnect);
325 m_aConnectedCharges.Remove(
index);
326 m_iNumberOfConnectedCharges--;
338 if (!m_aConnectedCharges.Contains(chargeCompToReplace))
353 if (!detonatorId.IsValid())
357 foreach (
RplId chargeCompId : m_aConnectedCharges)
359 if (!chargeCompId.IsValid())
363 if (!explosiveChargeComp)
369 m_aConnectedCharges.Clear();
370 m_iNumberOfConnectedCharges = 0;
380 SlotManagerComponent slotManagerComp = SlotManagerComponent.Cast(
GetOwner().FindComponent(SlotManagerComponent));
381 if (!slotManagerComp)
384 array<EntitySlotInfo> slots = {};
385 if (slotManagerComp.GetSlotInfos(slots) < 1)
394 wireEntity = slot.GetAttachedEntity();
412 foreach (
RplId chargeCompId : m_aConnectedCharges)
414 if (!chargeCompId.IsValid())
418 if (!explosiveChargeComp)
423 shoudShowWires =
true;
443 return EGadgetType.DETONATOR;
460 super.ModeSwitch(mode, charOwner);
461 if (mode == EGadgetMode.IN_HAND)
470 super.ModeClear(mode, charOwner);
471 if (mode == EGadgetMode.IN_HAND)
483 super.ActivateGadgetUpdate();
490 super.DeactivateGadgetUpdate();
498 super.Update(timeSlice);
509 super.EOnInit(owner);
521 super.OnPostInit(owner);
528 writer.WriteInt(m_iNumberOfConnectedCharges);
529 foreach (
RplId chargeCompId : m_aConnectedCharges)
531 writer.WriteRplId(chargeCompId);
534 return super.RplSave(writer);
540 reader.ReadInt(m_iNumberOfConnectedCharges);
541 for (
int i; i < m_iNumberOfConnectedCharges; i++)
544 reader.ReadRplId(rplIdOutput);
545 if (rplIdOutput.IsValid())
546 m_aConnectedCharges.Insert(rplIdOutput);
549 return super.RplLoad(reader);
ArmaReforgerScripted GetGame()
SCR_RplTestComponentClass m_CharacterOwner
override bool RplLoad(ScriptBitReader reader)
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override bool RplSave(ScriptBitWriter writer)
SCR_CharacterSoundComponentClass GetComponentData()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void OnNumberOfConnectedChargesChanged()
bool IsAttachedToTheDetonator(SCR_ExplosiveChargeComponent explosiveChargeComp)
void OnDeployedStateChanged(bool newState, SCR_BaseDeployableInventoryItemComponent component)
void ShowConnectedWiresForChargesInRange()
Checks if there are any charges in range and if so then will show connected wires.
void ConnectNewCharge(RplId explosiveChargeCompId, bool shouldReplicate=true)
Add new charge to the list of connected charges.
void OnAnimationEnded(IEntity item, bool successful, ItemUseParameters animParams)
void UpdateWiresVisibility(bool visible=false)
Change visibility of sloted wires.
override void ActivateGadgetUpdate()
const string TRIGGER_ANIMATION_EVENT_NAME
void DetonateExplosiveCharge()
Trigger detonation of explosive charge if there is some connected and in range.
void PlaySound(string soundName)
override void DeactivateGadgetUpdate()
array< RplId > GetConnectedCharges()
void RemoveChargeFromTheList(RplId chargeCompToDisconnect, bool shouldReplicate=true)
Remove provided charge from the listed of connected charges.
bool IsChargeInRange(vector pos, SCR_ExplosiveChargeComponent explosiveChargeComp)
const string ANIMATION_BIND_COMMAND
override bool CanBeRaised()
void ReplaceChargeFromTheList(RplId chargeCompToReplace, RplId replaceWith=RplId.Invalid())
void RemoveAllChargesFromTheList()
Remove all charges from the listed of connected charges.
float m_fVisibilityCheckDelay
int GetNumberOfConnectedCharges()
const int UPDATE_WIRES_VISIBILITY_DELAY
AnimationEventID m_iDetonatorTriggeredEventID
Get all prefabs that have the spawner data
void ToggleActive()
Toggle map light.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Adds ability to attach an object to a slot.
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external EntityFlags ClearFlags(EntityFlags flags, bool recursively=false)
Replication item identifier.
Base class which all deployable inventory items inherit from.
SCR_DeployableItemState GetOnDeployedStateChanged()
ScriptInvoker GetOnAnimationEvent()
ref OnItemUseEndedInvoker m_OnItemUseEndedInvoker
float GetmaxDetonationRange()
float m_fMaxDetonationRange
SCR_ExplosiveTriggerComponent GetTrigger()
void ReplaceDetonatorFromTheList(RplId detonatorIdToReplace, RplId replaceWith=RplId.Invalid())
Replaces connected detonator RplId with provided id which by default will be invalid.
void AskToggleGadget(SCR_GadgetComponent gadgetComp, bool state)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
static IEntity GetLocalControlledEntity()
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
event void OnAnimationEvent(AnimationEventID animEventType, AnimationEventID animUserString, int intParam, float timeFromStart, float timeToEnd)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
EntityFlags
Various entity flags.
RplRole
Role of replicated node (and all items in it) within the replication system.