* delete round seed

* delete worldEdge locale

* Update CP14BiomeSpawnerSystem.cs

* nails to 50 max stack

* wood planks stack increase

* flora material stack edit

* Update EntityTest.cs

* Update EntityTest.cs
This commit is contained in:
Ed
2025-01-31 18:24:54 +03:00
committed by GitHub
parent b3eed32588
commit 3f70d8600c
14 changed files with 71 additions and 124 deletions

View File

@@ -5,7 +5,6 @@
using System.Linq;
using Content.Server._CP14.BiomeSpawner.Components;
using Content.Server._CP14.RoundSeed;
using Content.Server.Decals;
using Content.Server.Parallax;
using Content.Shared.Whitelist;
@@ -13,6 +12,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server._CP14.BiomeSpawner.EntitySystems;
@@ -24,12 +24,21 @@ public sealed class CP14BiomeSpawnerSystem : EntitySystem
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly DecalSystem _decals = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly CP14RoundSeedSystem _roundSeed = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private int _globalSeed = 0;
public override void Initialize()
{
SubscribeLocalEvent<CP14BiomeSpawnerComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<Shared.GameTicking.RoundEndMessageEvent>(OnRoundEnd);
UpdateSeed();
}
private void OnRoundEnd(Shared.GameTicking.RoundEndMessageEvent ev)
{
UpdateSeed();
}
private void OnMapInit(Entity<CP14BiomeSpawnerComponent> ent, ref MapInitEvent args)
@@ -38,6 +47,11 @@ public sealed class CP14BiomeSpawnerSystem : EntitySystem
QueueDel(ent);
}
private void UpdateSeed()
{
_globalSeed = _random.Next(int.MinValue, int.MaxValue);
}
private void SpawnBiome(Entity<CP14BiomeSpawnerComponent> ent)
{
var biome = _proto.Index(ent.Comp.Biome);
@@ -50,11 +64,9 @@ public sealed class CP14BiomeSpawnerSystem : EntitySystem
if (!TryComp<MapGridComponent>(gridUid, out var map))
return;
var seed = _roundSeed.GetSeed();
var vec = _transform.GetGridOrMapTilePosition(ent);
if (!_biome.TryGetTile(vec, biome.Layers, seed, map, out var tile))
if (!_biome.TryGetTile(vec, biome.Layers, _globalSeed, map, out var tile))
return;
// Set new tile
@@ -70,7 +82,7 @@ public sealed class CP14BiomeSpawnerSystem : EntitySystem
}
//Add decals
if (_biome.TryGetDecals(vec, biome.Layers, seed, map, out var decals))
if (_biome.TryGetDecals(vec, biome.Layers, _globalSeed, map, out var decals))
{
foreach (var decal in decals)
{
@@ -87,7 +99,7 @@ public sealed class CP14BiomeSpawnerSystem : EntitySystem
QueueDel(entToRemove);
}
if (_biome.TryGetEntity(vec, biome.Layers, tile.Value, seed, map, out var entityProto))
if (_biome.TryGetEntity(vec, biome.Layers, tile.Value, _globalSeed, map, out var entityProto))
Spawn(entityProto, new EntityCoordinates(gridUid, tileCenterVec));
}
}

View File

@@ -1,21 +0,0 @@
/*
* All right reserved to CrystallEdge.
*
* BUT this file is sublicensed under MIT License
*
*/
namespace Content.Server._CP14.RoundSeed;
/// <summary>
/// This is used for round seed
/// </summary>
[RegisterComponent, Access(typeof(CP14RoundSeedSystem))]
public sealed partial class CP14RoundSeedComponent : Component
{
[ViewVariables]
public static int MaxValue = 10000;
[ViewVariables]
public int Seed;
}

View File

@@ -1,53 +0,0 @@
/*
* All right reserved to CrystallEdge.
*
* BUT this file is sublicensed under MIT License
*
*/
using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Random;
namespace Content.Server._CP14.RoundSeed;
/// <summary>
/// Provides a round seed for another systems
/// </summary>
public sealed class CP14RoundSeedSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
SubscribeLocalEvent<CP14RoundSeedComponent, ComponentStartup>(OnComponentStartup);
}
private void OnComponentStartup(Entity<CP14RoundSeedComponent> ent, ref ComponentStartup args)
{
ent.Comp.Seed = _random.Next(CP14RoundSeedComponent.MaxValue);
}
private int SetupSeed()
{
return AddComp<CP14RoundSeedComponent>(Spawn(null, MapCoordinates.Nullspace)).Seed;
}
/// <summary>
/// Returns the round seed if assigned, otherwise assigns the round seed itself.
/// </summary>
/// <returns>seed of the round</returns>
public int GetSeed()
{
var query = EntityQuery<CP14RoundSeedComponent>();
foreach (var comp in query)
{
return comp.Seed;
}
var seed = SetupSeed();
Log.Warning($"Missing RoundSeed. Seed set to {seed}");
return seed;
}
}