Skip to content

Commit 947161b

Browse files
Cleanup part 2
1 parent bc5fa24 commit 947161b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1574
-1736
lines changed

.run/Blocktest (Local Multiplayer).run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Blocktest (Local Multiplayer)" type="DotNetProject" factoryName=".NET Project">
3-
<option name="EXE_PATH" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0/Blocktest" />
3+
<option name="EXE_PATH" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0/Blocktest.exe" />
44
<option name="PROGRAM_PARAMETERS" value="connect 127.0.0.1" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0" />
66
<option name="PASS_PARENT_ENVS" value="1" />

.run/Blocktest.run.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Blocktest" type="DotNetProject" factoryName=".NET Project">
3-
<option name="EXE_PATH" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0/Blocktest" />
3+
<option name="EXE_PATH" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0/Blocktest.exe" />
44
<option name="PROGRAM_PARAMETERS" value="" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Blocktest/bin/Debug/net7.0" />
66
<option name="PASS_PARENT_ENVS" value="1" />

Blocktest/Blocktest.csproj

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
<ApplicationIcon>Icon.ico</ApplicationIcon>
1212
</PropertyGroup>
1313
<ItemGroup>
14-
<None Remove="Icon.ico" />
15-
<None Remove="Icon.bmp" />
14+
<None Remove="Icon.ico"/>
15+
<None Remove="Icon.bmp"/>
1616
</ItemGroup>
1717
<ItemGroup>
18-
<EmbeddedResource Include="Icon.ico" />
19-
<EmbeddedResource Include="Icon.bmp" />
18+
<EmbeddedResource Include="Icon.ico"/>
19+
<EmbeddedResource Include="Icon.bmp"/>
2020
</ItemGroup>
2121
<PropertyGroup>
2222
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
2323
</PropertyGroup>
2424
<ItemGroup>
25-
<PackageReference Include="LiteNetLib" Version="1.1.0" />
26-
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
27-
<PackageReference Include="Nopipeline.Task" Version="2.2.*" />
28-
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*" />
25+
<PackageReference Include="LiteNetLib" Version="1.1.0"/>
26+
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*"/>
27+
<PackageReference Include="Nopipeline.Task" Version="2.2.*"/>
28+
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*"/>
2929
</ItemGroup>
3030
<ItemGroup>
31-
<ProjectReference Include="..\Shared\Shared.csproj" />
31+
<ProjectReference Include="..\Shared\Shared.csproj"/>
3232
</ItemGroup>
3333
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
34-
<Message Text="Restoring dotnet tools" Importance="High" />
35-
<Exec Command="dotnet tool restore" />
34+
<Message Text="Restoring dotnet tools" Importance="High"/>
35+
<Exec Command="dotnet tool restore"/>
3636
</Target>
3737
</Project>
+6-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=code/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
1+
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2+
xmlns:s="clr-namespace:System;assembly=mscorlib"
3+
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xml:space="preserve">
5+
<s:Boolean
6+
x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=code/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

Blocktest/BlocktestGame.cs

