void Destroy() { Instance = null; GameEvents.OnKSCFacilityUpgraded.Remove(new EventData <UpgradeableFacility, int> .OnEvent(OnKSCFacilityUpgraded)); GameEvents.OnKSCStructureRepairing.Remove(new EventData <DestructibleBuilding> .OnEvent(OnKSCStructureRepairing)); GameEvents.OnCrewmemberHired.Remove(new EventData <ProtoCrewMember, int> .OnEvent(OnCrewHired)); GameEvents.OnTechnologyResearched.Remove(new EventData <GameEvents.HostTargetAction <RDTech, RDTech.OperationResult> > .OnEvent(OnTechResearched)); GameEvents.Modifiers.OnCurrencyModified.Remove(new EventData <CurrencyModifierQuery> .OnEvent(OnCurrencyModified)); GameEvents.onGameSceneSwitchRequested.Remove(new EventData <GameEvents.FromToAction <GameScenes, GameScenes> > .OnEvent(OnSceneSwitch)); GameEvents.onGUIAdministrationFacilitySpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIAstronautComplexSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIMissionControlSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIRnDComplexSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); }
void Awake() { // Destroy if we're not in a scene with a camera if (FlightCamera.fetch == null || FlightCamera.fetch.mainCamera == null) { DestroyImmediate(this); return; } CurrencyPopup current = FlightCamera.fetch.mainCamera.gameObject.GetComponent <CurrencyPopup>(); if (current == null) { FlightCamera.fetch.mainCamera.gameObject.AddComponent <CurrencyPopup>(); // Destroy this object - otherwise we'll have two DestroyImmediate(this); return; } else if (current != this) { // Nope, already got one, don't want it DestroyImmediate(this); return; } Instance = this; GameEvents.OnKSCFacilityUpgraded.Add(new EventData <UpgradeableFacility, int> .OnEvent(OnKSCFacilityUpgraded)); GameEvents.OnKSCStructureRepairing.Add(new EventData <DestructibleBuilding> .OnEvent(OnKSCStructureRepairing)); GameEvents.OnCrewmemberHired.Add(new EventData <ProtoCrewMember, int> .OnEvent(OnCrewHired)); GameEvents.OnTechnologyResearched.Add(new EventData <GameEvents.HostTargetAction <RDTech, RDTech.OperationResult> > .OnEvent(OnTechResearched)); GameEvents.Modifiers.OnCurrencyModified.Add(new EventData <CurrencyModifierQuery> .OnEvent(OnCurrencyModified)); GameEvents.onGameSceneSwitchRequested.Add(new EventData <GameEvents.FromToAction <GameScenes, GameScenes> > .OnEvent(OnSceneSwitch)); GameEvents.onGUIAdministrationFacilitySpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIAstronautComplexSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIMissionControlSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIRnDComplexSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); }
void Destroy() { Instance = null; GameEvents.OnKSCFacilityUpgraded.Remove(new EventData<UpgradeableFacility, int>.OnEvent(OnKSCFacilityUpgraded)); GameEvents.OnKSCStructureRepairing.Remove(new EventData<DestructibleBuilding>.OnEvent(OnKSCStructureRepairing)); GameEvents.OnCrewmemberHired.Remove(new EventData<ProtoCrewMember, int>.OnEvent(OnCrewHired)); GameEvents.OnTechnologyResearched.Remove(new EventData<GameEvents.HostTargetAction<RDTech, RDTech.OperationResult>>.OnEvent(OnTechResearched)); GameEvents.Modifiers.OnCurrencyModified.Remove(new EventData<CurrencyModifierQuery>.OnEvent(OnCurrencyModified)); GameEvents.onGameSceneSwitchRequested.Remove(new EventData<GameEvents.FromToAction<GameScenes, GameScenes>>.OnEvent(OnSceneSwitch)); GameEvents.onGUIAdministrationFacilitySpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIAstronautComplexSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIMissionControlSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIRnDComplexSpawn.Remove(new EventVoid.OnEvent(OnBuildingOpen)); }
void Awake() { // Destroy if we're not in a scene with a camera if (FlightCamera.fetch == null || FlightCamera.fetch.mainCamera == null) { DestroyImmediate(this); return; } CurrencyPopup current = FlightCamera.fetch.mainCamera.gameObject.GetComponent<CurrencyPopup>(); if (current == null) { FlightCamera.fetch.mainCamera.gameObject.AddComponent<CurrencyPopup>(); // Destroy this object - otherwise we'll have two DestroyImmediate(this); return; } else if (current != this) { // Nope, already got one, don't want it DestroyImmediate(this); return; } Instance = this; GameEvents.OnKSCFacilityUpgraded.Add(new EventData<UpgradeableFacility, int>.OnEvent(OnKSCFacilityUpgraded)); GameEvents.OnKSCStructureRepairing.Add(new EventData<DestructibleBuilding>.OnEvent(OnKSCStructureRepairing)); GameEvents.OnCrewmemberHired.Add(new EventData<ProtoCrewMember, int>.OnEvent(OnCrewHired)); GameEvents.OnTechnologyResearched.Add(new EventData<GameEvents.HostTargetAction<RDTech, RDTech.OperationResult>>.OnEvent(OnTechResearched)); GameEvents.Modifiers.OnCurrencyModified.Add(new EventData<CurrencyModifierQuery>.OnEvent(OnCurrencyModified)); GameEvents.onGameSceneSwitchRequested.Add(new EventData<GameEvents.FromToAction<GameScenes, GameScenes>>.OnEvent(OnSceneSwitch)); GameEvents.onGUIAdministrationFacilitySpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIAstronautComplexSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIMissionControlSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); GameEvents.onGUIRnDComplexSpawn.Add(new EventVoid.OnEvent(OnBuildingOpen)); }