Weapons/Base/BaseWeapon.Effects.cs
using Opium;

public partial class BaseWeapon
{
	protected void CreateImpactEffects( GameObject hitObject, Surface surface, Vector3 pos, Vector3 normal )
	{
		var existing = surface?.PrefabCollection.BulletImpact;
		var decalPath = Game.Random.FromList( ["decals/impact/generic.decal"] );
		if ( ResourceLibrary.TryGet<DecalDefinition>( decalPath, out var decal ) )
		{
			var gameObject = existing?.Clone() ?? new GameObject();
			gameObject.WorldPosition = pos;
			gameObject.WorldRotation = Rotation.LookAt( -normal );

			// Random rotation
			gameObject.WorldRotation *= Rotation.FromAxis( Vector3.Forward, Game.Random.Float( -180, 180 ) );

			try
			{
				gameObject.SetParent( hitObject, true );
			}
			catch
			{
				Log.Warning( "Make sure this gets fixed" );
			}

			var decalRenderer = gameObject.Components.Create<Decal>();
			decalRenderer.Decals = [decal];
			decalRenderer.Depth = 16f;

			// Creates a destruction component to destroy the gameobject after a while
			gameObject.DestroyAsync( 30f );
		}

		if ( !string.IsNullOrEmpty( surface.Sounds.Bullet ) )
		{
			hitObject.PlaySound( surface.Sounds.Bullet );
		}
	}
}