Added commands to assign business to user

This commit is contained in:
hydrant
2018-11-19 22:24:06 +01:00
parent 225eb78ced
commit cef42180c9
7 changed files with 130 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ namespace reallife_gamemode.Server.Managers
class BusinessManager : Script
{
private static List<BusinessBase> businesses;
public static List<BusinessBase> Businesses { get => businesses; }
public static void LoadBusinesses()
{
@@ -22,12 +23,14 @@ namespace reallife_gamemode.Server.Managers
NAPI.Util.ConsoleOutput($"Loading Business {item.Name}");
if (Activator.CreateInstance(item) is BusinessBase o)
{
if (businesses.Find(b => b.GetType() == item) != null)
if (businesses.Any(x => x.Id == o.Id))
{
throw new InvalidOperationException($"Double Business found: {o.Id} | {o.Name}");
throw new InvalidOperationException($"Double Business ID found: {o.Id} | {o.Name}");
}
businesses.Add(o);
o.Setup();
o.Load();
o.Update();
}
}
}
@@ -37,5 +40,9 @@ namespace reallife_gamemode.Server.Managers
return (T)businesses.Find(b => b.GetType() == typeof(T));
}
public static BusinessBase GetBusiness(int id)
{
return businesses.Find(b => b.Id == id);
}
}
}