Components and Interfaces
Cube Weapon connects a PlayerController, Character and runtime actor through three components. Their source headers are under Public/Components; interface headers are under Public/Interfaces.
UAC_WeaponNetComp
Add this replicated component to the PlayerController. It registers with the subsystem during component initialization, owns one replicated WorkingBuild and routes requests directly on authority or through reliable server RPCs.
| Blueprint utility | Purpose |
|---|---|
SetComponentActive(bool bNewActive) | Sets component active state |
AddActorToRepRegistry(AWeaponActorBase* Actor) | Adds a valid actor to the registry workflow |
RemoveActorFromRepRegistry(AWeaponActorBase* Actor) | Removes a registered actor |
SetLastValidatedBuildID(FGuid InstanceGuid) | Stores a valid GUID; does not validate a build |
GetLastValidatedBuildID() | Returns last validated GUID |
Native accessors GetWorkingBuildCopy, GetWorkingBuildRef and MutateWorkingBuild support the internal build pipeline. The public route methods QueueBuildOperation, QueueAcquireOperation, QueueEquipOperation and QueueWeaponInteractOperation are reflected but not declared BlueprintCallable. Submit through the subsystem's Blueprint API.
Bind OnWorkingBuildModified, OnWorkingBuildReplicated, OnWorkingBuildCreated, OnBuildValidatedCallback and FetchBuildCallback for their specific stages. See Replication and Events.
UAC_WeaponCharComp
Add this replicated component to an ACharacter. It manages assignment records, active weapon selection, actor reference caching and draw/holster attachment transitions. It does not implement ranged firing itself.
| Member or function | Purpose |
|---|---|
AssignedWeaponActors | Replicated array of source/current slots and actor GUIDs |
ActualUsedWeapon | Replicated active actor GUID |
WeaponRefCache | Local GUID-to-actor cache; not a replicated map |
SetComponentActive | Component activation |
NotifyWeaponAttach(FGuid WeaponGuid) | Animation-driven attachment notification |
NotifyHolsterFinished() | Completes holster transition and advances pending draw |
OnUsedWeaponUpdate(OldWeapon, NewWeapon) | Active weapon change event |
Native methods include AddAssignedWeapon, RemoveAssignedWeapon, UseWeapon, AssignWeaponToSlot, ResolveWeaponAttachment, HandleDrawWeapon and HandleHolsterWeapon. For normal Blueprint gameplay use the corresponding operation helpers and animation notifications.
GetBuildData, AddOrUpdateBuildData and RemoveBuildData are BlueprintCallable but currently only check GUID validity. They do not read/write build records; GetBuildData leaves OutBuild unchanged. Use the fetch operation for registry retrieval.
Attachment casts the owner to ACharacter, requires I_WeaponPawn, and uses GetCharMesh. A generic Pawn does not gain this behavior by adding the component alone.
UAC_WeaponGameplayComp
AWeaponActorBase creates this replicated component as a default subobject. It owns the replicated state-tag Fast Array and the implemented ranged fire loop.
Blueprint functions SetComponentActive, AddWeaponState, RemoveWeaponState and UpdateWeaponState expose state mutation. Native FireWeapon, ReloadWeapon and TriggerFiremode are invoked by the routed interaction workflow. Reliable multicasts are MRPC_FireWeapon and MRPC_ReloadWeapon.
OnWeaponFired(AWeaponActorBase* WeaponRef) broadcasts when the fire loop consumes a shot. Projectile spawning, muzzle flash, audio and recoil remain placeholders in that shot function. Bind project behavior deliberately; this delegate does not prove that damage was applied.
ActualAmmo is an integer initialized to 100 and is not marked Replicated or BlueprintReadOnly/BlueprintReadWrite. Reload sets it back to 100; there is no complete magazine/reserve model here.
I_WeaponController
Implemented by your PlayerController. All listed functions are BlueprintNativeEvent/BlueprintCallable.
| Function | Contract |
|---|---|
GetWeaponNetComp() | Return the controller's Net component |
AcquireWeaponExternal(const ECustomWeaponType& WeaponType, AActor* Owner) | Supply an externally allocated actor |
WeaponAcquiredCallback(APawn* OwnerPawn, FGuid WeaponGuid) | Owning-client acquisition handoff from actor OnRep_Owner |
WeaponUnequipCallback(const EWeaponAllocationType& AllocationType, const ECustomWeaponType& WeaponType, AActor* WeaponRef) | Destroy, detach, retain or return actor to pool |
BuildCreatedCallback(FGuid BuildID) | Declared; not called by the current create-build handler |
Acquisition callback availability differs between authority and clients, and depends on the GUID already being valid at OnRep_Owner. See Implementation Limits.
I_WeaponPawn
Implemented by your Character. Provide GetCharMesh, PlayWeaponDrawAnimation(WeaponGuid), PlayWeaponHolsterAnimation(WeaponGuid), and GetWeaponGuidByHolsterIndex(HolsterIndex). The returned mesh is the attachment provider; animations and holster-index mapping belong to your project.
Animation Interfaces
I_WeaponAnim::GetWeaponSocketTransform(SocketName, TransformSpace, SocketTransform) is implemented by AWeaponActorBase for weapon sockets. SocketTransform is an output reference and TransformSpace is ERelativeTransformSpace.
I_WeaponCharAnim currently declares no methods. Do not expect a supplied character animation API from this empty interface. Internal data/state listener interfaces are used by Fast Array callbacks and live in the module's Private folder.