Ninja Bear Studio Plugins Help

Components and Extensions

The Combat System has multiple parts represented by interfaces. This design allows developers to replace parts of the system, by replacing components with their own functionality.

The only component that cannot be swapped by interface level is the Combat Component, since it is the backbone of the Combat System. Still, it provides many extension points as virtual/overridable functions.

The following table shows all components that can be swapped on interface level.

Interface

Implementation

Factory Method

ComboManagerInterface

ComboManagerComponent

CreateComboManagerComponent

DamageManagerInterface

Base Combat Manager

CreateDamageManagerComponent

DefenseManagerInterface

Base Combat Manager

CreateDefenseManagerComponent

DissolveManagerInterface

DissolveComponent

GetAndCacheDissolveManager

MotionWarpingInterface

MotionWarpingComponent

CreateMotionWarpingComponent

MovementManagerInterface

CharacterMovementComponent

N/A

PhysicalAnimationInterface

PhysicalAnimationComponent

CreatePhysicalAnimationComponent

TargetManagerInterface

Base Combat Manager

CreateTargetManagerComponent

WeaponManagerInterface

WeaponManagerComponent

GetAndCacheWeaponManager

The Combat Manager Component

The Combat Manager Component is the main component in the system. It does not have its own interface, since it's always expected to be present in a combatant (including potential subclasses).

This component is the default implementation of other interfaces (see table above) and will create additional components as needed. You can always override this behavior by providing your own components implementing the appropriate interfaces. In that case, the Combat Manager will find these instances and use them as needed.

The Combat Manager also hosts useful delegates, both from the required interfaces and some of its own. They should be useful when defining your own gameplay features.

Delegate

Source

Purpose

OnAttackStarted

Combat Manager

Informs that an attack is starting. Provides the Ability Tags and the locked target (if any).

OnCombatTargetChanged

Target Manager

Notifies a new target obtained or a target lost.

OnStaggerStateChanged

Damage Manager

Notifies changes in the Staggered state.

OnDamageReceived

Damage Manager

Notifies incoming damage.

OnOwnerFinishedDying

Damage Manager

Notifies the death of a combatant.

OnBlockingStateChanged

Defense Manager

Notifies changes in the Blocking state.

OnInvulnerabilityStateChanged

Defense Manager

Notifies changes in the Invulnerability state.

Delegate Binding

Except for delegates exposed directly by the Combat Manager itself, you should use the appropriate interfaces to bind to other Delegates. You can unbind from them using the interface as well.

The following examples show how to bind and unbind from delegates, via the appropriate interfaces.

Binding via Interfaces
if (UNinjaCombatFunctionLibrary::IsValidDamageManagerComponent(DamageManager)) { // Create the Delegate, binding to the object ("this") and using a function compatible with the signature. // All signatures can be found in the NinjaCombatDelegates.h class. // FOwnerDiedDelegate OwnerDiedDelegate; OwnerDiedDelegate.BindDynamic(this, &ThisClass::HandleCombatTargetDeath); // Binding to the delegate is done via the appropriate interface, invoked on the target actor component. // All interfaces related to their delegates can be found in the documentation site. // ICombatDamageManagerInterface::Execute_BindToOwnerDiedDelegate(DamageManager, OwnerDiedDelegate); // Unbinding is done passing the original object bound to the function ("this"). // Again, all interfaces can be found in the documentation site. // ICombatDamageManagerInterface::Execute_UnbindFromOwnerDiedDelegate(DamageManager, this); }

Custom Combat Components

Custom Components can be created by implementing the correct Interface, or extending the base class provided by the Combat framework. You can then add your new components to your character, and return them using the Combat System Interface.

Implementing the Interface

You can simply create a new Actor Component, implement the desired interface and fill the necessary logic. If you want to reuse logic already available in the base Combat Manager, you can always perform an interface call to that component too.

Subclassing Components

Another alternative is to subclass the provided components. You can do that for components that are independent, such as the Motion Warping, or even the main Combat Manager. In this case, replace the base components as needed.

Conditional Component Creation

Another way to provide custom components, when some per-character logic is required, is to override the appropriate Factory Methods in the Combat Manager Component. All appropriate Factory Methods are listed in the table above.

Movement Component

The Movement Component is a special case, since it overrides the Character Movement Component, therefore it is not created, or directly used by the Combat Manager Component.

You can replace the Movement Component in the base C++ Character Class, or in your Character Blueprint.

Override default input component
APluginLabsCharacter::APluginLabsCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<UNinjaCombatCharacterMovementComponent>(CharacterMovementComponentName)) { // ... }
Last modified: 29 December 2024