-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time machine -- can be built from iron & time flux powder, allows pla…
…yer to skip World time & realtime ticks using time flux powder
- Loading branch information
1 parent
3ba16de
commit d8bbea3
Showing
13 changed files
with
78 additions
and
21 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
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
34 changes: 29 additions & 5 deletions
34
MadSand-core/src/hitonoriol/madsand/gui/dialogs/WaitDialog.java
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 |
---|---|---|
@@ -1,24 +1,48 @@ | ||
package hitonoriol.madsand.gui.dialogs; | ||
|
||
import com.badlogic.gdx.utils.Align; | ||
|
||
import hitonoriol.madsand.MadSand; | ||
import hitonoriol.madsand.Resources; | ||
import hitonoriol.madsand.Utils; | ||
import hitonoriol.madsand.entities.Player; | ||
import hitonoriol.madsand.properties.Globals; | ||
import hitonoriol.madsand.properties.ItemProp; | ||
import hitonoriol.madsand.world.World; | ||
|
||
public class WaitDialog extends SliderDialog { | ||
|
||
private int worldSeconds; | ||
private int worldSeconds, realtimeTicks; | ||
private int timeSkipItemSpent; | ||
|
||
public WaitDialog(int maxTimeSkip) { | ||
super(maxTimeSkip); | ||
super((int) Player.TIMESKIP_COEF, maxTimeSkip); | ||
super.setStep((int) Player.TIMESKIP_COEF); | ||
super.setTitle("Skip Time"); | ||
super.setSliderTitle("How much time to skip:"); | ||
super.getBottomLabel().setAlignment(Align.center); | ||
|
||
String timeSkipItem = ItemProp.getItemName(Globals.getInt(Globals.TIMESKIP_ITEM)); | ||
super.setSliderAction( | ||
ticks -> super.setSliderText(Utils.timeString(worldSeconds = MadSand.world.toWorldTimeSeconds(ticks)))); | ||
ticks -> { | ||
timeSkipItemSpent = (int) Math.max((float) ticks / Player.TIMESKIP_COEF, 1); | ||
worldSeconds = MadSand.world.toWorldTimeSeconds(ticks); | ||
realtimeTicks = (int) (timeSkipItemSpent * Player.REALTIME_SKIP_COEF); | ||
super.setSliderText("+"+Utils.timeString(worldSeconds) + " [[World time]" | ||
+ Resources.LINEBREAK | ||
|
||
+ "+"+Utils.timeString((long) (realtimeTicks * MadSand.world.realtimeTickRate)) | ||
+ " [[Realtime]" | ||
+ Resources.LINEBREAK | ||
|
||
+ "-"+timeSkipItemSpent + " " + timeSkipItem); | ||
}); | ||
|
||
super.setConfirmAction(ticks -> { | ||
World.player.inventory.delItem(Globals.getInt(Globals.TIMESKIP_ITEM), timeSkipItemSpent); | ||
World.player.skipTime(ticks); | ||
World.player.inventory.delItem(Globals.getInt(Globals.TIMESKIP_ITEM), ticks); | ||
MadSand.world.skipRealtimeTicks(realtimeTicks); | ||
MadSand.notice("Skipped " + Utils.timeString(worldSeconds)); | ||
}); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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