Skip to content

Commit cbac60d

Browse files
committed
Autosplitter necessary changes
1 parent babb8c8 commit cbac60d

File tree

8 files changed

+76
-7
lines changed

8 files changed

+76
-7
lines changed

src/Main.as

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,48 @@ package
7474

7575
public static const DEPTH_ENVIRON:int = -5;
7676

77-
public static var pause:Pauser;
77+
public static var _pause:Pauser;
78+
79+
public static function get pause():Pauser
80+
{
81+
return _pause;
82+
}
83+
84+
public static function set pause(pause:Pauser):void
85+
{
86+
_pause = pause;
87+
if (pause == null)
88+
{
89+
GameState = STATE_LEVEL_RUNNING;
90+
}
91+
else
92+
{
93+
GameState = STATE_LEVEL_PAUSED;
94+
}
95+
}
7896

7997
public static const DEPTH_SPEECH:int = -7;
8098

8199
public static var instance:Main;
82100

83101
private var focus:Boolean = true;
102+
103+
/* AUTOSPLITTER QOL */
104+
105+
public static var GameState:uint;
106+
public static var LevelType:uint;
107+
public static var TotalTime:uint;
108+
109+
// Magics for easy autosplitting.
110+
public static const STATE_MAIN_MENU:uint = 0xABCDEF;
111+
public static const STATE_LEVEL_START:uint = 0xBCDEFA;
112+
public static const STATE_LEVEL_RUNNING:uint = 0xCDEFAB;
113+
public static const STATE_LEVEL_PAUSED:uint = 0xDEFABC;
114+
public static const STATE_LEVEL_TRANSITION:uint = 0xFABCDE;
115+
public static const STATE_FINISH:uint = 0xFFFFFF;
116+
117+
public static const TYPE_START_OR_END:uint = 0xAABBCC;
118+
public static const TYPE_NORMAL:uint = 0xDDEEFF;
84119

85120
public function Main()
86121
{

src/game/LastKey.as

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ package game
188188
}
189189
Assets.SndGetKey.play();
190190
Assets.setMusic();
191-
(FP.world as Level).countTime = false;
191+
(FP.world as Level)._countTime = false;
192+
Main.GameState = Main.STATE_FINISH;
192193
this.sprite.frame = 0;
193194
this.glow.alpha = 1;
194195
this.player.grabLastKey();

src/game/cosmetic/Win.as

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ package game.cosmetic
1414

1515
public function Win()
1616
{
17+
Main.GameState = Main.STATE_LEVEL_TRANSITION;
1718
this.timer = new Alarm(20,this.done,Tween.ONESHOT);
1819
super();
1920
addTween(this.timer,true);

src/game/engine/EndLevel.as

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ package game.engine
55

66
public class EndLevel extends Level
77
{
8-
9-
108
public function EndLevel(num:uint)
119
{
1210
super(0,num);
11+
Main.LevelType = Main.TYPE_START_OR_END;
1312
}
1413

1514
override protected function specifics() : void
@@ -30,7 +29,7 @@ package game.engine
3029
world = 1;
3130
}
3231
load(new Assets["E" + world]());
33-
countTime = false;
32+
_countTime = false;
3433
}
3534
}
3635
}

src/game/engine/Level.as

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,35 @@ package game.engine
100100

101101
public var practice:Boolean;
102102

103-
public var countTime:Boolean;
103+
public var _countTime:Boolean;
104+
105+
public function get countTime():Boolean
106+
{
107+
return _countTime;
108+
}
109+
110+
public function set countTime(value:Boolean):void
111+
{
112+
_countTime = value;
113+
if (value && player && player.active)
114+
{
115+
Main.GameState = Main.STATE_LEVEL_RUNNING;
116+
}
117+
else if (value)
118+
{
119+
// Level just started.
120+
Main.GameState = Main.STATE_LEVEL_START;
121+
}
122+
else
123+
{
124+
Main.GameState = Main.STATE_LEVEL_PAUSED;
125+
}
126+
}
104127

105128
public function Level(mode:uint, num:uint, practice:Boolean = false, str:String = null)
106129
{
107130
super();
131+
Main.LevelType = Main.TYPE_NORMAL;
108132
this.mode = mode;
109133
this.levelNum = num;
110134
this.practice = practice;
@@ -189,6 +213,11 @@ package game.engine
189213
if(this.player && this.player.active && this.countTime)
190214
{
191215
this.time++;
216+
Main.TotalTime = Main.saveData.time + this.time;
217+
if (!changing)
218+
{
219+
Main.GameState = Main.STATE_LEVEL_RUNNING;
220+
}
192221
if(this.drawTime)
193222
{
194223
this.drawTime.updateTotal();

src/game/engine/StartLevel.as

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package game.engine
1313
public function StartLevel(num:uint)
1414
{
1515
super(0,num);
16+
Main.LevelType = Main.TYPE_START_OR_END;
1617
}
1718

1819
override protected function specifics() : void
@@ -47,7 +48,7 @@ package game.engine
4748
world = 2;
4849
}
4950
load(new Assets["S" + world]());
50-
countTime = false;
51+
_countTime = false;
5152
}
5253

5354
private function makePlayer() : void

src/game/menus/MainMenu.as

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ package game.menus
4747

4848
private function gotoMain(m:MenuButton = null) : void
4949
{
50+
Main.GameState = Main.STATE_MAIN_MENU;
5051
var hard:MenuButton = null;
5152
var load:MenuButton = null;
5253
var stats:MenuButton = null;
@@ -91,6 +92,7 @@ package game.menus
9192

9293
override public function update() : void
9394
{
95+
//Main.GameState = Main.STATE_MAIN_MENU;
9496
super.update();
9597
if(this.options && Input.pressed(Key.DELETE) && Input.check(Key.CONTROL) && Input.check(Key.SHIFT))
9698
{

src/game/menus/WinMenu.as

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package game.menus
2222
override public function begin() : void
2323
{
2424
super.begin();
25+
Main.GameState = Main.STATE_FINISH;
2526
Main.clearGame();
2627
if(Main.saveData.mode == 0)
2728
{

0 commit comments

Comments
 (0)