Files
reallife-gamemode/ReallifeGamemode.Server/Job/JobBase.cs

48 lines
1.1 KiB
C#

using GTANetworkAPI;
using ReallifeGamemode.Server.Entities;
using ReallifeGamemode.Server.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ReallifeGamemode.Server.Job
{
public abstract class JobBase
{
protected delegate void JobStartHandler();
protected delegate void JobStopHandler();
protected event JobStartHandler JobStart;
protected event JobStopHandler JobStop;
private readonly List<Client> _inJob = new List<Client>();
public abstract int Id { get; }
public abstract string Name { get; }
public void StartJob(Client player)
{
_inJob.Add(player);
JobStart();
}
public void StopJob(Client player)
{
_inJob.Remove(player);
JobStop();
}
public List<JobVehicle> GetJobVehicles()
{
using(var dbContext = new DatabaseContext())
{
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
}
}
public List<Client> GetUsersInJob() => _inJob;
}
}