Magic staves + wands (#9070)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Content.Shared.Polymorph;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Polymorph.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class PolymorphOnCollideComponent : Component
|
||||
{
|
||||
[DataField("polymorph", required: true, customTypeSerializer:typeof(PrototypeIdSerializer<PolymorphPrototype>))]
|
||||
public string Polymorph = default!;
|
||||
|
||||
[DataField("whitelist", required: true)]
|
||||
public EntityWhitelist Whitelist = default!;
|
||||
|
||||
[DataField("blacklist")]
|
||||
public EntityWhitelist? Blacklist;
|
||||
|
||||
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Magic/forcewall.ogg");
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Content.Server.Polymorph.Components;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Polymorph.Systems;
|
||||
|
||||
public partial class PolymorphableSystem
|
||||
{
|
||||
// Need to do this so we don't get a collection enumeration error in physics by polymorphing
|
||||
// an entity we're colliding with
|
||||
private Queue<PolymorphQueuedData> _queuedPolymorphUpdates = new();
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
while (_queuedPolymorphUpdates.TryDequeue(out var data))
|
||||
{
|
||||
if (Deleted(data.Ent))
|
||||
continue;
|
||||
|
||||
var ent = PolymorphEntity(data.Ent, data.Polymorph);
|
||||
if (ent != null)
|
||||
{
|
||||
SoundSystem.Play(data.Sound.GetSound(), Filter.Pvs(ent.Value, entityManager: EntityManager),
|
||||
ent.Value, data.Sound.Params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeCollide()
|
||||
{
|
||||
SubscribeLocalEvent<PolymorphOnCollideComponent, StartCollideEvent>(OnPolymorphCollide);
|
||||
}
|
||||
|
||||
private void OnPolymorphCollide(EntityUid uid, PolymorphOnCollideComponent component, StartCollideEvent args)
|
||||
{
|
||||
if (args.OurFixture.ID != SharedProjectileSystem.ProjectileFixture)
|
||||
return;
|
||||
|
||||
var other = args.OtherFixture.Body.Owner;
|
||||
if (!component.Whitelist.IsValid(other)
|
||||
|| component.Blacklist != null && component.Blacklist.IsValid(other))
|
||||
return;
|
||||
|
||||
_queuedPolymorphUpdates.Enqueue(new (other, component.Sound, component.Polymorph));
|
||||
}
|
||||
}
|
||||
|
||||
struct PolymorphQueuedData
|
||||
{
|
||||
public EntityUid Ent;
|
||||
public SoundSpecifier Sound;
|
||||
public string Polymorph;
|
||||
|
||||
public PolymorphQueuedData(EntityUid ent, SoundSpecifier sound, string polymorph)
|
||||
{
|
||||
Ent = ent;
|
||||
Sound = sound;
|
||||
Polymorph = polymorph;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Buckle.Components;
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Mind.Commands;
|
||||
@@ -12,8 +13,11 @@ using Content.Shared.Damage;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Polymorph;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -39,6 +43,7 @@ namespace Content.Server.Polymorph.Systems
|
||||
SubscribeLocalEvent<PolymorphableComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<PolymorphableComponent, PolymorphActionEvent>(OnPolymorphActionEvent);
|
||||
|
||||
InitializeCollide();
|
||||
InitializeMap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user