Biome generation

This commit is contained in:
2026-03-19 13:45:33 -05:00
parent fedb426cfc
commit 6d97e5324c
8 changed files with 376 additions and 36 deletions
@@ -36,7 +36,7 @@ public class LocationStore
"$jsonSchema", new BsonDocument
{
{ "bsonType", "object" },
{ "required", new BsonArray { "name", "coord", "createdUtc" } },
{ "required", new BsonArray { "name", "coord", "biomeKey", "createdUtc" } },
{
"properties", new BsonDocument
{
@@ -55,6 +55,7 @@ public class LocationStore
}
}
},
{ "biomeKey", new BsonDocument { { "bsonType", "string" } } },
{
"resources", new BsonDocument
{
@@ -219,14 +220,28 @@ public class LocationStore
Builders<Location>.Filter.Eq(l => l.Coord.X, 0),
Builders<Location>.Filter.Eq(l => l.Coord.Y, 0)
);
var existing = _col.Find(filter).FirstOrDefault();
if (existing is not null)
return;
var existing = _col.Find(filter).FirstOrDefault();
if (existing is not null)
{
var updates = new List<UpdateDefinition<Location>>();
if (string.IsNullOrWhiteSpace(existing.BiomeKey))
updates.Add(Builders<Location>.Update.Set(l => l.BiomeKey, "plains"));
if (existing.Resources.Count == 0)
updates.Add(Builders<Location>.Update.Set(l => l.Resources, new List<LocationResource>
{
new() { ItemKey = "wood", RemainingQuantity = 100, GatherQuantity = 3 },
new() { ItemKey = "grass", RemainingQuantity = 500, GatherQuantity = 10 }
}));
if (updates.Count > 0)
_col.UpdateOne(filter, Builders<Location>.Update.Combine(updates));
return;
}
var origin = new Location
{
Name = "Origin",
Coord = new Coord { X = 0, Y = 0 },
BiomeKey = "plains",
Resources =
[
new LocationResource { ItemKey = "wood", RemainingQuantity = 100, GatherQuantity = 3 },