void Destroy() { Instance = null; GameEvents.Contract.onAccepted.Remove(new EventData <Contract> .OnEvent(OnContractAccepted)); ContractPreLoader.OnInitializeValues.Remove(new EventVoid.OnEvent(OnPreLoaderInitializeValues)); ContractPreLoader.OnInitializeFail.Remove(new EventVoid.OnEvent(OnPreLoaderInitializeFail)); }
void Destroy() { Instance = null; GameEvents.Contract.onAccepted.Remove(new EventData<Contract>.OnEvent(OnContractAccepted)); ContractPreLoader.OnInitializeValues.Remove(new EventVoid.OnEvent(OnPreLoaderInitializeValues)); ContractPreLoader.OnInitializeFail.Remove(new EventVoid.OnEvent(OnPreLoaderInitializeFail)); }
void Awake() { DontDestroyOnLoad(this); Instance = this; // Do a version check Assembly dtvAssembly = Util.Version.VerifyAssemblyVersion("DraftTwitchViewers", "2.3.1", true); if (dtvAssembly == null) { LoggingUtil.LogDebug(this, "Unable to find DraftTwitchViewers assembly."); Destroy(this); return; } LoggingUtil.LogDebug(this, "Found DraftTwitchViewers assembly."); Type draftManager = dtvAssembly.GetTypes().Where(t => t.Name.Contains("ScenarioDraftManager")).FirstOrDefault(); if (draftManager == null) { LoggingUtil.LogError(this, "Couldn't get ScenarioDraftManager from DraftTwitchViewers!"); Destroy(this); return; } draftMethod = draftManager.GetMethods(BindingFlags.Public | BindingFlags.Static). Where(mi => mi.Name == "DraftKerbal").FirstOrDefault(); if (draftMethod == null) { LoggingUtil.LogError(this, "Couldn't get DraftKerbal method from DraftTwitchViewers!"); Destroy(this); return; } saveMethod = draftManager.GetMethods(BindingFlags.Public | BindingFlags.Static). Where(mi => mi.Name == "SaveSupressedDraft").FirstOrDefault(); if (saveMethod == null) { LoggingUtil.LogError(this, "Couldn't get SaveSupressedDraft method from DraftTwitchViewers!"); Destroy(this); return; } GameEvents.Contract.onAccepted.Add(new EventData <Contract> .OnEvent(OnContractAccepted)); ContractPreLoader.OnInitializeValues.Add(new EventVoid.OnEvent(OnPreLoaderInitializeValues)); ContractPreLoader.OnInitializeFail.Add(new EventVoid.OnEvent(OnPreLoaderInitializeFail)); }
public static string KerbalName(ProtoCrewMember.Gender gender) { string defaultKerbalName = ""; do { defaultKerbalName = CrewGenerator.GetRandomName(gender, random); }while (nameCache.ContainsKey(defaultKerbalName)); string kerbalName = ""; do { kerbalName = DraftTwitchViewers.KerbalName(defaultKerbalName); }while (nameCache.ContainsKey(kerbalName)); nameCache.Add(kerbalName, 0); return(kerbalName); }
void Awake() { DontDestroyOnLoad(this); Instance = this; // Do a version check Assembly dtvAssembly = Util.Version.VerifyAssemblyVersion("DraftTwitchViewers", "2.0.1", true); if (dtvAssembly == null) { Destroy(this); return; } Type draftManager = dtvAssembly.GetTypes().Where(t => t.Name.Contains("DraftManager")).FirstOrDefault(); if (draftManager == null) { LoggingUtil.LogError(this, "Couldn't get DraftManager from DraftTwitchViewers!"); Destroy(this); return; } draftMethod = draftManager.GetMethods(BindingFlags.Public | BindingFlags.Static). Where(mi => mi.Name == "DraftKerbal").FirstOrDefault(); if (draftMethod == null) { LoggingUtil.LogError(this, "Couldn't get DraftKerbal method from DraftTwitchViewers!"); Destroy(this); return; } saveMethod = draftManager.GetMethods(BindingFlags.Public | BindingFlags.Static). Where(mi => mi.Name == "SaveSupressedDraft").FirstOrDefault(); if (saveMethod == null) { LoggingUtil.LogError(this, "Couldn't get SaveSupressedDraft method from DraftTwitchViewers!"); Destroy(this); return; } GameEvents.Contract.onAccepted.Add(new EventData<Contract>.OnEvent(OnContractAccepted)); ContractPreLoader.OnInitializeValues.Add(new EventVoid.OnEvent(OnPreLoaderInitializeValues)); ContractPreLoader.OnInitializeFail.Add(new EventVoid.OnEvent(OnPreLoaderInitializeFail)); }