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:
@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 the bound animation GUID. Returns
| Set the animation GUID. Parameters
|
reloadDuration
• | • | ||||
---|---|---|---|---|---|
Obtain the reload time. Returns
| 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
|