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. /// Accumulation of the spawn timer.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("spawnAccumulator")] [ViewVariables(VVAccess.ReadWrite), DataField("spawnAccumulator")]
public float SpawnAccumulator = 60f; public float SpawnAccumulator = 30f;
/// <summary> /// <summary>
/// How long it takes for a new spawn to be added. /// How long it takes for a new spawn to be added.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("spawnCooldown")] [ViewVariables(VVAccess.ReadWrite), DataField("spawnCooldown")]
public float SpawnCooldown = 60f; public float SpawnCooldown = 30f;
[ViewVariables(VVAccess.ReadWrite), DataField("spawn", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] [ViewVariables(VVAccess.ReadWrite), DataField("spawn", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SpawnPrototype = "MobCarpDragon"; public string SpawnPrototype = "MobCarpDragon";

View File

@@ -33,6 +33,13 @@ namespace Content.Server.Dragon
[Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = 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() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -75,7 +82,7 @@ namespace Content.Server.Dragon
} }
// At max rifts // At max rifts
if (comp.Rifts.Count >= 3) if (comp.Rifts.Count >= RiftsAllowed)
{ {
continue; continue;
} }
@@ -121,7 +128,7 @@ namespace Content.Server.Dragon
comp.SpawnAccumulator += frameTime; 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; comp.State = DragonRiftState.AlmostFinished;
Dirty(comp); Dirty(comp);
@@ -197,7 +204,7 @@ namespace Content.Server.Dragon
return; return;
} }
if (component.Rifts.Count >= 3) if (component.Rifts.Count >= RiftsAllowed)
{ {
_popupSystem.PopupEntity(Loc.GetString("carp-rift-max"), uid, Filter.Entities(uid)); _popupSystem.PopupEntity(Loc.GetString("carp-rift-max"), uid, Filter.Entities(uid));
return; return;
@@ -218,6 +225,15 @@ namespace Content.Server.Dragon
return; 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); var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
component.Rifts.Add(carpUid); component.Rifts.Add(carpUid);
Comp<DragonRiftComponent>(carpUid).Dragon = uid; Comp<DragonRiftComponent>(carpUid).Dragon = uid;
@@ -244,6 +260,13 @@ namespace Content.Server.Dragon
_audioSystem.PlayPvs(component.SoundDeath, uid, component.SoundDeath.Params); _audioSystem.PlayPvs(component.SoundDeath, uid, component.SoundDeath.Params);
component.DragonStomach.EmptyContainer(); 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-examine = It is [color=yellow]{$percentage}%[/color] charged!
carp-rift-max = You have reached your maximum amount of rifts carp-rift-max = You have reached your maximum amount of rifts
carp-rift-anchor = Rifts require a stable surface to spawn. 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-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. carp-rift-destroyed = A rift has been destroyed! You are now weakened temporarily.

View File

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