things/enemyProjectiles/EnemyProjectile.cs

A game entity class for enemy projectiles. It defines an RPC to remove the projectile, a Remove implementation that destroys the GameObject on the server/owner, and a SetDirection method that sets velocity and orients the projectile based on a 2D direction.

Networking
using System;
using Sandbox;

public class EnemyProjectile : Thing
{
	[Rpc.Broadcast]
	public void RemoveRpc( bool shouldSpawnEffects )
	{
		Remove( shouldSpawnEffects );
	}

	protected virtual void Remove( bool shouldSpawnEffects )
	{
		if ( IsProxy )
			return;

		GameObject.Destroy();
	}

	public virtual void SetDirection( Vector2 dir )
	{
		Velocity = dir * Velocity.Length;

		WorldRotation = Rotation.From( 0f, -Utils.GetAngleDegreesFromVector( dir ), 0f );
	}
}