things/enemies/BarrelExploding.cs

A subclass of Barrel that defines an exploding barrel enemy. It sets explosion parameters, overrides start/dying behavior to trigger an explosion sequence, and plays a fuse sound when beginning to explode.

Networking
using Sandbox;
using Sandbox.Diagnostics;
using System;
using System.Numerics;

public class BarrelExploding : Barrel
{
	public override EnemyType EnemyType => EnemyType.BarrelExploding;
	//public override EnemyType KillStatEnemyType => EnemyType.Barrel;
	public override bool CanCombust => false;

	protected override void OnStart()
	{
		base.OnStart();

		_explosionRadius = 110f;
		_explosionDamage = 40f;
		_explodeTime = 1f;

		_debrisName = "barrel_exploding_debris";

		if ( IsProxy )
			return;

	}

	protected override void StartDying( Vector2 dir, float force, Player player, DamageType damageType )
	{
		IsDying = true;
		IsSpawning = false;

		Velocity *= 0.5f;

		//if ( player.IsValid() && player.CombustionActive )
		//	Combust( player );
		//else
			StartExplodingRpc( _explodeTime, _explosionRadius, _explosionDamage, player );
	}

	protected override void StartExploding( float time, float radius, float damage, Player player )
	{
		base.StartExploding( time, radius, damage, player );

		Manager.Instance.PlaySfxNearbyRpc( "exploding_barrel_fuse", Position2D, pitch: Game.Random.Float( 1.1f, 1.2f ), volume: 1.15f, maxDist: 450f );

		//ShakeRpc( startStrength: 5f, endStrength: 0f, time: 0.1f, easingType: EasingType.QuadIn);
	}
}