BaseWeaponModelclass

Marks up a weapon's view or world model with the attachment points the weapon fires from - the muzzle, the shell-eject port, and so on - and plays the stock presentation off them: muzzle flash, brass and tracer prefabs, plus the b_deploy/b_attack/b_reload animation parameters. Drop this on a weapon model prefab, wire the attachment GameObjects, and override the On* hooks to extend or replace any of it. The holding `Sandbox.BaseCombatWeapon` drives it through those hooks.

objectComponentBaseWeaponModel
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public class Sandbox.BaseWeaponModel : Sandbox.Component

Constructors1

Showing 1 constructors

Methods12

Showing 12 methods

public void DoEjectBrass()PUBLIC

Spawns `Sandbox.BaseWeaponModel.EjectBrass` at the shell-eject attachment and throws it out, if both are set.

Returns:void

public void DoMuzzleEffect()PUBLIC

Spawns `Sandbox.BaseWeaponModel.MuzzleEffect` parented to the muzzle attachment, if both are set.

Returns:void

public void DoTracerEffect(Vector3 hitPoint, System.Nullable`1<Vector3> origin = null)PUBLIC

ParameterTypeDescription
hitPointVector3
origin = nullNullable<Vector3>
Returns:void

public Transform GetMuzzleTransform()PUBLIC

The muzzle world transform, or the model's own transform when there's no muzzle attachment.

Returns:Transform

public Transform GetShellEjectTransform()PUBLIC

The shell-eject world transform, or the model's own transform when there's no eject attachment.

Returns:Transform

public Transform GetTracerOrigin()PUBLIC

The point a tracer starts from - the muzzle.

Returns:Transform

public virtual void OnAttack(System.Nullable`1<Vector3> hitPoint = null, System.Nullable`1<Vector3> origin = null)PUBLICVIRTUAL

ParameterTypeDescription
hitPoint = nullNullable<Vector3>
origin = nullNullable<Vector3>
Returns:void

public virtual void OnDeploy()PUBLICVIRTUAL

Called when this weapon model is deployed (drawn). Base sets the "b_deploy" animation parameter and plays `Sandbox.BaseWeaponModel.DeploySound`. Override to extend.

Returns:void

public virtual void OnIncrementalReload()PUBLICVIRTUAL

Called when a round is loaded during an incremental (one-at-a-time) reload. Base does nothing - override for the per-shell animation.

Returns:void

public virtual void OnReloadCancel()PUBLICVIRTUAL

Called when a reload is cancelled part-way through. Base does nothing - override to stop timed sounds and so on.

Returns:void

public virtual void OnReloadFinish()PUBLICVIRTUAL

Called when the reload finishes. Base clears the "b_reload" animation parameter. Override to extend.

Returns:void

public virtual void OnReloadStart()PUBLICVIRTUALLIFECYCLE

Called when the weapon starts reloading. Base sets the "b_reload" animation parameter. Override to extend (incremental animations, timed reload sounds).

Returns:void

Properties7

Showing 7 properties

public Sandbox.SoundEvent Sandbox.BaseWeaponModel.DeploySound { get; set; }PUBLICGETSET

Sound played when this weapon model is deployed (drawn).

Returns:SoundEvent

public Sandbox.GameObject Sandbox.BaseWeaponModel.EjectBrass { get; set; }PUBLICGETSET

Effect prefab spawned at the shell-eject port when the weapon fires (the flying brass). Defaults to a generic casing - clear it for none.

Returns:GameObject

public Sandbox.GameObject Sandbox.BaseWeaponModel.MuzzleEffect { get; set; }PUBLICGETSET

Effect prefab spawned at the muzzle when the weapon fires (muzzle flash, smoke). Defaults to a generic flash - clear it for none.

Returns:GameObject

public Sandbox.GameObject Sandbox.BaseWeaponModel.MuzzleGameObject { get; set; }PUBLICGETSET

The muzzle attachment - where shots and muzzle effects originate.

Returns:GameObject

public Sandbox.GameObject Sandbox.BaseWeaponModel.ShellEjectGameObject { get; set; }PUBLICGETSET

The shell-eject attachment - where spent casings are thrown from.

Returns:GameObject

public Sandbox.GameObject Sandbox.BaseWeaponModel.TracerEffect { get; set; }PUBLICGETSET

Effect prefab spawned from the muzzle toward the hit point (the bullet tracer). Defaults to a generic tracer - clear it for none.

Returns:GameObject

On this page