From b24ec5bc80cf8b027485b513a8b92e628a62d855 Mon Sep 17 00:00:00 2001 From: Red <96445749+TheShuEd@users.noreply.github.com> Date: Sun, 15 Jun 2025 21:25:58 +0300 Subject: [PATCH] Bugfixes (#1432) * fix #1428 * CodTenAlt review * fix map tests * real this time * fix #1429 * add wheat and cotton into victorian gardens trade faction * Update PostMapInitTest.cs --- .../CP14ReligionEntityBoundUserInterface.cs | 1 - .../Religion/CP14ReligionEntityWindow.xaml.cs | 1 + .../Religion/CP14ReligionVisionOverlay.cs | 4 +-- .../Tests/PostMapInitTest.cs | 2 +- .../Components/SpawnPointComponent.cs | 3 -- .../EntitySystems/SpawnPointSystem.cs | 2 +- .../CP14DemiplaneSystem.Stabilization.cs | 13 --------- .../CP14DemiplaneTravelingSystem.cs | 2 ++ .../_CP14/Passport/CP14PassportSystem.cs | 5 +++- .../CP14StationRandomJobsComponent.cs | 2 +- .../_CP14/Religion/CP14ReligionSystem.UI.cs | 4 --- .../_CP14/Religion/CP14ReligionSystem.cs | 8 ++++- ...4MagicEffectReligionRestrictedComponent.cs | 3 -- .../MagicSpell/Spells/CP14SpellGodTouch.cs | 1 + .../CP14SharedReligionGodSystem.Altars.cs | 1 + .../CP14SharedReligionGodSystem.Followers.cs | 7 +++-- ...CP14SharedReligionGodSystem.Observation.cs | 5 +--- .../Player/{Demigods => Patrons}/gods.yml | 0 .../Structures/Specific/Religion/base.yml | 2 +- .../_CP14/Trading/victoria_gardens.yml | 29 +++++++++++++++++-- 20 files changed, 53 insertions(+), 42 deletions(-) rename Resources/Prototypes/_CP14/Entities/Mobs/Player/{Demigods => Patrons}/gods.yml (100%) diff --git a/Content.Client/_CP14/Religion/CP14ReligionEntityBoundUserInterface.cs b/Content.Client/_CP14/Religion/CP14ReligionEntityBoundUserInterface.cs index ba517f05d8..8be8e1f51c 100644 --- a/Content.Client/_CP14/Religion/CP14ReligionEntityBoundUserInterface.cs +++ b/Content.Client/_CP14/Religion/CP14ReligionEntityBoundUserInterface.cs @@ -11,7 +11,6 @@ public sealed class CP14ReligionEntityBoundUserInterface : BoundUserInterface public CP14ReligionEntityBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { - IoCManager.InjectDependencies(this); } protected override void Open() diff --git a/Content.Client/_CP14/Religion/CP14ReligionEntityWindow.xaml.cs b/Content.Client/_CP14/Religion/CP14ReligionEntityWindow.xaml.cs index dd2545b5c4..629a90e894 100644 --- a/Content.Client/_CP14/Religion/CP14ReligionEntityWindow.xaml.cs +++ b/Content.Client/_CP14/Religion/CP14ReligionEntityWindow.xaml.cs @@ -11,6 +11,7 @@ namespace Content.Client._CP14.Religion; public sealed partial class CP14ReligionEntityWindow : DefaultWindow { [Dependency] private readonly ILogManager _log = default!; + private ISawmill Sawmill { get; init; } public event Action? OnTeleportAttempt; diff --git a/Content.Client/_CP14/Religion/CP14ReligionVisionOverlay.cs b/Content.Client/_CP14/Religion/CP14ReligionVisionOverlay.cs index ce1b5405fc..6c837e0713 100644 --- a/Content.Client/_CP14/Religion/CP14ReligionVisionOverlay.cs +++ b/Content.Client/_CP14/Religion/CP14ReligionVisionOverlay.cs @@ -31,6 +31,7 @@ public sealed class CP14ReligionVisionOverlay : Overlay private readonly Vector2[] _positions = new Vector2[MaxCount]; private readonly float[] _radii = new float[MaxCount]; private int _count = 0; + public CP14ReligionVisionOverlay() { IoCManager.InjectDependencies(this); @@ -40,12 +41,9 @@ public sealed class CP14ReligionVisionOverlay : Overlay _transform = _entManager.System(); if (_entManager.TryGetComponent(_player.LocalEntity, out var vision)) - { _religion = vision.Religion; - } } - protected override bool BeforeDraw(in OverlayDrawArgs args) { if (args.Viewport.Eye == null) diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index 78ae7ff7e6..03642a957f 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -401,7 +401,7 @@ namespace Content.IntegrationTests.Tests var jobs = new HashSet>(comp.SetupAvailableJobs.Keys); var spawnPoints = entManager.EntityQuery() - .Where(x => x.SpawnType == SpawnPointType.Job && x.Job != null) + .Where(x => x.SpawnType is SpawnPointType.Job or SpawnPointType.Unset && x.Job != null) //CP14 Job or Unset (only Job in upstream) .Select(x => x.Job.Value); jobs.ExceptWith(spawnPoints); diff --git a/Content.Server/Spawners/Components/SpawnPointComponent.cs b/Content.Server/Spawners/Components/SpawnPointComponent.cs index 16b24d6d62..c6d14dfeb3 100644 --- a/Content.Server/Spawners/Components/SpawnPointComponent.cs +++ b/Content.Server/Spawners/Components/SpawnPointComponent.cs @@ -27,7 +27,4 @@ public enum SpawnPointType LateJoin, Job, Observer, - //CP14 - Always, //Always use only these spawn point, and latejoin, and roundstart - //CP14 end } diff --git a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs index 56c01f64de..1a399a8678 100644 --- a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs +++ b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs @@ -33,7 +33,7 @@ public sealed class SpawnPointSystem : EntitySystem continue; //CP14 always spawn gods on gods spawnpoints - if (spawnPoint.SpawnType == SpawnPointType.Always && (args.Job == null || spawnPoint.Job == args.Job)) + if (spawnPoint.SpawnType == SpawnPointType.Unset && (args.Job == null || spawnPoint.Job == args.Job)) { possiblePositions.Clear(); possiblePositions.Add(xform.Coordinates); diff --git a/Content.Server/_CP14/Demiplane/CP14DemiplaneSystem.Stabilization.cs b/Content.Server/_CP14/Demiplane/CP14DemiplaneSystem.Stabilization.cs index a89bfd7e76..4d4f055000 100644 --- a/Content.Server/_CP14/Demiplane/CP14DemiplaneSystem.Stabilization.cs +++ b/Content.Server/_CP14/Demiplane/CP14DemiplaneSystem.Stabilization.cs @@ -83,26 +83,13 @@ public sealed partial class CP14DemiplaneSystem while (query.MoveNext(out var uid, out var stabilizer, out var xform)) { - if (!stabilizer.Enabled) - continue; - if (TryTeleportOutDemiplane(demiplane, uid)) { if (!safe) - { - var ev = new CP14DemiplaneUnsafeExit(); - RaiseLocalEvent(uid, ev); - _body.GibBody(uid); - } } } QueueDel(demiplane); } } - -public sealed class CP14DemiplaneUnsafeExit : EntityEventArgs -{ - -} diff --git a/Content.Server/_CP14/DemiplaneTraveling/CP14DemiplaneTravelingSystem.cs b/Content.Server/_CP14/DemiplaneTraveling/CP14DemiplaneTravelingSystem.cs index 6e6516c753..b1978c537c 100644 --- a/Content.Server/_CP14/DemiplaneTraveling/CP14DemiplaneTravelingSystem.cs +++ b/Content.Server/_CP14/DemiplaneTraveling/CP14DemiplaneTravelingSystem.cs @@ -117,6 +117,8 @@ public sealed partial class CP14DemiplaneTravelingSystem : EntitySystem { if (HasComp(ent)) continue; + if (HasComp(ent)) //TODO: make some generic way to whitelist entities from teleporting + continue; if (!_mind.TryGetMind(ent, out var mindId, out var mind)) continue; diff --git a/Content.Server/_CP14/Passport/CP14PassportSystem.cs b/Content.Server/_CP14/Passport/CP14PassportSystem.cs index 80ab0fcc4f..1b60833551 100644 --- a/Content.Server/_CP14/Passport/CP14PassportSystem.cs +++ b/Content.Server/_CP14/Passport/CP14PassportSystem.cs @@ -25,6 +25,9 @@ public sealed partial class CP14PassportSystem : EntitySystem private void OnPlayerSpawning(PlayerSpawnCompleteEvent ev) { + if (!TryComp(ev.Mob, out var inventory)) + return; + var passport = Spawn(PassportProto, Transform(ev.Mob).Coordinates); if (!TryComp(passport, out var paper)) @@ -39,7 +42,7 @@ public sealed partial class CP14PassportSystem : EntitySystem StampedName = Loc.GetString("cp14-passport-stamp") }, ""); - _inventory.TryEquip(ev.Mob, passport, "pocket1"); + _inventory.TryEquip(ev.Mob, passport, "pocket1", inventory: inventory); } private string GeneratePassportText(PlayerSpawnCompleteEvent ev) diff --git a/Content.Server/_CP14/RandomJobs/CP14StationRandomJobsComponent.cs b/Content.Server/_CP14/RandomJobs/CP14StationRandomJobsComponent.cs index 12c5d8582f..b269c243e8 100644 --- a/Content.Server/_CP14/RandomJobs/CP14StationRandomJobsComponent.cs +++ b/Content.Server/_CP14/RandomJobs/CP14StationRandomJobsComponent.cs @@ -16,7 +16,7 @@ public sealed partial class CP14StationRandomJobsComponent : Component public sealed partial class CP14RandomJobEntry { [DataField(required: true)] - public List> Jobs = default!; + public List> Jobs = new(); [DataField(required: true)] public MinMax Count = new(1, 1); diff --git a/Content.Server/_CP14/Religion/CP14ReligionSystem.UI.cs b/Content.Server/_CP14/Religion/CP14ReligionSystem.UI.cs index 4d46b02b5c..96bf35ac03 100644 --- a/Content.Server/_CP14/Religion/CP14ReligionSystem.UI.cs +++ b/Content.Server/_CP14/Religion/CP14ReligionSystem.UI.cs @@ -25,16 +25,12 @@ public sealed partial class CP14ReligionGodSystem if (TryComp(target, out var altar)) { if (altar.Religion == ent.Comp.Religion) - { canTeleport = true; - } } else if (TryComp(target, out var follower)) { if (follower.Religion == ent.Comp.Religion) - { canTeleport = true; - } } if (!canTeleport) diff --git a/Content.Server/_CP14/Religion/CP14ReligionSystem.cs b/Content.Server/_CP14/Religion/CP14ReligionSystem.cs index 394c6931e9..991f620cbd 100644 --- a/Content.Server/_CP14/Religion/CP14ReligionSystem.cs +++ b/Content.Server/_CP14/Religion/CP14ReligionSystem.cs @@ -25,6 +25,12 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; + /// + /// If ReligionObserver receives a radius higher than this value, this entity will automatically be placed in PvsOverride for the god in order to function correctly outside of the player's PVS. + /// + /// Maybe there is a variable for the distance outside the screen in PVS, I don't know. This number works best + private const float ObservationOverrideRadius = 6.5f; + public override void Initialize() { base.Initialize(); @@ -197,7 +203,7 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem if (!observer.Observation.ContainsKey(ent.Comp.Religion.Value)) continue; - if (observer.Observation[ent.Comp.Religion.Value] <= 6.5f) //Maybe there is a variable for the distance outside the screen in PVS, I don't know. This number works best + if (observer.Observation[ent.Comp.Religion.Value] <= ObservationOverrideRadius) continue; ent.Comp.PvsOverridedObservers.Add(uid); diff --git a/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectReligionRestrictedComponent.cs b/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectReligionRestrictedComponent.cs index 11563950ce..25eca4eb4b 100644 --- a/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectReligionRestrictedComponent.cs +++ b/Content.Shared/_CP14/MagicSpell/Components/CP14MagicEffectReligionRestrictedComponent.cs @@ -1,6 +1,3 @@ -using Content.Shared._CP14.MagicSpellStorage; -using Content.Shared.FixedPoint; - namespace Content.Shared._CP14.MagicSpell.Components; /// diff --git a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellGodTouch.cs b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellGodTouch.cs index 4121e3b52a..1fe4675080 100644 --- a/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellGodTouch.cs +++ b/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellGodTouch.cs @@ -18,6 +18,7 @@ public sealed partial class CP14SpellGodTouch : CP14SpellEffect entManager.EventBus.RaiseLocalEvent(args.Target.Value, ev); } } + public sealed class CP14GodTouchEvent(ProtoId religion) : EntityEventArgs { public ProtoId Religion = religion; diff --git a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Altars.cs b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Altars.cs index a653d63f48..e9e29777d9 100644 --- a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Altars.cs +++ b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Altars.cs @@ -10,6 +10,7 @@ namespace Content.Shared._CP14.Religion.Systems; public abstract partial class CP14SharedReligionGodSystem { [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; + private void InitializeAltars() { SubscribeLocalEvent>(GetAltVerb); diff --git a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Followers.cs b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Followers.cs index 981f2f3ee5..4ad072f40e 100644 --- a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Followers.cs +++ b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Followers.cs @@ -18,6 +18,9 @@ public abstract partial class CP14SharedReligionGodSystem [Dependency] protected readonly SharedMindSystem Mind = default!; [Dependency] private readonly FollowerSystem _follower = default!; + [ValidatePrototypeId] + public const string AlertProto = "CP14DivineOffer"; + private void InitializeFollowers() { SubscribeLocalEvent(OnPendingFollowerInit); @@ -105,12 +108,12 @@ public abstract partial class CP14SharedReligionGodSystem private void OnPendingFollowerInit(Entity ent, ref MapInitEvent args) { - _alerts.ShowAlert(ent, "CP14DivineOffer"); + _alerts.ShowAlert(ent, AlertProto); } private void OnPendingFollowerShutdown(Entity ent, ref ComponentShutdown args) { - _alerts.ClearAlert(ent, "CP14DivineOffer"); + _alerts.ClearAlert(ent, AlertProto); } private bool CanBecomeFollower(EntityUid target, ProtoId religion) diff --git a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Observation.cs b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Observation.cs index c2ee697f4a..dc5a3f5174 100644 --- a/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Observation.cs +++ b/Content.Shared/_CP14/Religion/Systems/CP14SharedReligionGodSystem.Observation.cs @@ -37,19 +37,16 @@ public abstract partial class CP14SharedReligionGodSystem var newRange = Math.Clamp(observer.Observation[religion] + range, 0, float.MaxValue); if (newRange <= 0) - { observer.Observation.Remove(religion); - } else - { observer.Observation[religion] = newRange; - } } else { // Otherwise, add a new observation for the religion. observer.Observation.Add(religion, range); } + Dirty(target, observer); } diff --git a/Resources/Prototypes/_CP14/Entities/Mobs/Player/Demigods/gods.yml b/Resources/Prototypes/_CP14/Entities/Mobs/Player/Patrons/gods.yml similarity index 100% rename from Resources/Prototypes/_CP14/Entities/Mobs/Player/Demigods/gods.yml rename to Resources/Prototypes/_CP14/Entities/Mobs/Player/Patrons/gods.yml diff --git a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Religion/base.yml b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Religion/base.yml index c7ab0cc7d5..1ca572b8da 100644 --- a/Resources/Prototypes/_CP14/Entities/Structures/Specific/Religion/base.yml +++ b/Resources/Prototypes/_CP14/Entities/Structures/Specific/Religion/base.yml @@ -40,4 +40,4 @@ - type: CP14ReligionAltar canBeConverted: false - type: SpawnPoint - spawn_type: Always \ No newline at end of file + spawn_type: Unset \ No newline at end of file diff --git a/Resources/Prototypes/_CP14/Trading/victoria_gardens.yml b/Resources/Prototypes/_CP14/Trading/victoria_gardens.yml index f9cb01c667..7ebaf31212 100644 --- a/Resources/Prototypes/_CP14/Trading/victoria_gardens.yml +++ b/Resources/Prototypes/_CP14/Trading/victoria_gardens.yml @@ -66,13 +66,24 @@ product: CP14FoodOnion count: 3 +- type: cp14TradingPosition + id: CP14Wheat + faction: VictoriaGardens + uiPosition: 6 + icon: + sprite: _CP14/Objects/Flora/Farm/wheat.rsi + state: base1 + service: !type:CP14BuyItemsService + product: CP14Wheat + count: 3 + - type: cp14TradingPosition id: CP14FloorTileGrassBag faction: VictoriaGardens priceMarkup: 2 reputationLevel: 0 - uiPosition: 7 + uiPosition: 8 icon: sprite: _CP14/Objects/Specific/Farming/grass_seeds.rsi state: grass @@ -85,7 +96,7 @@ faction: VictoriaGardens priceMarkup: 2 reputationLevel: 0 - uiPosition: 8 + uiPosition: 9 icon: sprite: _CP14/Objects/Specific/Farming/grass_seeds.rsi state: grass2 @@ -98,7 +109,7 @@ faction: VictoriaGardens priceMarkup: 2 reputationLevel: 0 - uiPosition: 9 + uiPosition: 10 icon: sprite: _CP14/Objects/Specific/Farming/grass_seeds.rsi state: grass3 @@ -130,4 +141,16 @@ state: base1 service: !type:CP14BuyItemsService product: CP14FoodPumpkin + count: 3 + +- type: cp14TradingPosition + id: CP14Cotton + faction: VictoriaGardens + reputationLevel: 1 + uiPosition: 2 + icon: + sprite: _CP14/Objects/Flora/Farm/cotton.rsi + state: base1 + service: !type:CP14BuyItemsService + product: CP14Cotton count: 3 \ No newline at end of file