Minor formatting / style changes

wip/source-generators
copygirl 1 year ago
parent d24e517e7c
commit ec7ddf4e5f
  1. 2
      src/gaemstone.Bloxel/BlockPos.cs
  2. 2
      src/gaemstone.Bloxel/Components/CoreComponents.cs
  3. 4
      src/gaemstone.Bloxel/Systems/BasicWorldGenerator.cs
  4. 8
      src/gaemstone.Client/Components/CameraComponents.cs
  5. 16
      src/gaemstone.Client/Components/RenderingComponents.cs
  6. 2
      src/gaemstone.Client/Components/ResourceComponents.cs
  7. 4
      src/gaemstone.Client/Resources.cs
  8. 2
      src/gaemstone/ECS/Observer.cs
  9. 3
      src/gaemstone/ECS/System.cs
  10. 12
      src/gaemstone/Flecs/Core.cs
  11. 2
      src/gaemstone/Utility/TypeWrapper.cs

@ -16,7 +16,7 @@ public readonly struct BlockPos
public void Deconstruct(out int x, out int y, out int z) => (x, y, z) = (X, Y, Z);
public Vector3D<float> GetOrigin() => new(X, Y, Z);
public Vector3D<float> GetCenter() => new(X + 0.5F, Y + 0.5F, Z + 0.5F);
public Vector3D<float> GetCenter() => new(X + 0.5f, Y + 0.5f, Z + 0.5f);
public BlockPos Add(int x, int y, int z) => new(X + x, Y + y, Z + z);

@ -17,6 +17,6 @@ public partial class CoreComponents
: ChunkPaletteStorage<Entity>
{
public ChunkStoreBlocks()
: base(default) { }
: base(default) { }
}
}

@ -17,7 +17,7 @@ public class BasicWorldGenerator
_noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
_noise.SetFractalType(FastNoiseLite.FractalType.Ridged);
_noise.SetFractalOctaves(4);
_noise.SetFractalGain(0.6F);
_noise.SetFractalGain(0.6f);
}
[Tag]
@ -35,7 +35,7 @@ public class BasicWorldGenerator
var gx = chunk.Position.X << ChunkBitShift | lx;
var gy = chunk.Position.Y << ChunkBitShift | ly;
var gz = chunk.Position.Z << ChunkBitShift | lz;
var bias = Math.Clamp(gy / 32.0F + 1.0F, 0.0F, 1.0F);
var bias = Math.Clamp(gy / 32.0f + 1.0f, 0.0f, 1.0f);
if (_noise.GetNoise(gx, gy, gz) > bias)
blocks[lx, ly, lz] = stone;
}

@ -10,18 +10,18 @@ public class CameraComponents
public struct Camera
{
public static readonly Camera Default2D = Create2D();
public static readonly Camera Default3D = Create3D(80.0F);
public static readonly Camera Default3D = Create3D(80.0f);
public static Camera Create2D(float nearPlane = -100.0F, float farPlane = 100.0F)
public static Camera Create2D(float nearPlane = -100.0f, float farPlane = 100.0f)
=> new() { NearPlane = nearPlane, FarPlane = farPlane };
public static Camera Create3D(float fieldOfView, float nearPlane = 0.1F, float farPlane = 200.0F)
public static Camera Create3D(float fieldOfView, float nearPlane = 0.1f, float farPlane = 200.0f)
=> new() { FieldOfView = fieldOfView, NearPlane = nearPlane, FarPlane = farPlane };
public float FieldOfView { get; set; }
public float NearPlane { get; set; }
public float FarPlane { get; set; }
public bool IsOrthographic => (FieldOfView == 0.0F);
public bool IsOrthographic => (FieldOfView == 0.0f);
}
[Component]

