* tweaks.

* aaaaaa

* aaaaa

* Revert "aaaaa"

This reverts commit d95c6d6cedeac70d9c882533f115c229a69ee38a.

* yes

* AlwaysPoweredMap, remove biomes.

* forget..

* sky

* Updated map

* Update PlanetPrisonStationSystem.cs

* Update EmergencyShuttleSystem.cs

---------

Co-authored-by: SplikZerys <tronezero700@yandex.ru>
Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com>
This commit is contained in:
haiwwkes 2024-10-07 10:45:23 +05:00 committed by GitHub
parent 86cec57f9f
commit b8032baa9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 692 additions and 28633 deletions

View file

@ -22,6 +22,8 @@ using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.StatsBoard;
using Content.Shared._Sunrise.StatsBoard;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
namespace Content.Server.GameTicking
{
@ -30,6 +32,7 @@ namespace Content.Server.GameTicking
[Dependency] private readonly DiscordWebhook _discord = default!;
[Dependency] private readonly ITaskManager _taskManager = default!;
[Dependency] private readonly StatsBoardSystem _statsBoardSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
private static readonly Counter RoundNumberMetric = Metrics.CreateCounter(
"ss14_round_number",
@ -143,7 +146,14 @@ namespace Content.Server.GameTicking
_mapManager.AddUninitializedMap(toLoad);
}
LoadGameMap(map, toLoad, null);
if (map == mainStationMap) // Sunrise
{
LoadGameMap(map, toLoad, null, anchor: true);
}
else
{
LoadGameMap(map, toLoad, null);
}
}
}
@ -157,7 +167,7 @@ namespace Content.Server.GameTicking
/// <param name="loadOptions">Map loading options, includes offset.</param>
/// <param name="stationName">Name to assign to the loaded station.</param>
/// <returns>All loaded entities and grids.</returns>
public IReadOnlyList<EntityUid> LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null)
public IReadOnlyList<EntityUid> LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null, bool anchor = false)
{
// Okay I specifically didn't set LoadMap here because this is typically called onto a new map.
// whereas the command can also be used on an existing map.
@ -176,6 +186,17 @@ namespace Content.Server.GameTicking
_metaData.SetEntityName(_mapManager.GetMapEntityId(targetMapId), map.MapName);
// Sunrise
if (anchor)
{
var grids = _mapManager.GetAllMapGrids(targetMapId);
foreach (var grid in grids)
{
_physics.SetBodyType(grid.Owner, BodyType.Static);
}
}
// Sunrise
var gridUids = gridIds.ToList();
RaiseLocalEvent(new PostGameMapLoad(map, targetMapId, gridUids, stationName));

View file

@ -8,6 +8,7 @@ using Content.Server.Decals;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.Atmos;
using Content.Shared.Decals;
using Content.Shared.Gravity;
@ -57,6 +58,10 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
private const float DefaultLoadRange = 16f;
private float _loadRange = DefaultLoadRange;
// Sunrise
private int _maxChunks = 100;
// Sunrise
private List<(Vector2i, Tile)> _tiles = new();
private ObjectPool<HashSet<Vector2i>> _tilePool =
@ -86,10 +91,18 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
SubscribeLocalEvent<FTLStartedEvent>(OnFTLStarted);
SubscribeLocalEvent<ShuttleFlattenEvent>(OnShuttleFlatten);
Subs.CVar(_configManager, CVars.NetMaxUpdateRange, SetLoadRange, true);
Subs.CVar(_configManager, SunriseCCVars.MaxLoadedChunks, SetMaxChunk, true); // Sunrise
InitializeCommands();
SubscribeLocalEvent<PrototypesReloadedEventArgs>(ProtoReload);
}
// Sunrise
private void SetMaxChunk(int obj)
{
_maxChunks = obj;
}
// Sunrise
private void ProtoReload(PrototypesReloadedEventArgs obj)
{
if (!obj.ByType.TryGetValue(typeof(BiomeTemplatePrototype), out var reloads))
@ -428,16 +441,21 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
BuildMarkerChunks(component, gridUid, grid, seed);
var active = _activeChunks[component];
var loadedCount = component.LoadedChunks.Count; // Sunrise
foreach (var chunk in active)
{
LoadChunkMarkers(component, gridUid, grid, chunk, seed);
// Sunrise
if (loadedCount >= _maxChunks)
continue;
// Sunrise
if (!component.LoadedChunks.Add(chunk))
continue;
// Load NOW!
LoadChunkMarkers(component, gridUid, grid, chunk, seed);
LoadChunk(component, gridUid, grid, chunk, seed);
loadedCount++; // Sunrise
}
}

View file

