Dragon rift fixes (#10428)

This commit is contained in:
metalgearsloth
2022-08-08 14:19:53 +10:00
committed by GitHub
parent fcd005cf06
commit 3f5a5d46b6
4 changed files with 30 additions and 6 deletions

View File

@@ -27,13 +27,13 @@ public sealed class DragonRiftComponent : SharedDragonRiftComponent
/// Accumulation of the spawn timer.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("spawnAccumulator")]
public float SpawnAccumulator = 60f;
public float SpawnAccumulator = 30f;
/// <summary>
/// How long it takes for a new spawn to be added.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("spawnCooldown")]
public float SpawnCooldown = 60f;
public float SpawnCooldown = 30f;
[ViewVariables(VVAccess.ReadWrite), DataField("spawn", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SpawnPrototype = "MobCarpDragon";

View File

@@ -33,6 +33,13 @@ namespace Content.Server.Dragon
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
/// <summary>
/// Minimum distance between 2 rifts allowed.
/// </summary>
private const int RiftRange = 15;
private const int RiftsAllowed = 3;
public override void Initialize()
{
base.Initialize();
@@ -75,7 +82,7 @@ namespace Content.Server.Dragon
}
// At max rifts
if (comp.Rifts.Count >= 3)
if (comp.Rifts.Count >= RiftsAllowed)
{
continue;
}
@@ -121,7 +128,7 @@ namespace Content.Server.Dragon
comp.SpawnAccumulator += frameTime;
if (comp.State < DragonRiftState.AlmostFinished && comp.SpawnAccumulator > comp.MaxAccumulator / 2f)
if (comp.State < DragonRiftState.AlmostFinished && comp.Accumulator > comp.MaxAccumulator / 2f)
{
comp.State = DragonRiftState.AlmostFinished;
Dirty(comp);
@@ -197,7 +204,7 @@ namespace Content.Server.Dragon
return;
}
if (component.Rifts.Count >= 3)
if (component.Rifts.Count >= RiftsAllowed)
{
_popupSystem.PopupEntity(Loc.GetString("carp-rift-max"), uid, Filter.Entities(uid));
return;
@@ -218,6 +225,15 @@ namespace Content.Server.Dragon
return;
}
foreach (var (_, riftXform) in EntityQuery<DragonRiftComponent, TransformComponent>(true))
{
if (riftXform.Coordinates.InRange(EntityManager, xform.Coordinates, RiftRange))
{
_popupSystem.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, Filter.Entities(uid));
return;
}
}
var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
component.Rifts.Add(carpUid);
Comp<DragonRiftComponent>(carpUid).Dragon = uid;
@@ -244,6 +260,13 @@ namespace Content.Server.Dragon
_audioSystem.PlayPvs(component.SoundDeath, uid, component.SoundDeath.Params);
component.DragonStomach.EmptyContainer();
foreach (var rift in component.Rifts)
{
QueueDel(rift);
}
component.Rifts.Clear();
}
}

View File

@@ -17,6 +17,7 @@ carp-rift-duplicate = Cannot have 2 charging rifts at the same time!
carp-rift-examine = It is [color=yellow]{$percentage}%[/color] charged!
carp-rift-max = You have reached your maximum amount of rifts
carp-rift-anchor = Rifts require a stable surface to spawn.
carp-rift-proximity = Too close to a nearby rift! Need to be at least {$proximity}m away.
carp-rift-weakened = You are unable to summon more rifts in your weakened state.
carp-rift-destroyed = A rift has been destroyed! You are now weakened temporarily.

View File

@@ -148,7 +148,7 @@
name: space carp
id: MobCarpDragon
suffix: DragonBrood
parent: MobCarp
parent: BaseMobCarp
components:
- type: GhostTakeoverAvailable
makeSentient: true