+53-54
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
1-
using Blocktest.Rendering;
1+
using Blocktest.Block_System;
22
using Blocktest.Scenes;
3+
using Shared.Code.Block_System;
4+
namespace Blocktest;
5+
6+
/// <inheritdoc />
7+
public sealed class BlocktestGame : Game {
8+
private readonly bool _connect;
9+
private readonly string? _ip;
10+
private IScene? _currentScene;
11+
private GraphicsDeviceManager _graphics;
12+
313

4-
namespace Blocktest
5-
{
614
/// <inheritdoc />
7-
public class BlocktestGame : Game
8-
{
9-
private GraphicsDeviceManager _graphics;
10-
private Scene? _currentScene;
11-
private bool connect;
12-
private string? ip;
13-
public static ContentManager? ContentManager { get; private set; }
15+
public BlocktestGame() {
16+
_connect = false;
17+
_graphics = new GraphicsDeviceManager(this);
18+
Content.RootDirectory = "Content";
19+
IsMouseVisible = true;
20+
TargetElapsedTime = TimeSpan.FromMilliseconds(16);
21+
}
1422

23+
public BlocktestGame(string newIp) {
24+
_connect = true;
25+
_ip = newIp;
26+
_graphics = new GraphicsDeviceManager(this);
27+
Content.RootDirectory = "Content";
28+
IsMouseVisible = true;
29+
TargetElapsedTime = TimeSpan.FromMilliseconds(16);
30+
}
1531

32+
public static ContentManager? ContentManager { get; private set; }
1633

17-
/// <inheritdoc />
18-
public BlocktestGame()
19-
{
20-
connect = false;
21-
_graphics = new GraphicsDeviceManager(this);
22-
Content.RootDirectory = "Content";
23-
IsMouseVisible = true;
24-
TargetElapsedTime = TimeSpan.FromMilliseconds(16);
25-
}
34+
/// <inheritdoc />
35+
protected override void Initialize() {
36+
BlockManagerShared.Initialize();
37+
base.Initialize();
38+
}
2639

27-
public BlocktestGame(string newIp)
28-
{
29-
connect = true;
30-
ip = newIp;
31-
_graphics = new GraphicsDeviceManager(this);
32-
Content.RootDirectory = "Content";
33-
IsMouseVisible = true;
34-
TargetElapsedTime = TimeSpan.FromMilliseconds(16);
35-
}
40+
/// <inheritdoc />
41+
protected override void LoadContent() {
42+
ContentManager = Content;
43+
BlockSpritesManager.LoadBlockSprites(Content);
44+
_currentScene = new GameScene(this, _connect, _ip);
45+
}
46+
47+
/// <inheritdoc />
48+
protected override void Update(GameTime gameTime) {
49+
_currentScene?.Update(gameTime);
3650

37-
/// <inheritdoc />
38-
protected override void Initialize() {
39-
BlockManagerShared.Initialize();
40-
base.Initialize();
41-
}
51+
base.Update(gameTime);
52+
}
4253

43-
/// <inheritdoc />
44-
protected override void LoadContent()
45-
{
46-
ContentManager = Content;
47-
BlockSpritesManager.LoadBlockSprites(Content);
48-
_currentScene = new GameScene(this, connect, ip);
49-
}
54+
/// <inheritdoc />
55+
protected override void Draw(GameTime gameTime) {
56+
_currentScene?.Draw(gameTime, GraphicsDevice);
5057

51-
/// <inheritdoc />
52-
protected override void Update(GameTime gameTime)
53-
{
54-
_currentScene?.Update(gameTime);
58+
base.Draw(gameTime);
59+
}
5560

56-
base.Update(gameTime);
57-
}
61+
protected override void OnExiting(object sender, EventArgs args) {
62+
_currentScene?.EndScene();
5863

59-
/// <inheritdoc />
60-
protected override void Draw(GameTime gameTime)
61-
{
62-
_currentScene?.Draw(gameTime, GraphicsDevice);
63-
64-
base.Draw(gameTime);
65-
}
64+
base.OnExiting(sender, args);
6665
}
67-
}
66+
}
+45-42
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
11
using Blocktest.Rendering;
2+
using Shared.Code.Block_System;
3+
namespace Blocktest.Block_System;
24

3-
namespace Blocktest
4-
{
5-
/// <summary>
6-
/// Handles sprites for blocks.
7-
/// </summary>
8-
public class BlockSprites
9-
{
10-
/// <summary> Shared block info </summary>
11-
public BlockShared blockShared;
5+
/// <summary>
6+
/// Handles sprites for blocks.
7+
/// </summary>
8+
public sealed class BlockSprites {
9+
/// <summary> Shared block info </summary>
10+
public BlockShared BlockShared;
1211

13-
/// <summary> The block's sprite. </summary>
14-
public Drawable blockSprite;
12+
/// <summary> The block's sprite. </summary>
13+
public Drawable BlockSprite;
1514

16-
/// <summary> The sprite sheet used for smoothing the block. </summary>
17-
public SpriteSheet spriteSheet;
15+
/// <summary> The sprite sheet used for smoothing the block. </summary>
16+
public SpriteSheet SpriteSheet;
1817

19-
/* METHODS */
18+
/* METHODS */
2019

21-
public BlockSprites(BlockShared newBlockShared, ContentManager content)
22-
{
23-
blockShared = newBlockShared;
24-
LoadSprite(content);
25-
}
20+
public BlockSprites(BlockShared newBlockShared, ContentManager content) {
21+
BlockShared = newBlockShared;
22+
LoadSprite(content);
23+
}
2624

27-
/// <summary>
28-
/// Called when the block is created by the block sprites manager.
29-
/// </summary>
30-
/// <remarks>
31-
/// DO NOT FORGET TO CALL THE BASE METHOD IF YOU OVERRIDE THIS.
32-
/// </remarks>
33-
public virtual void LoadSprite(ContentManager content)
34-
{
35-
string path = @"Graphics\Blocks\" + blockShared.blockName.ToLower().Replace(" ", "");
36-
try {
37-
blockSprite = new Drawable(path, new Rectangle(1, 1, 10, 10)); //this might need to be expanded in the future in case we decide to make use of the full 12x12 tiles on our spritesheets
38-
/*if (!blockShared.blockSmoothing) {
39-
return;
40-
}*/
41-
spriteSheet = new SpriteSheet(path, 4, 4, 1);
42-
if (spriteSheet.OrderedSprites.Length <= 1) {
43-
Console.WriteLine("Block " + this + " is marked as smoothable, but a sprite sheet could not be found at " + path + "!");
44-
}
45-
}
46-
catch (ContentLoadException) {
47-
blockSprite = new Drawable(@"Graphics\Blocks\error");
48-
Console.WriteLine("Block " + this + " does not have an icon at " + path + "!");
25+
/// <summary>
26+
/// Called when the block is created by the block sprites manager.
27+
/// </summary>
28+
/// <remarks>
29+
/// DO NOT FORGET TO CALL THE BASE METHOD IF YOU OVERRIDE THIS.
30+
/// </remarks>
31+
public void LoadSprite(ContentManager content) {
32+
string path = @"Graphics\Blocks\" + BlockShared.BlockName.ToLower().Replace(" ", "");
33+
try {
34+
BlockSprite =
35+
new Drawable(path,
36+
new Rectangle(1, 1, 10,
37+
10)); //this might need to be expanded in the future in case we decide to make use of the full 12x12 tiles on our spritesheets
38+
/*if (!blockShared.blockSmoothing) {
39+
return;
40+
}*/
41+
SpriteSheet = new SpriteSheet(path, 4, 4, 1);
42+
if (SpriteSheet.OrderedSprites.Length <= 1) {
43+
Console.WriteLine("Block " +
44+
this +
45+
" is marked as smoothable, but a sprite sheet could not be found at " +
46+
path +
47+
"!");
4948
}
5049
}
50+
catch (ContentLoadException) {
51+
BlockSprite = new Drawable(@"Graphics\Blocks\error");
52+
Console.WriteLine("Block " + this + " does not have an icon at " + path + "!");
53+
}
5154
}
52-
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
using Blocktest.Rendering;
1+
using Shared.Code.Block_System;
2+
namespace Blocktest.Block_System;
23

3-
namespace Blocktest
4-
{
5-
public class BlockSpritesManager
6-
{
7-
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary>
8-
private static BlockSprites[] allBlocksSprites;
9-
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary>
10-
public static BlockSprites[] AllBlocksSprites { get => allBlocksSprites; private set => allBlocksSprites = value; }
4+
public sealed class BlockSpritesManager {
5+
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary>
6+
private static BlockSprites[] _allBlocksSprites;
117

12-
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary>
13-
private static string[] blockSpriteNames;
14-
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary>
15-
public static string[] BlockSpriteNames { get => blockSpriteNames; private set => blockSpriteNames = value; }
8+
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary>
9+
private static string[] _blockSpriteNames;
1610

17-
public static void LoadBlockSprites(ContentManager content)
18-
{
19-
AllBlocksSprites = new BlockSprites[BlockManagerShared.AllBlocks.Length];
20-
BlockSpriteNames = new string[BlockManagerShared.AllBlocks.Length];
11+
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary>
12+
public static BlockSprites[] AllBlocksSprites {
13+
get => _allBlocksSprites;
14+
private set => _allBlocksSprites = value;
15+
}
16+
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary>
17+
public static string[] BlockSpriteNames {
18+
get => _blockSpriteNames;
19+
private set => _blockSpriteNames = value;
20+
}
21+
22+
public static void LoadBlockSprites(ContentManager content) {
23+
AllBlocksSprites = new BlockSprites[BlockManagerShared.AllBlocks.Length];
24+
BlockSpriteNames = new string[BlockManagerShared.AllBlocks.Length];
2125

22-
for(int i = 0; i < BlockManagerShared.AllBlocks.Length; i++)
23-
{
24-
BlockShared block = BlockManagerShared.AllBlocks[i];
25-
BlockSprites newBlockSprites = new(block, content);
26-
BlockSpriteNames[block.blockID] = block.blockName;
27-
AllBlocksSprites[block.blockID] = newBlockSprites;
28-
}
26+
for (int i = 0; i < BlockManagerShared.AllBlocks.Length; i++) {
27+
BlockShared block = BlockManagerShared.AllBlocks[i];
28+
BlockSprites newBlockSprites = new(block, content);
29+
BlockSpriteNames[block.BlockId] = block.BlockName;
30+
AllBlocksSprites[block.BlockId] = newBlockSprites;
2931
}
3032
}
31-
}
33+
}

0 commit comments

Comments
 (0)