@ -48,15 +48,15 @@ public class RenderingComponents
public static TextureCoords4 FromIntCoords(Size textureSize, Point origin, Size size)
=> FromIntCoords(textureSize, origin.X, origin.Y, size.Width, size.Height);
public static TextureCoords4 FromIntCoords(Size textureSize, int x, int y, int width, int height) => new(
x / (float)textureSize.Width + 0.001F,
y / (float)textureSize.Height + 0.001F,
(x + width) / (float)textureSize.Width - 0.001F,
(y + height) / (float)textureSize.Height - 0.001F);
x / (float)textureSize.Width + 0.001f,
y / (float)textureSize.Height + 0.001f,
(x + width) / (float)textureSize.Width - 0.001f,
(y + height) / (float)textureSize.Height - 0.001f);
public static TextureCoords4 FromGrid(int numCellsX, int numCellsY, int cellX, int cellY) => new(
cellX / (float)numCellsX + 0.001F,
cellY / (float)numCellsY + 0.001F,
(cellX + 1) / (float)numCellsX - 0.001F,
(cellY + 1) / (float)numCellsY - 0.001F);
cellX / (float)numCellsX + 0.001f,
cellY / (float)numCellsY + 0.001f,
(cellX + 1) / (float)numCellsX - 0.001f,
(cellY + 1) / (float)numCellsY - 0.001f);
}
}

@ -10,7 +10,7 @@ public class ResourceComponents
// Entities can have for example Texture as a tag, in which case
// they're the actual resource holding the data or handle.
//
//
// Entities can also have a (Texture, $T) pair where $T is a resource,
// meaning the entity has that resource assigned as their texture.

@ -40,10 +40,10 @@ public static class Resources
{
if (!path.IsAbsolute) throw new ArgumentException(
$"Path '{path}' must be absolute", nameof(path));
if (path.Count < 3 || path[1] != "Resources") throw new ArgumentException(
if ((path.Count < 3) || (path[1] != "Resources")) throw new ArgumentException(
$"Path '{path}' must be in the format '/[domain]/Resources/...", nameof(path));
var assembly = Assembly.Load(path[0].ToString());
var assembly = Assembly.Load(path[0]);
var builder = new StringBuilder(path[2]);
for (var i = 3; i < path.Count; i++)
builder.Append('.').Append(path[i]);

@ -43,7 +43,7 @@ public static class ObserverExtensions
Action<Iterator> iterAction;
var param = method.GetParameters();
if (param.Length == 1 && param[0].ParameterType == typeof(Iterator)) {
if ((param.Length == 1) && (param[0].ParameterType == typeof(Iterator))) {
filter = new(expr ?? throw new Exception(
"Observer must specify ExpressionAttribute"));
if (method.IsStatic) instance = null;

@ -38,6 +38,7 @@ public static class SystemExtensions
entity = universe.New((query.Name != null) ? new(query.Name) : null)
.Add<DependsOn>(phase).Add(phase).Build(),
binding_ctx = (void*)CallbackContextHelper.Create(callback),
// TODO: Use binding_ctx_free to remove clear the context.
run = new() { Data = new() { Pointer = &Run } },
};
return new(universe, new(ecs_system_init(universe, &desc)));
@ -72,7 +73,7 @@ public static class SystemExtensions
QueryDesc query;
Action<Iterator> callback;
var param = method.GetParameters();
if (param.Length == 1 && param[0].ParameterType == typeof(Iterator)) {
if ((param.Length == 1) && (param[0].ParameterType == typeof(Iterator))) {
query = new(expr ?? throw new ArgumentException(
"System must specify ExpressionAttribute", nameof(method)));
callback = (Action<Iterator>)Delegate.CreateDelegate(typeof(Action<Iterator>), instance, method);

@ -15,12 +15,12 @@ public static class Core
// Entities
[Entity] public struct World { }
[Entity("*")] public struct Wildcard { }
[Entity("_")] public struct Any { }
[Entity] public struct This { }
[Entity("$")] public struct Variable { }
[Entity] public struct Flag { }
[Entity] public struct World { }
[Entity("*")] public struct Wildcard { }
[Entity("_")] public struct Any { }
[Entity] public struct This { }
[Entity("$")] public struct Variable { }
[Entity] public struct Flag { }
// Entity Relationships

@ -55,7 +55,7 @@ public class TypeWrapper<TType> : ITypeWrapper
public int Size { get; } = Unsafe.SizeOf<TType>();
public bool IsUnmanaged { get; } = !RuntimeHelpers.IsReferenceOrContainsReferences<TType>();
private TypeWrapper() { }
private TypeWrapper() { }
IFieldWrapper ITypeWrapper.GetFieldForAutoProperty(string propertyName) => GetFieldForAutoProperty(propertyName);
IFieldWrapper ITypeWrapper.GetFieldForAutoProperty(PropertyInfo property) => GetFieldForAutoProperty(property);

Loading…
Cancel
Save