@ -3,6 +3,7 @@ using Content.Server.NodeContainer.EntitySystems;
using Content.Server.Power.Components;
using Content.Server.Power.NodeGroups;
using Content.Server.Power.Pow3r;
using Content.Shared._Sunrise.AlwaysPoweredMap;
using Content.Shared.CCVar;
using Content.Shared.Power;
using JetBrains.Annotations;
@ -313,12 +314,12 @@ namespace Content.Server.Power.EntitySystems
var enumerator = AllEntityQuery<ApcPowerReceiverComponent>();
while (enumerator.MoveNext(out var uid, out var apcReceiver))
{
var powered = !apcReceiver.PowerDisabled
&& (!apcReceiver.NeedsPower
|| MathHelper.CloseToPercent(apcReceiver.NetworkLoad.ReceivingPower,
apcReceiver.Load));
var mapId = Transform(uid).MapUid;
var isAlwaysPowered = HasComp<AlwaysPoweredMapComponent>(mapId);
var powered = isAlwaysPowered || (!apcReceiver.PowerDisabled &&
(!apcReceiver.NeedsPower || MathHelper.CloseToPercent(apcReceiver.NetworkLoad.ReceivingPower, apcReceiver.Load)));
// If new value is the same as the old, then exit
if (!apcReceiver.Recalculate && apcReceiver.Powered == powered)
continue;
@ -330,7 +331,7 @@ namespace Content.Server.Power.EntitySystems
apcReceiver.Powered = powered;
Dirty(uid, apcReceiver, metadata);
var ev = new PowerChangedEvent(powered, apcReceiver.NetworkLoad.ReceivingPower);
var ev = new PowerChangedEvent(powered, isAlwaysPowered ? apcReceiver.Load : apcReceiver.NetworkLoad.ReceivingPower);
RaiseLocalEvent(uid, ref ev);
if (appearanceQuery.TryComp(uid, out var appearance))
@ -344,7 +345,10 @@ namespace Content.Server.Power.EntitySystems
var enumerator = AllEntityQuery<PowerConsumerComponent>();
while (enumerator.MoveNext(out var uid, out var consumer))
{
var newRecv = consumer.NetworkLoad.ReceivingPower;
var mapId = Transform(uid).MapUid;
var isAlwaysPowered = HasComp<AlwaysPoweredMapComponent>(mapId);
var newRecv = isAlwaysPowered ? consumer.DrawRate : consumer.NetworkLoad.ReceivingPower;
ref var lastRecv = ref consumer.LastReceived;
if (MathHelper.CloseToPercent(lastRecv, newRecv))
continue;
@ -363,8 +367,11 @@ namespace Content.Server.Power.EntitySystems
var enumerator = EntityQueryEnumerator<PowerNetworkBatteryComponent>();
while (enumerator.MoveNext(out var uid, out var powerNetBattery))
{
var mapId = Transform(uid).MapUid;
var isAlwaysPowered = HasComp<AlwaysPoweredMapComponent>(mapId);
var lastSupply = powerNetBattery.LastSupply;
var currentSupply = powerNetBattery.CurrentSupply;
var currentSupply = isAlwaysPowered ? powerNetBattery.MaxSupply : powerNetBattery.CurrentSupply;
if (lastSupply == 0f && currentSupply != 0f)
{
@ -378,6 +385,14 @@ namespace Content.Server.Power.EntitySystems
}
powerNetBattery.LastSupply = currentSupply;
if (isAlwaysPowered)
{
powerNetBattery.CurrentSupply = powerNetBattery.MaxSupply;
powerNetBattery.CurrentReceiving = 0;
powerNetBattery.CanCharge = false;
powerNetBattery.CanDischarge = true;
}
}
}

View file

@ -8,6 +8,7 @@ using Content.Server._Sunrise.TransitHub;
using Content.Server.Access.Systems;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chat.Systems;
using Content.Server.Communications;
using Content.Server.DeviceNetwork.Components;
@ -46,6 +47,10 @@ using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Server.GameTicking;
using Content.Shared._Sunrise.AlwaysPoweredMap;
using Content.Shared.Atmos;
using Content.Shared.Gravity;
using Content.Shared.Parallax;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Salvage;
using Robust.Shared.Audio;
@ -84,6 +89,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
[Dependency] private readonly BiomeSystem _biomes = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly AtmosphereSystem _atmos = default!;
private const float ShuttleSpawnBuffer = 1f;
@ -575,6 +581,35 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
return;
}
EnsureComp<NightDayMapLightComponent>(mapUid);
Log.Info($"Created transit hub grid {ToPrettyString(uids[0])} on map {ToPrettyString(mapUid)} for station {ToPrettyString(station)}");
EnsureComp<ProtectedGridComponent>(uids[0]);
// var template = _random.Pick(component.Biomes);
// _biomes.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>(template), mapLight: component.PlanetLightColor);
component.MapEntity = mapUid;
component.Entity = uids[0];
var moles = new float[Atmospherics.AdjustedNumberOfGases];
moles[(int) Gas.Oxygen] = 21.824779f;
moles[(int) Gas.Nitrogen] = 82.10312f;
var mixture = new GasMixture(moles, Atmospherics.T20C);
_atmos.SetMapAtmosphere(mapUid, false, mixture);
var gravity = EnsureComp<GravityComponent>(mapUid);
gravity.Enabled = true;
gravity.Inherent = true;
Dirty(mapUid, gravity);
var light = EnsureComp<MapLightComponent>(mapUid);
light.AmbientLightColor = Color.FromHex("#D8B059");
Dirty(mapUid, light);
// Sunrise-Start
var restricted = new RestrictedRangeComponent
{
@ -584,16 +619,10 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
AddComp(mapUid, restricted);
// Sunrise-End
EnsureComp<NightDayMapLightComponent>(mapUid);
Log.Info($"Created transit hub grid {ToPrettyString(uids[0])} on map {ToPrettyString(mapUid)} for station {ToPrettyString(station)}");
EnsureComp<ProtectedGridComponent>(uids[0]);
var template = _random.Pick(component.Biomes);
_biomes.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>(template), mapLight: component.PlanetLightColor);
component.MapEntity = mapUid;
component.Entity = uids[0];
EnsureComp<AlwaysPoweredMapComponent>(mapUid);
EnsureComp<ParallaxComponent>(mapUid, out var parallaxComponent);
parallaxComponent.Parallax = "Grass";
Dirty(mapUid, parallaxComponent);
_mapManager.DoMapInitialize(mapId);
// Sunrise-end

