Gameplay / HotWeaponFireComponent
HotWeaponFireComponent Class
Thermal weapon firing component, responsible for maintaining the main parameters and core logic of thermal weapon firing
Example usage: Create a script named "HotWeaponFireSample1", place it in the child node of the object manager's hot weapon, open the script, enter the following code to save, run the game, the code is as follows:
@Component
export default class HotWeaponFireSample1 extends Script {
protected onStart(): void {
// structure
const hotWeapon = this.gameObject as HotWeapon;
if (SystemUtil.isServer()) {
hotWeapon.fireComponent.isFireOnScreenCenter = false;
hotWeapon.fireComponent.clipSize = 50;
hotWeapon.fireComponent.fireInterval = 0;
hotWeapon.fireComponent.multipleShot = 3;
hotWeapon.fireComponent.isFireOnScreenCenter = false;
hotWeapon.fireComponent.offsetOfFireOnScreenCenter = new Vector(100, 30, 0);
// Set parameters
hotWeapon.fireComponent.animationAssetId = "80484";
hotWeapon.fireComponent.onStartFire.add(() => { console.log("fireComponent.onStartFireClient") });
hotWeapon.fireComponent.onEndFire.add(() => { console.log("fireComponent.onEndFireClient") });
hotWeapon.fireComponent.onEndContinuousFire.add(() => { console.log("fireComponent.onEndFireClient") });
}
}
}
@Component
export default class HotWeaponFireSample1 extends Script {
protected onStart(): void {
// structure
const hotWeapon = this.gameObject as HotWeapon;
if (SystemUtil.isServer()) {
hotWeapon.fireComponent.isFireOnScreenCenter = false;
hotWeapon.fireComponent.clipSize = 50;
hotWeapon.fireComponent.fireInterval = 0;
hotWeapon.fireComponent.multipleShot = 3;
hotWeapon.fireComponent.isFireOnScreenCenter = false;
hotWeapon.fireComponent.offsetOfFireOnScreenCenter = new Vector(100, 30, 0);
// Set parameters
hotWeapon.fireComponent.animationAssetId = "80484";
hotWeapon.fireComponent.onStartFire.add(() => { console.log("fireComponent.onStartFireClient") });
hotWeapon.fireComponent.onEndFire.add(() => { console.log("fireComponent.onEndFireClient") });
hotWeapon.fireComponent.onEndContinuousFire.add(() => { console.log("fireComponent.onEndFireClient") });
}
}
}
Table of contents
Properties
onEndContinuousFire: MulticastDelegateInterface <() => void > |
---|
The server executes the binding function when it finishes a burst fire shoot cycle. Example usage of class HotWeaponFireComponent |
onEndFire: MulticastDelegateInterface <() => void > |
Execute binding function when the server stops firing. Example usage of class HotWeaponFireComponent |
onStartFire: MulticastDelegateInterface <() => void > |
Execute binding function when the server starts firing. For the usage example, see the usage example of the class HotWeaponFireComponent |
Accessors
animationAssetId(): string other |
---|
Binding animation UID. Example usage of class HotWeaponFireComponent |
clipSize(): number other |
Get the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent |
currentBullet(): number other |
Get the number of bullets in the current magazine. For the usage example, see the usage example of the class HotWeaponFireComponent |
fireInterval(): number other |
Obtain the firing gap. For the usage example, see the usage example of the class HotWeaponFireComponent |
fireMode(): HotWeaponFireMode other |
Get the current firing mode |
isFireOnScreenCenter(): boolean other |
Gets whether to fire in the center of the screen. Example usage of class HotWeaponFireComponent |
multipleShot(): number other |
Obtain the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent |
offsetOfFireOnScreenCenter(): Vector other |
Get the offset when the screen center fires. Example usage of class HotWeaponFireComponent |
Methods
isFiring(): boolean other |
---|
Obtain the value of bFiring in the current state, which is generally used to process automatic reload change in fully automatic firing mode |
Properties
onEndContinuousFire
• onEndContinuousFire: MulticastDelegateInterface
<() => void
>
The server executes the binding function when it finishes a burst fire shoot cycle. Example usage of class HotWeaponFireComponent
onEndFire
• onEndFire: MulticastDelegateInterface
<() => void
>
Execute binding function when the server stops firing. Example usage of class HotWeaponFireComponent
onStartFire
• onStartFire: MulticastDelegateInterface
<() => void
>
Execute binding function when the server starts firing. For the usage example, see the usage example of the class HotWeaponFireComponent
Accessors
animationAssetId
• | • | ||||
---|---|---|---|---|---|
Binding animation UID. Example usage of class HotWeaponFireComponent Returns
| Set the animation GUID. Example usage of class HotWeaponFireComponent Parameters
|
clipSize
• | • | ||||
---|---|---|---|---|---|
Get the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent Returns
| Set the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent Precautions Only the server can be called before equipping the hot weapon, and both ends can be called after equipping Parameters
|
currentBullet
• | • | ||||
---|---|---|---|---|---|
Get the number of bullets in the current magazine. For the usage example, see the usage example of the class HotWeaponFireComponent Returns
| Set the number of bullets in the current magazine. Example usage of class HotWeaponFireComponent Parameters
|
fireInterval
• | • | ||||
---|---|---|---|---|---|
Obtain the firing gap. For the usage example, see the usage example of the class HotWeaponFireComponent Returns
| Set the firing gap. Example usage of class HotWeaponFireComponent Precautions Only the server can be called before equipping the hot weapon, and both ends can be called after equipping Parameters
|
fireMode
• | • | ||||
---|---|---|---|---|---|
Get the current firing mode Returns
| Switch and set the current firing mode Precautions Before equipment, it can only be call on the server, and after equipment, it can be call on the client Parameters
|
isFireOnScreenCenter
• | • | ||||
---|---|---|---|---|---|
Gets whether to fire in the center of the screen. Example usage of class HotWeaponFireComponent Returns
| Set whether to fire in the center of the screen. For the usage example, see the usage example of the class HotWeaponFireComponent Precautions Only the server can be called before equipping the hot weapon, and both ends can be called after equipping Parameters
|
multipleShot
• | • | ||||
---|---|---|---|---|---|
Obtain the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent Returns
| Set the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent Precautions Only the server can be called before equipping the hot weapon, and both ends can be called after equipping Parameters
|
offsetOfFireOnScreenCenter
• | • | ||||
---|---|---|---|---|---|
Get the offset when the screen center fires. Example usage of class HotWeaponFireComponent Returns
| Set the offset when firing from the center of the screen. Example usage of class HotWeaponFireComponent Precautions Only the server can be called before equipping the hot weapon, and both ends can be called after equipping Parameters
|
Methods
isFiring
• isFiring(): boolean
other
Obtain the value of bFiring in the current state, which is generally used to process automatic reload change in fully automatic firing mode
Returns
boolean | The current number of bullets in the magazine |
---|