-
Notifications
You must be signed in to change notification settings - Fork 1
/
VehicleDatabase.cs
40 lines (37 loc) · 1.11 KB
/
VehicleDatabase.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections.Generic;
namespace GarageLite
{
public class VehicleDatabase
{
private DataStorage<List<VehicleInfo>> DataStorage { get; set; }
public List<VehicleInfo> Data { get; private set; }
public VehicleDatabase()
{
DataStorage = new DataStorage<List<VehicleInfo>>(MQSPlugin.Instance.Directory, "Vehicles.json");
}
public void Reload()
{
Data = DataStorage.Read();
if (Data == null)
{
Data = new List<VehicleInfo>();
DataStorage.Save(Data);
}
}
public void AddVehicle(VehicleInfo vehicle)
{
Data.Add(vehicle);
DataStorage.Save(Data);
}
public bool RetrieveVehicle(string name, string id)
{
var flag = Data.RemoveAll(x => x.Name.Equals(name) && x.PlayerId.Equals(id));
if (flag > 0)
{
DataStorage.Save(Data);
return true;
}
return false;
}
}
}