Zum Hauptinhalt springen

Loading and Runtime Builder

UWeaponDataManager handles ID lookup and asynchronous loading. UWeaponRuntimeBuilder handles validation, local mesh components, attachment resolution and calculated statistics. Both derive from UObject and are created by the subsystem; their native manager functions are not BlueprintCallable nodes.

Source: Public/Manager/WeaponDataManager.h, Public/Manager/WeaponRuntimeBuilder.h and their Private implementations.

UWeaponDataManager​

Initialize loads the configured database assets, then reads their Tables into type-specific soft-reference caches and WeaponDBTypeLookup. Master/part assets load when requested and are retained in loaded-asset caches.

Native functionPurpose
InitializeBegin configured database loading
GetDBType(ID)Resolve registered asset type
RequestWeaponAsset(AssetID, Callback)Resolve master/part for runtime assembly
RequestBuildAsset(AssetID, Request, Callback)Load one asset for a build edit
RequestBuildAssets(Build, Request, Callback)Load master and part references for import/validation
GetLoadedWeaponMaster / GetLoadedWeaponPartQuery already loaded definitions
GetWeaponLookupTablesNative cache access
DumpWeaponDBLookup / DumpWeaponLookupTablesLog diagnostics

Callbacks distinguish a single asset from a batch plus its original request. FWeaponLookupTables separates soft cache entries from loaded object pointers. Initialization completion currently has an empty handler and no Blueprint-ready event.

A soft database entry defers loading its weapon definition, but the definition can hold hard mesh, statistics and modifier references. Loading it may load those dependencies too. The code does not establish a universal unload/eviction or memory-budget guarantee.

UWeaponRuntimeBuilder​

Native functionPurpose
Initialize(Subsystem)Retain the subsystem's data manager
InitializeWeapon(InActor, Build)Clear old runtime components/entries; add master and part entries
AssignComponent(InActor, InstanceID)Create local runtime record and request its asset
ResetComponent(InActor, InstanceID)Clear mesh and return component to free pool
ValidateBuild(Build, LoadedAssets)Produce FBuildValidationResult
ValidateParentCompatibility(...)Find socket provider and test its tags
BuildWeaponStats(InActor, BuildID, OutStats)Compute stats from registered build and loaded definitions
PassesFilterTags(Filter, EffectiveTags)Exact required/blocked tag checks
ApplyModifier / NormalizeStatsApply supported fields and limits

InitializeWeapon returning true confirms the initial entry setup, not completion of asynchronous visual assembly or full build validation.

Visual Assembly​

Equip → InitializeWeapon → master/part Fast Array entries
↓
AssignComponent → asynchronous asset resolution
↓
Take free mesh component → assign mesh → collect provider sockets
↓
Refresh parent links → attach child components → BuildComplete

Each actor preallocates static/skeletal components from settings. Components begin hidden with NoCollision, then the builder assigns a mesh and makes them visible. Reset clears the mesh, hides it, attaches it to the actor root and returns it to the corresponding free list.

When every runtime entry has a valid local component, BuildComplete finalizes the actor's build ID and calculates stats on authority. Clients reconstruct local components from replicated entries.

Parent Resolution​

InitializeWeapon copies the build's PartID and InstalledSlotName into actor entries. It does not copy the build's ParentPartID into those entries. Runtime parents are found by searching AvailableSockets for the first provider containing SocketName.

Avoid identical socket names across competing providers when unambiguous parent selection matters. The build validator has a declared-parent preference and fallback, while runtime assembly uses socket-provider lookup. A successful build validation is not a guarantee that ambiguous socket names resolve to the intended parent at runtime.

Weapon Actors​

AWeaponActorBase is abstract and creates GameplayComponent, a scene root and mesh component pools. Internal allocation uses its Range, Melee or Throwable subclasses. Authority initializes ActorNetGuid and registers the actor; client RepNotify also performs registration.

Blueprint-accessible actor functions include GetWeaponData, GetBuildID and OverrideWeaponType. Runtime mutations AddWeaponEntry, RemoveWeaponEntry, ClearWeaponRuntimeData, SetTemporaryBuildCache and BuildComplete are native implementation methods. OverrideWeaponType does not reconstruct the constructor's component pools.

The actor stores WeaponRuntimeData, ActiveComponentMap, AvailableSockets, RuntimeStats and the build/actor GUIDs. These members collectively represent runtime assembly; there is no separate FRuntimeWeaponBuild structure.