File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/kitten-scientists/source Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,11 @@ export class KittenScientists {
47
47
gameLanguage : GameLanguage = "en" ,
48
48
engineState ?: EngineState ,
49
49
) {
50
- cinfo ( `Kitten Scientists ${ ksVersion ( "v" ) } constructed.` ) ;
50
+ cinfo ( `Kitten Scientists ${ ksVersion ( "v" ) } constructed. Checking for previous instances...` ) ;
51
+ if ( "kittenScientists" in UserScriptLoader . window ) {
52
+ cwarn ( "Detected existing KS instance. Trying to unload it..." ) ;
53
+ UserScriptLoader . window . kittenScientists ?. unload ( ) ;
54
+ }
51
55
cinfo ( `You are on the '${ String ( KS_RELEASE_CHANNEL ) } ' release channel.` ) ;
52
56
53
57
this . game = game ;
@@ -92,6 +96,7 @@ export class KittenScientists {
92
96
* Removes Kitten Scientists from the browser.
93
97
*/
94
98
unload ( ) : void {
99
+ cwarn ( "Unloading Kitten Scientists..." ) ;
95
100
this . engine . stop ( ) ;
96
101
this . _userInterface . destroy ( ) ;
97
102
if ( this . _gameBeforeSaveHandle !== undefined ) {
@@ -107,6 +112,7 @@ export class KittenScientists {
107
112
this . game . managers . splice ( managerIndex , 1 ) ;
108
113
}
109
114
delete window . kittenScientists ;
115
+ cwarn ( "Kitten Scientists have been unloaded!" ) ;
110
116
}
111
117
112
118
/**
You can’t perform that action at this time.
0 commit comments