-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0 - Fix AudioPlayers, Custom Drink API
- Loading branch information
1 parent
570a2fc
commit 18f7696
Showing
10 changed files
with
95 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using SCP294.Types.Config; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MEC; | ||
using MapEditorReborn.API.Features.Objects; | ||
using Exiled.API.Features; | ||
|
||
namespace SCP294.Classes | ||
{ | ||
public class DrinkManager | ||
{ | ||
public List<CustomDrink> LoadedDrinks = new List<CustomDrink>() { }; | ||
|
||
public void UnloadAllDrinks() | ||
{ | ||
LoadedDrinks = new List<CustomDrink>() { }; | ||
} | ||
|
||
public void LoadBaseDrinks() | ||
{ | ||
LoadedDrinks = LoadedDrinks.Concat(DrinkList.DefaultDrinks).ToList(); | ||
if (SCP294.Instance.Config.EnableCommunityDrinks) LoadedDrinks = LoadedDrinks.Concat(DrinkList.CommunityDrinks).ToList(); | ||
} | ||
|
||
public void UnloadBaseDrinks() | ||
{ | ||
LoadedDrinks = LoadedDrinks.Except(DrinkList.DefaultDrinks).ToList(); | ||
if (SCP294.Instance.Config.EnableCommunityDrinks) LoadedDrinks = LoadedDrinks.Except(DrinkList.CommunityDrinks).ToList(); | ||
} | ||
|
||
public static bool IsDrinkManagerLoaded() { return SCP294.Instance.DrinkManager.LoadedDrinks != null; } | ||
|
||
public static void RegisterDrink(CustomDrink newDrink) | ||
{ | ||
RegisterDrink(new CustomDrink[] { newDrink }); | ||
} | ||
public static void RegisterDrink(CustomDrink[] newDrink) | ||
{ | ||
Timing.RunCoroutine(AwaitAddDrink(newDrink)); | ||
} | ||
|
||
public static IEnumerator<float> AwaitAddDrink(CustomDrink[] newDrink) | ||
{ | ||
yield return Timing.WaitUntilTrue(IsDrinkManagerLoaded); | ||
SCP294.Instance.DrinkManager.LoadedDrinks = SCP294.Instance.DrinkManager.LoadedDrinks.Concat(newDrink.ToList()).ToList(); | ||
} | ||
|
||
public static void UnloadDrink(CustomDrink newDrink) | ||
{ | ||
UnloadDrink(new CustomDrink[] { newDrink }); | ||
} | ||
public static void UnloadDrink(CustomDrink[] newDrink) | ||
{ | ||
Timing.RunCoroutine(AwaitRemoveDrink(newDrink)); | ||
} | ||
|
||
public static IEnumerator<float> AwaitRemoveDrink(CustomDrink[] newDrink) | ||
{ | ||
while (SCP294.Instance.DrinkManager == null) | ||
{ | ||
yield return Timing.WaitForSeconds(1f); | ||
} | ||
|
||
SCP294.Instance.DrinkManager.LoadedDrinks = SCP294.Instance.DrinkManager.LoadedDrinks.Except(newDrink.ToList()).ToList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters