* fix #1428

* CodTenAlt review

* fix map tests

* real this time

* fix #1429

* add wheat and cotton into victorian gardens trade faction

* Update PostMapInitTest.cs
This commit is contained in:
Red
2025-06-15 21:25:58 +03:00
committed by GitHub
parent 4dfaf6a16e
commit b24ec5bc80
20 changed files with 53 additions and 42 deletions

View File

@@ -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()

View File

@@ -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<NetEntity>? OnTeleportAttempt;

View File

@@ -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<SharedTransformSystem>();
if (_entManager.TryGetComponent<CP14ReligionEntityComponent>(_player.LocalEntity, out var vision))
{
_religion = vision.Religion;
}
}
protected override bool BeforeDraw(in OverlayDrawArgs args)
{
if (args.Viewport.Eye == null)

View File

@@ -401,7 +401,7 @@ namespace Content.IntegrationTests.Tests
var jobs = new HashSet<ProtoId<JobPrototype>>(comp.SetupAvailableJobs.Keys);
var spawnPoints = entManager.EntityQuery<SpawnPointComponent>()
.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);

View File

@@ -27,7 +27,4 @@ public enum SpawnPointType
LateJoin,
Job,
Observer,
//CP14
Always, //Always use only these spawn point, and latejoin, and roundstart
//CP14 end
}

View File

@@ -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);

View File

@@ -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
{
}

View File

@@ -117,6 +117,8 @@ public sealed partial class CP14DemiplaneTravelingSystem : EntitySystem
{
if (HasComp<GhostComponent>(ent))
continue;
if (HasComp<CP14ReligionEntityComponent>(ent)) //TODO: make some generic way to whitelist entities from teleporting
continue;
if (!_mind.TryGetMind(ent, out var mindId, out var mind))
continue;

View File

@@ -25,6 +25,9 @@ public sealed partial class CP14PassportSystem : EntitySystem
private void OnPlayerSpawning(PlayerSpawnCompleteEvent ev)
{
if (!TryComp<InventoryComponent>(ev.Mob, out var inventory))
return;
var passport = Spawn(PassportProto, Transform(ev.Mob).Coordinates);
if (!TryComp<PaperComponent>(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)

View File

@@ -16,7 +16,7 @@ public sealed partial class CP14StationRandomJobsComponent : Component
public sealed partial class CP14RandomJobEntry
{
[DataField(required: true)]
public List<ProtoId<JobPrototype>> Jobs = default!;
public List<ProtoId<JobPrototype>> Jobs = new();
[DataField(required: true)]
public MinMax Count = new(1, 1);

View File

@@ -25,16 +25,12 @@ public sealed partial class CP14ReligionGodSystem
if (TryComp<CP14ReligionAltarComponent>(target, out var altar))
{
if (altar.Religion == ent.Comp.Religion)
{
canTeleport = true;
}
}
else if (TryComp<CP14ReligionFollowerComponent>(target, out var follower))
{
if (follower.Religion == ent.Comp.Religion)
{
canTeleport = true;
}
}
if (!canTeleport)

View File

@@ -25,6 +25,12 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
/// <summary>
/// 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.
/// </summary>
/// <remarks> Maybe there is a variable for the distance outside the screen in PVS, I don't know. This number works best</remarks>
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);

View File

@@ -1,6 +1,3 @@
using Content.Shared._CP14.MagicSpellStorage;
using Content.Shared.FixedPoint;
namespace Content.Shared._CP14.MagicSpell.Components;
/// <summary>

View File

@@ -18,6 +18,7 @@ public sealed partial class CP14SpellGodTouch : CP14SpellEffect
entManager.EventBus.RaiseLocalEvent(args.Target.Value, ev);
}
}
public sealed class CP14GodTouchEvent(ProtoId<CP14ReligionPrototype> religion) : EntityEventArgs
{
public ProtoId<CP14ReligionPrototype> Religion = religion;

View File

@@ -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<CP14ReligionAltarComponent, GetVerbsEvent<AlternativeVerb>>(GetAltVerb);

View File

@@ -18,6 +18,9 @@ public abstract partial class CP14SharedReligionGodSystem
[Dependency] protected readonly SharedMindSystem Mind = default!;
[Dependency] private readonly FollowerSystem _follower = default!;
[ValidatePrototypeId<AlertPrototype>]
public const string AlertProto = "CP14DivineOffer";
private void InitializeFollowers()
{
SubscribeLocalEvent<CP14ReligionPendingFollowerComponent, MapInitEvent>(OnPendingFollowerInit);
@@ -105,12 +108,12 @@ public abstract partial class CP14SharedReligionGodSystem
private void OnPendingFollowerInit(Entity<CP14ReligionPendingFollowerComponent> ent, ref MapInitEvent args)
{
_alerts.ShowAlert(ent, "CP14DivineOffer");
_alerts.ShowAlert(ent, AlertProto);
}
private void OnPendingFollowerShutdown(Entity<CP14ReligionPendingFollowerComponent> ent, ref ComponentShutdown args)
{
_alerts.ClearAlert(ent, "CP14DivineOffer");
_alerts.ClearAlert(ent, AlertProto);
}
private bool CanBecomeFollower(EntityUid target, ProtoId<CP14ReligionPrototype> religion)

View File

@@ -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);
}

View File

@@ -40,4 +40,4 @@
- type: CP14ReligionAltar
canBeConverted: false
- type: SpawnPoint
spawn_type: Always
spawn_type: Unset

View File

@@ -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