Skip to content

Commit

Permalink
Merge branch 'refactor/baseclient' into refactor/mutliplayer
Browse files Browse the repository at this point in the history
Co-authored-by: Marcus Aurelius <[email protected]>
  • Loading branch information
susch19 and Gallimathias committed Feb 28, 2024
2 parents 5393a68 + 38cd67d commit feac0e8
Show file tree
Hide file tree
Showing 196 changed files with 2,472 additions and 831 deletions.
1 change: 1 addition & 0 deletions OctoAwesome/Design Documents/RecipeOrReceipt.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
### Iron Smelting Recipe Sample
``` json
{
"Type": "Blast Furnace", //, Crafting, etc.pp. Freitext
"Inputs":[
{
"ItemName":"IronOre",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/Biomes/BiomeBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Chunking;
using OctoAwesome.Location;

using System.Buffers;
using System.Collections.Generic;
Expand Down
1 change: 1 addition & 0 deletions OctoAwesome/OctoAwesome.Basics/Biomes/FlatlandBiome.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Biomes
{
Expand Down
1 change: 1 addition & 0 deletions OctoAwesome/OctoAwesome.Basics/Biomes/HighMountainBiome.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Biomes
{
Expand Down
1 change: 1 addition & 0 deletions OctoAwesome/OctoAwesome.Basics/Biomes/HillsBiome.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Biomes
{
Expand Down
3 changes: 2 additions & 1 deletion OctoAwesome/OctoAwesome.Basics/Biomes/IBiome.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Biomes
{
Expand Down Expand Up @@ -43,7 +44,7 @@ public interface IBiome
/// <param name="chunkIndex">The chunk position to read the heightmap at.</param>
/// <param name="heightmap">
/// The heightmap array to read into.
/// Should be size <see cref="Chunk.CHUNKSIZE_X"/> * <see cref="Chunk.CHUNKSIZE_Y"/>.
/// Should be size <see cref="Chunking.Chunk.CHUNKSIZE_X"/> * <see cref="Chunking.Chunk.CHUNKSIZE_Y"/>.
/// </param>
void FillHeightmap(Index2 chunkIndex, float[] heightmap);
}
Expand Down
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/Biomes/LandBiomeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

using OctoAwesome.Basics.Noise;
using OctoAwesome.Chunking;
using OctoAwesome.Location;

using System;
using System.Buffers;
Expand Down
5 changes: 3 additions & 2 deletions OctoAwesome/OctoAwesome.Basics/Biomes/LargeBiomeBase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

using OctoAwesome.Basics.Noise;
using OctoAwesome.Location;

using System;
using System.Diagnostics;
using System.Linq;
using OctoAwesome.Basics.Noise;

namespace OctoAwesome.Basics.Biomes
{
Expand Down
5 changes: 4 additions & 1 deletion OctoAwesome/OctoAwesome.Basics/Biomes/OceanBiomeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace OctoAwesome.Basics.Biomes
using OctoAwesome.Chunking;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Biomes
{
/// <summary>
/// Biome class or generating the oceanic floor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Chunking;
using OctoAwesome.Location;

using System;
using System.Buffers;
Expand Down
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/Climate/ComplexClimateMap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using OctoAwesome.Basics.Noise;
using OctoAwesome.Chunking;
using OctoAwesome.Location;

using System;

Expand Down
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/ComplexPlanet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using OctoAwesome.Basics.Biomes;
using OctoAwesome.Serialization;

using OctoAwesome.Location;

using System;
using System.Diagnostics;
using System.IO;
Expand Down
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/ComplexPlanetGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using OctoAwesome.Basics.Definitions.Blocks;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;
using OctoAwesome.Location;
using OctoAwesome.Pooling;
using OctoAwesome.Serialization;

Expand Down
2 changes: 2 additions & 0 deletions OctoAwesome/OctoAwesome.Basics/DebugMapGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.IO;
using OctoAwesome.Basics.Definitions.Blocks;
using OctoAwesome.Definitions;
using OctoAwesome.Chunking;
using OctoAwesome.Location;

namespace OctoAwesome.Basics
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Basics.Properties;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;
using OctoAwesome.Information;

namespace OctoAwesome.Basics.Definitions.Blocks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;

namespace OctoAwesome.Basics.Definitions.Blocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;

namespace OctoAwesome.Basics.Definitions.Blocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using OctoAwesome.Basics.Definitions.Materials;
using System;
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;
using OctoAwesome.Location;

namespace OctoAwesome.Basics.Definitions.Blocks
{
Expand All @@ -15,7 +18,25 @@ public sealed class RedCottonBlockDefinition : BlockDefinition
public override string Icon => "cotton_red";

/// <inheritdoc />
public override string[] Textures { get; } = { "cotton_red" };
public override string[] Textures =>
new[]{
"cotton_red_0",
"cotton_red_1",
"cotton_red_2",
"cotton_red_3",
"cotton_red_4",
"cotton_red_5",
"cotton_red_6",
"cotton_red_7",
"cotton_red_8",
"cotton_red_9",
"cotton_red_10",
"cotton_red_11",
"cotton_red_12",
"cotton_red_13",
"cotton_red_14",
"cotton_red_15",
};

/// <inheritdoc />
public override IMaterialDefinition Material { get; }
Expand All @@ -28,5 +49,46 @@ public RedCottonBlockDefinition(CottonMaterialDefinition material)
{
Material = material;
}

/// <inheritdoc />
public override int GetTextureIndex(Wall wall, ILocalChunkCache manager, int x, int y, int z)
{
int fullBlockTextureIndex = 15;
var centerBlock = new Index3(x, y, z);
var baseBlockIndex = manager.GetBlock(centerBlock);

var (firstAxis, secondAxis) = wall switch
{
Wall.Top => (Index3.UnitX, Index3.UnitY),
Wall.Bottom => (-Index3.UnitX, Index3.UnitY),
Wall.Left => (Index3.UnitY, -Index3.UnitZ),
Wall.Right => (-Index3.UnitY, -Index3.UnitZ),
Wall.Front => (Index3.UnitX, -Index3.UnitZ),
Wall.Back => (-Index3.UnitX, -Index3.UnitZ),
_ => throw new ArgumentOutOfRangeException(nameof(wall), wall, null)
};

fullBlockTextureIndex = RemoveEdgesOnAxis(manager, centerBlock, firstAxis, 0, baseBlockIndex, fullBlockTextureIndex);
fullBlockTextureIndex = RemoveEdgesOnAxis(manager, centerBlock, secondAxis, 1, baseBlockIndex, fullBlockTextureIndex);

return fullBlockTextureIndex;
}

private static int RemoveEdgesOnAxis(ILocalChunkCache manager, Index3 centerBlock, Index3 axis, int sideOffset, ushort baseBlockIndex,
int fullBlockTextureIndex)
{
for (int i = -1; i <= 1; i+=2)
{
var otherIndex = manager.GetBlock(centerBlock + axis * i);

if (otherIndex == baseBlockIndex)
{
var bitOffset = (i + 1) + sideOffset;
fullBlockTextureIndex &= ~(1 << bitOffset);
}
}

return fullBlockTextureIndex;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Chunking;
using OctoAwesome.Definitions;

namespace OctoAwesome.Basics.Definitions.Blocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OctoAwesome.Basics.Definitions.Materials;
using OctoAwesome.Basics.Languages;
using OctoAwesome.Definitions;
using OctoAwesome.Chunking;

namespace OctoAwesome.Basics.Definitions.Blocks
{
Expand Down
5 changes: 3 additions & 2 deletions OctoAwesome/OctoAwesome.Basics/Definitions/Items/Axe.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OctoAwesome.Definitions;
using OctoAwesome.Definitions.Items;
using OctoAwesome.Information;
using OctoAwesome.OctoMath;

namespace OctoAwesome.Basics.Definitions.Items
Expand Down Expand Up @@ -38,10 +39,10 @@ public Axe(AxeDefinition definition, IMaterialDefinition materialDefinition)
}

/// <inheritdoc />
public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decimal volumeRemaining, int volumePerHit)
public override int Hit(IMaterialDefinition material, IBlockInteraction hitInfo, decimal volumeRemaining, int volumePerHit)
{
//⁅𝑥^2/800+3𝑥/8+(−𝑥^3)/320000⁆
var baseEfficiency = base.Hit(material, blockInfo, volumeRemaining, volumePerHit);
var baseEfficiency = base.Hit(material, hitInfo, volumeRemaining, volumePerHit);
//typeof(Item).GUID
if (material is ISolidMaterialDefinition solid && baseEfficiency > 0)
{
Expand Down
23 changes: 19 additions & 4 deletions OctoAwesome/OctoAwesome.Basics/Definitions/Items/Bucket.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using OctoAwesome.Definitions;
using OctoAwesome.Definitions.Items;
using OctoAwesome.Information;
using OctoAwesome.Services;

namespace OctoAwesome.Basics.Definitions.Items
{
Expand All @@ -25,7 +27,7 @@ public class Bucket : Item, IFluidInventory
public Bucket(BucketDefinition definition, IMaterialDefinition materialDefinition)
: base(definition, materialDefinition)
{
MaxQuantity = 125;
MaxQuantity = 1250;
}

/// <inheritdoc />
Expand All @@ -34,12 +36,14 @@ public void AddFluid(int quantity, IBlockDefinition fluidBlock)
if (!Definition.CanMineMaterial(fluidBlock.Material))
return;

Quantity += quantity;
if (Quantity < 125)
Quantity += quantity;

FluidBlock = fluidBlock;
}

/// <inheritdoc />
public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decimal volumeRemaining, int volumePerHit)
public override int Hit(IMaterialDefinition material, IBlockInteraction hitInfo, decimal volumeRemaining, int volumePerHit)
{
if (!Definition.CanMineMaterial(material))
return 0;
Expand All @@ -56,7 +60,18 @@ public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decim
}


return base.Hit(material, blockInfo, volumeRemaining, volumePerHit);
return base.Hit(material, hitInfo, volumeRemaining, volumePerHit);
}

/// <inheritdoc />
public override int Apply(IMaterialDefinition material, IBlockInteraction hitInfo, decimal volumeRemaining)
{
if (Quantity > 125 && FluidBlock is not null)
{
BlockInteractionService.CalculatePositionAndRotation(hitInfo, out var facingDirection, out _);
}

return base.Apply(material, hitInfo, volumeRemaining);
}
}
}
14 changes: 10 additions & 4 deletions OctoAwesome/OctoAwesome.Basics/Definitions/Items/ChestItem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using engenious;

using OctoAwesome.Basics.FunctionBlocks;
using OctoAwesome.Definitions;
using OctoAwesome.Definitions.Items;
using OctoAwesome.Information;
using OctoAwesome.Location;
using OctoAwesome.Notifications;
using OctoAwesome.Rx;
using OctoAwesome.Services;

using System;

namespace OctoAwesome.Basics.Definitions.Items
Expand Down Expand Up @@ -32,11 +37,12 @@ public ChestItem(ChestItemDefinition definition, IMaterialDefinition materialDef
}

/// <inheritdoc />
public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decimal volumeRemaining, int volumePerHit)
public override int Apply(IMaterialDefinition material, IBlockInteraction hitInfo, decimal volumeRemaining)
{
//TODO: Implement Place Chest and remove this item
var position = blockInfo.Position;
Chest chest = new(new Coordinate(0, new(position.X, position.Y, position.Z + 1), new Vector3(0.5f, 0.5f, 0.5f)));
BlockInteractionService.CalculatePositionAndRotation(hitInfo, out var facingDirection, out var rot);

Chest chest = new(new Coordinate(0, facingDirection, new Vector3(0.5f, 0.5f, 0.5f)), rot);

var notification = new EntityNotification
{
Entity = chest,
Expand Down
15 changes: 9 additions & 6 deletions OctoAwesome/OctoAwesome.Basics/Definitions/Items/FurnaceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
using OctoAwesome.Basics.FunctionBlocks;
using OctoAwesome.Definitions;
using OctoAwesome.Definitions.Items;
using OctoAwesome.Information;
using OctoAwesome.Location;
using OctoAwesome.Notifications;
using OctoAwesome.Rx;
using OctoAwesome.Services;

using System;

Expand Down Expand Up @@ -37,15 +40,15 @@ public FurnaceItem(FurnaceItemDefinition definition, IMaterialDefinition materia
simulationSource = updateHub.AddSource(simulationRelay, DefaultChannels.Simulation);
}

/// <inheritdoc/>
public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decimal volumeRemaining, int volumePerHit)
/// <inheritdoc />
public override int Apply(IMaterialDefinition material, IBlockInteraction hitInfo, decimal volumeRemaining)
{
//TODO: Implement Place Furnace and remove this item
var position = blockInfo.Position;
Furnace chest = new(new Coordinate(0, new(position.X, position.Y, position.Z + 1), new Vector3(0.5f, 0.5f, 0.5f)));
BlockInteractionService.CalculatePositionAndRotation(hitInfo, out var facingDirection, out var rot);

Furnace furnace = new(new Coordinate(0, facingDirection, new Vector3(0.5f, 0.5f, 0.5f)), rot);
var notification = new EntityNotification
{
Entity = chest,
Entity = furnace,
Type = EntityNotification.ActionType.Add
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class FurnaceItemDefinition : IItemDefinition
/// <inheritdoc/>
public string DisplayName { get; }
/// <inheritdoc/>
public string Icon { get; }
public string Icon { get; }

/// <summary>
/// Initializes a new instance of the<see cref="FurnaceItemDefinition" /> class
Expand Down
Loading

0 comments on commit feac0e8

Please sign in to comment.