Skip to content
CRUSHFORMV1.1.0
GET IT ON FAB

REFERENCECOMPONENTS

UCFBreakableInstancesComponent

MODULECrushformBreakableINCLUDECFBreakableInstancesComponent.hPARENTUCFBreakableUnitsComponent

Breakable units on the Crushform units core, laid out by an owner: the ISM instances that show them, the layout they stand in, the server-side respawn and, for definitions that ask for it, the breaking from any body. Knows nothing about what the owner lays them out along. The owner lays out units and hands them to SetUnits on every node with identical data; a unit's index is its identity everywhere and never changes for the owner's lifetime. The ISMs given to SetInstanceSlots must be attached to this component at identity: FindForPrimitive walks from an overlapped ISM to its attach parent. A unit has two levels, intact (0) and broken (1); the base component replicates, predicts and plays them.

Any body: a unit whose definition sets bBreaksFromAnyBody is broken, on the authority only, by a physics body or a walking pawn that has no contact component of its own (CFBreakable::IsContactBody). A looped timer (UCFBreakableSettings::AnyBodyCheckIntervalSeconds) looks once for bodies in the box round the standing marked units; while one of them is heavy and fast enough the component ticks after physics and tests each such body's frame path against the units' bounds, and a frame with none turns the tick off. Without a marked definition, on a client and in a world that is not a game world, the component holds no timer and never ticks.

Functions

AUTHORITY · server, every machineLOCAL · this machinePURE · read only
UCFBreakableInstancesComponent* FindForPrimitive(const UPrimitiveComponent* Primitive)
C++ ONLY

The instances component that owns Primitive's instances, or nullptr.

void SetInstanceSlots(const TArray<UCFBreakablePropDefinition*>& InDefinitions, const TArray<UInstancedStaticMeshComponent*>& InInstances)
C++ ONLY

One ISM per definition slot (FCFBreakableUnit::DefinitionIndex indexes both arrays); sets each ISM's mesh.

void SetUnits(const TArray<FCFBreakableUnit>& InUnits)
C++ ONLY

Replaces the unit list and shows every unit the replicated state does not mark broken.

bool IsUnitConfirmedBroken(int32 UnitIndex) const
PUREC++ ONLY

The authority's view, as replicated.

FBox GetUnitWorldBounds(int32 UnitIndex) const
PUREC++ ONLY

World box of the unit's intact mesh.

int32 FindUnitForOverlap(const UPrimitiveComponent* Component, int32 ItemIndex) const
PUREC++ ONLY

The unit an overlap result on one of this component's ISMs refers to; INDEX_NONE if not ours.

bool TryBreakLocal(int32 UnitIndex, const FCFBreakImpact& Impact)
LOCALC++ ONLY

Breaks the unit on this node now (hides it, scatters debris, plays feedback) and waits for the authority to confirm; unconfirmed breaks are undone after PredictionConfirmTimeoutSeconds. False if already broken here. The unit's FCFBreakableUnit::LinkedUnits that still stand break with it, each as a break of its own.

void BreakOnAuthority(int32 UnitIndex, const FCFBreakImpact& Impact)
AUTHORITYC++ ONLY

Authority only: records and replicates the break and schedules the respawn. No-op for a broken unit. The unit's FCFBreakableUnit::LinkedUnits that still stand break with it, each as a break of its own.

int32 RespawnAllOnAuthority()
AUTHORITYC++ ONLY

Authority: every broken unit stands up at once, whatever CanRespawnUnit says. Returns how many stood up.

bool IsWatchingAnyBody() const
PUREC++ ONLY

Whether the any-body look is armed: this component is on the authority of a game world and has a unit whose definition breaks from any body.

bool IsAnyBodyTickOn() const
PUREC++ ONLY

Whether the component ticks now, which it does only while the last look found a body able to break a unit.

Functions

  • FindUnitsForPrimitiveThe units component Primitive stands for a unit of, and that unit's index: through ICFBreakableUnitPart on the primitive, else the first attach parent that knows the primitive. nullptr when none does.
  • ApplyHitResultOnAuthorityAuthority: applies an outside hit on a primitive to the unit it belongs to.
  • PredictHitResultAny machine: the prediction twin of ApplyHitResultOnAuthority.
  • ApplyHitOnAuthorityAuthority: raises the unit to the level its definition gives this hit (HitResponses), replicates it and plays it.
  • PredictHitAny machine: shows the hit's level now and waits for the authority; undone after PredictionConfirmTimeoutSeconds.
  • GetUnitCountHow many units the owner laid out.
  • GetMaxLevelThe highest level a unit can reach, as given to InitUnits; a unit is intact at 0.
  • GetUnitLevelThe level this machine shows: the authority's, or a prediction ahead of it.
  • GetConfirmedUnitLevelThe level the authority confirmed in the current generation.
  • IsUnitIntactTrue for a valid index whose shown level is 0; false for an invalid index.
  • PredictUnitLevelShows StoredImpact's level now, ahead of the authority, with the units GatherUnitsRaisedWith adds.
  • RaiseUnitLevelOnAuthorityAuthority: confirms Level for the unit and the units GatherUnitsRaisedWith adds, replicates it, plays it here and tells OnUnitsRaisedOnAuthority.
  • CancelPredictionRolls the unit's prediction back to the confirmed level, and with it the predictions of the units GatherUnitsRaisedWith adds.
  • ApplyGenerationAny machine: the first generation this component learns (from here or from its replicated levels) is taken whatever it is; after that a newer one puts every unit back to intact here at once, and an equal or older one is ignored.
  • FindUnitForPrimitiveThe unit the primitive (and the instance of it, ItemIndex) stands for, or INDEX_NONE.

Events