Added commands to assign business to user
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user