Example #1
0
    public static void Fire(ProjectileID ProjectileId, Player UsingPlayer)
    {
        int     Firer    = UsingPlayer.Id;
        Vector3 Position = UsingPlayer.ProjectileEmitter.GlobalTransform.origin;
        Vector3 Rotation = new Vector3(-UsingPlayer.IntendedLookVertical, UsingPlayer.LookHorizontal, 0);
        Vector3 Momentum = new Vector3(0, 0, Data[ProjectileId].InitialSpeed)
                           .Rotated(new Vector3(1, 0, 0), Deg2Rad(Rotation.x))
                           .Rotated(new Vector3(0, 1, 0), Deg2Rad(Rotation.y));
        string NameArg = System.Guid.NewGuid().ToString();

        if (Net.Work.IsNetworkServer())
        {
            Self.NonStaticFire(ProjectileId, Firer, Position, Rotation, Momentum, NameArg);
        }
        else
        {
            Self.RpcId(Net.ServerId, nameof(NonStaticFire), ProjectileId, Firer, Position, Rotation, Momentum, NameArg);
        }
    }