Skip to content
HotWeaponReloadComponent

Gameplay / HotWeaponReloadComponent

HotWeaponReloadComponent Class

Hot Weapon reload component is responsible for maintaining the relevant parameters and logic of Hot Weapon reload action

Usage example: create a script named "HotWeaponReloadSample1", place it in the object manager, open the script, enter the following code to save, and run the game. The code is as follows:

ts
@Component
export default class HotWeaponReloadSample1 extends Script {
    protected onStart(): void {
        // structure
        const hotWeapon = this.gameObject as HotWeapon;

        if (SystemUtil.isServer()) {

            hotWeapon.reloadEnabled = true;
            hotWeapon.reloadComponent.reloadDuration = 2;
            hotWeapon.reloadComponent.animationAssetId = "4171";

            hotWeapon.reloadComponent.onStartReload.add(() => { console.log("reloadComponent.onStartReload Server") });
            hotWeapon.reloadComponent.onEndReload.add(() => { console.log("reloadComponent.onEndReload Server") });
        } else if (SystemUtil.isClient()) {
            hotWeapon.reloadComponent.onStartReload.add(() => { console.log("reloadComponent.onStartReload Client") });
            hotWeapon.reloadComponent.onEndReload.add(() => { console.log("reloadComponent.onEndReload Client") });
        }
    }
}
@Component
export default class HotWeaponReloadSample1 extends Script {
    protected onStart(): void {
        // structure
        const hotWeapon = this.gameObject as HotWeapon;

        if (SystemUtil.isServer()) {

            hotWeapon.reloadEnabled = true;
            hotWeapon.reloadComponent.reloadDuration = 2;
            hotWeapon.reloadComponent.animationAssetId = "4171";

            hotWeapon.reloadComponent.onStartReload.add(() => { console.log("reloadComponent.onStartReload Server") });
            hotWeapon.reloadComponent.onEndReload.add(() => { console.log("reloadComponent.onEndReload Server") });
        } else if (SystemUtil.isClient()) {
            hotWeapon.reloadComponent.onStartReload.add(() => { console.log("reloadComponent.onStartReload Client") });
            hotWeapon.reloadComponent.onEndReload.add(() => { console.log("reloadComponent.onEndReload Client") });
        }
    }
}

Table of contents

Properties

onEndReload: MulticastDelegateInterface<() => void>
Execute the binding function when ending the reloading process. Example usage of class HotWeaponReloadComponent
onStartReload: MulticastDelegateInterface<() => void>
Execute binding function when starting to reload.

Accessors

animationAssetId(): string other
Get the bound animation GUID.
reloadDuration(): number other
Obtain the reload time.

Properties

onEndReload

onEndReload: MulticastDelegateInterface<() => void>

Execute the binding function when ending the reloading process. Example usage of class HotWeaponReloadComponent


onStartReload

onStartReload: MulticastDelegateInterface<() => void>

Execute binding function when starting to reload.

Accessors

animationAssetId

get animationAssetId(): string other

set animationAssetId(GUID): void other

Get the bound animation GUID.

Returns

stringBound animation GUID

Set the animation GUID.

Parameters

GUID stringMontage animation GUID range to be set: depends on the length of asset ID

reloadDuration

get reloadDuration(): number other

set reloadDuration(time): void other

Obtain the reload time.

Returns

numberIt's reload time

Set the reload time.

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

time numberNew reload time
default: 0.1
range: [0.01, 10] type: floating point number