View file

@ -1,13 +1,18 @@
using System.Linq;
using System.Numerics;
using Content.Server._Sunrise.NightDayMapLight;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Maps;
using Content.Server.Parallax;
using Content.Server.Shuttles.Systems;
using Content.Shared._Sunrise.AlwaysPoweredMap;
using Content.Shared._Sunrise.Shuttles;
using Content.Shared._Sunrise.SunriseCCVars;
using Content.Shared.Atmos;
using Content.Shared.Gravity;
using Content.Shared.Parallax;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Salvage;
using Content.Shared.Shuttles.Components;
@ -15,6 +20,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Maps;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@ -35,6 +41,7 @@ public sealed class PlanetPrisonStationSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly ShuttleSystem _shuttle = default!;
[Dependency] private readonly AtmosphereSystem _atmos = default!;
private ISawmill _sawmill = default!;
@ -110,7 +117,7 @@ public sealed class PlanetPrisonStationSystem : EntitySystem
}
_chat.DispatchServerAnnouncement(Loc.GetString("planet-prison-select-map", ("stationName", gameMap.MapName)), Color.LightBlue);
_chat.DispatchServerAnnouncement(Loc.GetString("planet-prison-select-biome", ("biomeName", biome.ID)), Color.LightBlue);
// _chat.DispatchServerAnnouncement(Loc.GetString("planet-prison-select-biome", ("biomeName", biome.ID)), Color.LightBlue);
var uids = _gameTicker.LoadGameMap(gameMap, xform.MapID, mapOptions);
@ -130,7 +137,22 @@ public sealed class PlanetPrisonStationSystem : EntitySystem
EnsureComp<IgnoreFtlCheckComponent>(uids[0]);
component.PrisonGrid = uids[0];
_biomeSystem.EnsurePlanet(mapUid, biome);
var moles = new float[Atmospherics.AdjustedNumberOfGases];
moles[(int) Gas.Oxygen] = 21.824779f;
moles[(int) Gas.Nitrogen] = 82.10312f;
var mixture = new GasMixture(moles, Atmospherics.T20C);
_atmos.SetMapAtmosphere(mapUid, false, mixture);
var gravity = EnsureComp<GravityComponent>(mapUid);
gravity.Enabled = true;
gravity.Inherent = true;
Dirty(mapUid, gravity);
var light = EnsureComp<MapLightComponent>(mapUid);
light.AmbientLightColor = Color.FromHex("#D8B059");
Dirty(mapUid, light);
// Sunrise-Start
var restricted = new RestrictedRangeComponent
@ -141,11 +163,15 @@ public sealed class PlanetPrisonStationSystem : EntitySystem
AddComp(mapUid, restricted);
// Sunrise-End
EnsureComp<AlwaysPoweredMapComponent>(mapUid);
EnsureComp<NightDayMapLightComponent>(mapUid);
EnsureComp<ParallaxComponent>(mapUid, out var parallaxComponent);
parallaxComponent.Parallax = "Grass";
Dirty(mapUid, parallaxComponent);
var destComp = _entManager.EnsureComponent<FTLDestinationComponent>(mapUid);
destComp.BeaconsOnly = true;
_shuttle.SetFTLWhitelist(mapUid, component.ShuttleWhitelist);
}
}

View file

@ -0,0 +1,6 @@
using Robust.Shared.GameStates;
namespace Content.Shared._Sunrise.AlwaysPoweredMap;
[RegisterComponent, NetworkedComponent]
public sealed partial class AlwaysPoweredMapComponent : Component;

View file

@ -190,6 +190,13 @@ public sealed class SunriseCCVars
public static readonly CVarDef<int> MinPlayersPlanetPrison =
CVarDef.Create("planet_prison.min_players", 60, CVar.SERVERONLY);
/*
* MaxLoadedChunks
*/
public static readonly CVarDef<int> MaxLoadedChunks =
CVarDef.Create("chunk.max", 100, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
/**
* Roadmap
*/

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff