Skip to content
HotWeaponLoadComponent

Gameplay / HotWeaponLoadComponent

HotWeaponLoadComponent Class

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

Example usage: Create a script named "HotWeaponLoadSample1", place it in the object manager, open the script, enter the following code to save, run the game, the code is as follows:

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

        if (SystemUtil.isServer()) {
            hotWeapon.loadEnabled = true;
            hotWeapon.loadComponent.loadDuration = 1
            hotWeapon.loadComponent.loadAfterFireEnabled = true;
            hotWeapon.loadComponent.animationAssetId = "4172";

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

        if (SystemUtil.isServer()) {
            hotWeapon.loadEnabled = true;
            hotWeapon.loadComponent.loadDuration = 1
            hotWeapon.loadComponent.loadAfterFireEnabled = true;
            hotWeapon.loadComponent.animationAssetId = "4172";

            hotWeapon.loadComponent.onStartLoad.add(() => { console.log("loadComponent.onStartLoad Server") });
            hotWeapon.loadComponent.onEndLoad.add(() => { console.log("loadComponent.onEndLoad Server") });
        } else if (SystemUtil.isClient()) {
            hotWeapon.loadComponent.onStartLoad.add(() => { console.log("loadComponent.onStartLoad Client") });
            hotWeapon.loadComponent.onEndLoad.add(() => { console.log("loadComponent.onEndLoad Client") });
        }
    }
}

Table of contents

Properties

onEndLoad: MulticastDelegateInterface<() => void>
Execute binding function at the end of server loading.
onStartLoad: MulticastDelegateInterface<() => void>
Execute binding function when the server starts loading.

Accessors

animationAssetId(): string other
Get the bound animation GUID.
loadAfterFireEnabled(): boolean other
Obtain whether to activate the automatic loading function after firing.
loadDuration(): number other
Obtain loading time.

Properties

onEndLoad

onEndLoad: MulticastDelegateInterface<() => void>

Execute binding function at the end of server loading.


onStartLoad

onStartLoad: MulticastDelegateInterface<() => void>

Execute binding function when the server starts loading.

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

loadAfterFireEnabled

get loadAfterFireEnabled(): boolean other

set loadAfterFireEnabled(enable): void other

Obtain whether to activate the automatic loading function after firing.

Returns

booleanWhether to enable the automatic loading function after firing

Set whether to enable the automatic loading function after firing.

Precautions

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

Parameters

enable booleanWhether to enable the automatic loading function after firing

loadDuration

get loadDuration(): number other

set loadDuration(time): void other

Obtain loading time.

Returns

numberLoading time

Set the loading time.

Precautions

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

Parameters

time numberLoading time
default: 0.1
range: [0.01, 10] type: floating-point number