Class CombatBehaviour
Represents the combat behaviour of an NPC, allowing configuration of combat-related settings and actions.
public class CombatBehaviour
- Inheritance
-
CombatBehaviour
- Inherited Members
- Extension Methods
Properties
DefaultWeaponAssetPath
Gets or sets the default weapon asset path for the NPC's combat behaviour. This property allows you to specify the weapon that the NPC will use by default. Use Weapon or AvatarEquippablePaths for convenience when setting this property. Set to an empty string to clear the default weapon.
public string DefaultWeaponAssetPath { get; set; }
Property Value
Remarks
Using type-safe SetDefaultWeapon(Equippable) or SetDefaultWeapon(EquippableBuilder) is generally preferred and advised.
GiveUpRange
Gets or sets the range in units at which the NPC will give up pursuing a target.
public float GiveUpRange { get; set; }
Property Value
GiveUpTime
Gets or sets the time in seconds the NPC will continue to pursue a target before giving up.
public float GiveUpTime { get; set; }
Property Value
Methods
SetAndAttackTarget(IEntity)
Sets the specified target as the NPC's combat target and enables attacking behavior.
public void SetAndAttackTarget(IEntity target)
Parameters
targetIEntityThe target entity to be attacked by the NPC.
SetCurrentWeapon(Equippable)
Sets the current weapon of the NPC using an S1API Equippable wrapper. This method extracts the asset path from the equippable's associated AvatarEquippable component.
public void SetCurrentWeapon(Equippable equippable)
Parameters
equippableEquippableThe S1API Equippable wrapper containing the weapon to equip.
Remarks
This method attempts to find an AvatarEquippable component on the equippable's GameObject and uses its AssetPath. If no AvatarEquippable is found, this method will log an error.
SetCurrentWeapon(EquippableBuilder)
Sets the current weapon of the NPC using an EquippableBuilder-created equippable. This method extracts the asset path from the builder's AvatarEquippable configuration.
public void SetCurrentWeapon(EquippableBuilder equippableBuilder)
Parameters
equippableBuilderEquippableBuilderThe EquippableBuilder instance containing the weapon configuration.
Remarks
This method requires the EquippableBuilder to have been configured with WithAvatarEquippable() to provide an asset path. The builder will be built automatically if not already built.
SetCurrentWeapon(string)
Sets the current weapon of the NPC by specifying the weapon's resource path.
public void SetCurrentWeapon(string weaponPath)
Parameters
weaponPathstringThe resource path of the weapon to equip (e.g., "Avatar/Equippables/M1911"). For convenience, Weapon can be used.
SetDefaultWeapon(Equippable)
Sets the default weapon for the NPC's combat behaviour using an S1API Equippable wrapper. This method extracts the asset path from the equippable's associated AvatarEquippable component.
public void SetDefaultWeapon(Equippable equippable)
Parameters
equippableEquippableThe S1API Equippable wrapper containing the weapon to set as default.
Remarks
This method attempts to find an AvatarEquippable component on the equippable's GameObject and uses its AssetPath. If no AvatarEquippable is found, this method will log an error.
SetDefaultWeapon(EquippableBuilder)
Sets the default weapon for the NPC's combat behaviour using an EquippableBuilder-created equippable. This method extracts the asset path from the builder's AvatarEquippable configuration.
public void SetDefaultWeapon(EquippableBuilder equippableBuilder)
Parameters
equippableBuilderEquippableBuilderThe EquippableBuilder instance containing the weapon configuration.
Remarks
This method requires the EquippableBuilder to have been configured with WithAvatarEquippable() to provide an asset path. The builder will be built automatically if not already built.