From 06ca2810c9a394127809adf236264ec710a5b23c Mon Sep 17 00:00:00 2001 From: comasqw Date: Tue, 17 Dec 2024 14:39:37 +0400 Subject: [PATCH] Demiplane Crystal --- .../Demiplane/CP14DemiplanSystem.Generation.cs | 18 ++++++++++++++++++ .../CP14DemiplaneCrystalComponent.cs | 6 ++++++ .../CP14DemiplaneGeneratorDataComponent.cs | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 Content.Server/_CP14/Demiplane/Components/CP14DemiplaneCrystalComponent.cs diff --git a/Content.Server/_CP14/Demiplane/CP14DemiplanSystem.Generation.cs b/Content.Server/_CP14/Demiplane/CP14DemiplanSystem.Generation.cs index 026f7c40d2..e90934686e 100644 --- a/Content.Server/_CP14/Demiplane/CP14DemiplanSystem.Generation.cs +++ b/Content.Server/_CP14/Demiplane/CP14DemiplanSystem.Generation.cs @@ -26,6 +26,7 @@ public sealed partial class CP14DemiplaneSystem private const double JobMaxTime = 0.002; [Dependency] private readonly ExamineSystemShared _examine = default!; + [Dependency] private readonly EntityLookupSystem _lookup = default!; private void InitGeneration() { @@ -141,6 +142,23 @@ public sealed partial class CP14DemiplaneSystem if (generator.Comp.Location is null) return; + var curTime = _timing.CurTime; + + if (curTime < generator.Comp.LastUseTime + generator.Comp.UseDelay) + return; + + generator.Comp.LastUseTime = curTime; + + if (generator.Comp.NeedDemiplaneCrystal) + { + var demiplaneCrystals = _lookup.GetEntitiesInRange(Transform(generator).Coordinates, generator.Comp.DemiplaneCrystalRange); + if (demiplaneCrystals.Count == 0) + { + return; + } + + } + //We cant open demiplan in another demiplan or if parent is not Map if (HasComp(Transform(generator).MapUid) || !HasComp(_transform.GetParentUid(args.User))) { diff --git a/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneCrystalComponent.cs b/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneCrystalComponent.cs new file mode 100644 index 0000000000..cb7a300a37 --- /dev/null +++ b/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneCrystalComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Server._CP14.Demiplane.Components; + +[RegisterComponent, Access(typeof(CP14DemiplaneSystem))] +public sealed partial class CP14DemiplaneCrystalComponent : Component +{ +} diff --git a/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneGeneratorDataComponent.cs b/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneGeneratorDataComponent.cs index 06ee11f714..36aa142e9c 100644 --- a/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneGeneratorDataComponent.cs +++ b/Content.Server/_CP14/Demiplane/Components/CP14DemiplaneGeneratorDataComponent.cs @@ -23,4 +23,16 @@ public sealed partial class CP14DemiplaneGeneratorDataComponent : Component [DataField(required: true)] public Dictionary, float> Limits; + + [DataField] + public bool NeedDemiplaneCrystal = true; + + [DataField] + public float DemiplaneCrystalRange = 15f; + + [DataField] + public TimeSpan UseDelay = TimeSpan.FromSeconds(1.0); + + [DataField] + public TimeSpan LastUseTime = TimeSpan.Zero; }