Quantum-Engineering/BlockSelector.cs

74 lines
2.2 KiB
C#
Raw Normal View History

2020-09-03 03:09:26 -04:00
public class BlockSelector
{
private PlayerController playerController;
public string[] objectNames;
private int selection;
2020-09-03 03:09:26 -04:00
2020-09-16 21:40:25 -05:00
//! This class handles the building block selection at the top right corner of the screen.
public BlockSelector(PlayerController playerController)
2020-09-03 03:09:26 -04:00
{
this.playerController = playerController;
objectNames = new string[]
{
"Glass Block",
"Brick",
"Iron Block",
"Iron Ramp",
"Steel Block",
"Steel Ramp",
2021-05-16 14:12:13 -05:00
"Door",
"Quantum Hatchway",
"Storage Container",
"Storage Computer",
"Electric Light",
"Auger",
"Extruder",
"Press",
"Smelter",
"Universal Conduit",
"Retriever",
"Rail Cart Hub",
"Rail Cart",
"Universal Extractor",
"Solar Panel",
"Generator",
"Nuclear Reactor",
"Reactor Turbine",
"Power Conduit",
"Heat Exchanger",
"Alloy Smelter",
"Gear Cutter",
"Auto Crafter",
"Dark Matter Conduit",
"Dark Matter Collector",
"Turret",
"Missile Turret"
};
2020-09-03 03:09:26 -04:00
}
2020-09-16 21:40:25 -05:00
//! Applies changes.
private void SetSelection()
2020-09-03 03:09:26 -04:00
{
playerController.buildType = objectNames[selection];
playerController.previousBuildType = selection > 0 ? objectNames[selection - 1] : objectNames[objectNames.Length - 1];
playerController.nextBuildType = selection == objectNames.Length - 1 ? objectNames[0] : objectNames[selection + 1];
playerController.displayingBuildItem = true;
playerController.buildItemDisplayTimer = 0;
playerController.PlayButtonSound();
2020-09-03 03:09:26 -04:00
}
2020-09-16 21:40:25 -05:00
//! Changes the currently selected building block.
public void NextBlock()
{
selection = selection < objectNames.Length - 1 ? selection + 1 : 0;
SetSelection();
}
2020-09-16 21:40:25 -05:00
//! Changes the currently selected building block.
public void PreviousBlock()
2020-09-03 03:09:26 -04:00
{
selection = selection > 0 ? selection - 1 : objectNames.Length - 1;
SetSelection();
2020-09-03 03:09:26 -04:00
}
}