Compare commits

...

1 Commits

Author SHA1 Message Date
comasqw
06ca2810c9 Demiplane Crystal 2024-12-17 14:39:37 +04:00
3 changed files with 36 additions and 0 deletions

View File

@@ -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<CP14DemiplaneCrystalComponent>(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<CP14DemiplaneComponent>(Transform(generator).MapUid) || !HasComp<MapGridComponent>(_transform.GetParentUid(args.User)))
{

View File

@@ -0,0 +1,6 @@
namespace Content.Server._CP14.Demiplane.Components;
[RegisterComponent, Access(typeof(CP14DemiplaneSystem))]
public sealed partial class CP14DemiplaneCrystalComponent : Component
{
}

View File

@@ -23,4 +23,16 @@ public sealed partial class CP14DemiplaneGeneratorDataComponent : Component
[DataField(required: true)]
public Dictionary<ProtoId<CP14DemiplaneModifierCategoryPrototype>, 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;
}