Magic 3 (#340)
* - add: Some tweaks and localization. * - add: Teleport spell. * - tweak: Tweak wizard hardsuit. * - add: Turn off shield on cast. * - add: New wizard clothes & update wizard shuttle, * - remove: Remove old clothes from shuttle. * - fix: No teleporting to centcomm.
This commit is contained in:
@@ -3,17 +3,21 @@ using System.Numerics;
|
||||
using Content.Server._White.IncorporealSystem;
|
||||
using Content.Server._White.Wizard.Magic.Amaterasu;
|
||||
using Content.Server._White.Wizard.Magic.Other;
|
||||
using Content.Server._White.Wizard.Teleport;
|
||||
using Content.Server.Abilities.Mime;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Lightning;
|
||||
using Content.Server.Magic;
|
||||
using Content.Server.Singularity.EntitySystems;
|
||||
using Content.Server.Standing;
|
||||
using Content.Server.Weapons.Ranged.Systems;
|
||||
using Content.Shared._White.BetrayalDagger;
|
||||
using Content.Shared._White.Events;
|
||||
using Content.Shared._White.Wizard;
|
||||
using Content.Shared._White.Wizard.Magic;
|
||||
using Content.Shared.Actions;
|
||||
@@ -36,6 +40,7 @@ using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server._White.Wizard.Magic;
|
||||
@@ -64,6 +69,8 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
[Dependency] private readonly EmpSystem _empSystem = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly StandingStateSystem _standing = default!;
|
||||
[Dependency] private readonly TelefragSystem _telefrag = default!;
|
||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,6 +78,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<TeleportSpellEvent>(OnTeleportSpell);
|
||||
SubscribeLocalEvent<InstantRecallSpellEvent>(OnInstantRecallSpell);
|
||||
SubscribeLocalEvent<MimeTouchSpellEvent>(OnMimeTouchSpell);
|
||||
SubscribeLocalEvent<BananaTouchSpellEvent>(OnBananaTouchSpell);
|
||||
@@ -87,6 +95,26 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
SubscribeLocalEvent<MagicComponent, BeforeCastSpellEvent>(OnBeforeCastSpell);
|
||||
}
|
||||
|
||||
#region Teleport
|
||||
|
||||
private void OnTeleportSpell(TeleportSpellEvent msg)
|
||||
{
|
||||
if (!CanCast(msg))
|
||||
return;
|
||||
|
||||
if (!TryComp(msg.Performer, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
var eui = new TeleportSpellEui(msg.Performer);
|
||||
_euiManager.OpenEui(eui, actor.PlayerSession);
|
||||
eui.StateDirty();
|
||||
|
||||
msg.Handled = true;
|
||||
Speak(msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instant Recall
|
||||
|
||||
private void OnInstantRecallSpell(InstantRecallSpellEvent msg)
|
||||
@@ -289,6 +317,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
if (!foundTeleportPos)
|
||||
return;
|
||||
|
||||
_telefrag.Telefrag(coords, msg.Performer);
|
||||
_transformSystem.SetCoordinates(msg.Performer, coords);
|
||||
_transformSystem.AttachToGridOrMap(msg.Performer);
|
||||
|
||||
@@ -404,6 +433,8 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
private void CardsSpellDefault(CardsSpellEvent msg)
|
||||
{
|
||||
TurnOffShield(msg.Performer);
|
||||
|
||||
var xform = Transform(msg.Performer);
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
@@ -428,6 +459,8 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
private void CardsSpellCharge(CardsSpellEvent msg)
|
||||
{
|
||||
TurnOffShield(msg.Performer);
|
||||
|
||||
var xform = Transform(msg.Performer);
|
||||
|
||||
var count = 10 + 10 * msg.ChargeLevel;
|
||||
@@ -466,6 +499,7 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
Del(msg.TargetUid);
|
||||
var item = Spawn(msg.Prototype);
|
||||
_handsSystem.TryPickupAnyHand(msg.Performer, item);
|
||||
TurnOffShield(msg.Performer);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -504,6 +538,8 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
private void FireballSpellDefault(FireballSpellEvent msg)
|
||||
{
|
||||
TurnOffShield(msg.Performer);
|
||||
|
||||
var xform = Transform(msg.Performer);
|
||||
|
||||
foreach (var pos in _magicSystem.GetSpawnPositions(xform, msg.Pos))
|
||||
@@ -662,12 +698,14 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
private void ArcSpellCharge(ArcSpellEvent msg)
|
||||
{
|
||||
_lightning.ShootRandomLightnings(msg.Performer, 2f * msg.ChargeLevel, msg.ChargeLevel * 2, "WizardLightning", 1,
|
||||
_lightning.ShootRandomLightnings(msg.Performer, 1.5f * msg.ChargeLevel, msg.ChargeLevel * 2, "WizardLightning", 2,
|
||||
caster: msg.Performer);
|
||||
}
|
||||
|
||||
private void ArcSpellAlt(ArcSpellEvent msg)
|
||||
{
|
||||
TurnOffShield(msg.Performer);
|
||||
|
||||
var xform = Transform(msg.Performer);
|
||||
|
||||
foreach (var pos in _magicSystem.GetSpawnPositions(xform, msg.Pos))
|
||||
@@ -693,6 +731,11 @@ public sealed class WizardSpellsSystem : EntitySystem
|
||||
|
||||
#region Helpers
|
||||
|
||||
private void TurnOffShield(EntityUid uid)
|
||||
{
|
||||
RaiseLocalEvent(uid, new EnergyDomeClothesTurnOffEvent());
|
||||
}
|
||||
|
||||
private bool CanCast(BaseActionEvent msg)
|
||||
{
|
||||
return !msg.Handled && CheckRequirements(msg.Action, msg.Performer) &&
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Content.Server._White.Wizard.Teleport;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class SpawnTeleportLocationComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server._White.Wizard.Teleport;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class TeleportLocationComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string Location = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Content.Server.Pinpointer;
|
||||
using Content.Server.Warps;
|
||||
|
||||
namespace Content.Server._White.Wizard.Teleport;
|
||||
|
||||
public sealed class TeleportLocationSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SpawnTeleportLocationComponent, MapInitEvent>(OnMapInit,
|
||||
after: new[] {typeof(NavMapSystem)});
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<SpawnTeleportLocationComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
if (!TryComp(ent, out WarpPointComponent? warpPoint) || warpPoint.Location == null)
|
||||
return;
|
||||
|
||||
var newEnt = Spawn(null, Transform(ent).Coordinates);
|
||||
var xForm = EnsureComp<TransformComponent>(newEnt);
|
||||
_transformSystem.AttachToGridOrMap(newEnt, xForm);
|
||||
var location = EnsureComp<TeleportLocationComponent>(newEnt);
|
||||
location.Location = warpPoint.Location;
|
||||
}
|
||||
}
|
||||
102
Content.Server/_White/Wizard/Teleport/TeleportSpellEui.cs
Normal file
102
Content.Server/_White/Wizard/Teleport/TeleportSpellEui.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System.Linq;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared._White.Wizard.Teleport;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.Timing;
|
||||
using TeleportSpellEuiState = Content.Shared._White.Wizard.Teleport.TeleportSpellEuiState;
|
||||
|
||||
namespace Content.Server._White.Wizard.Teleport;
|
||||
|
||||
public sealed class TeleportSpellEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly EntityManager _entityManager = default!;
|
||||
private readonly SharedTransformSystem _transformSystem;
|
||||
private readonly StationSystem _station;
|
||||
private readonly PopupSystem _popupSystem;
|
||||
|
||||
private readonly EntityUid _performer;
|
||||
|
||||
private bool _used;
|
||||
|
||||
public TeleportSpellEui(EntityUid performer)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_transformSystem = _entityManager.System<SharedTransformSystem>();
|
||||
_station = _entityManager.System<StationSystem>();
|
||||
_popupSystem = _entityManager.System<PopupSystem>();
|
||||
|
||||
_performer = performer;
|
||||
|
||||
Timer.Spawn(TimeSpan.FromSeconds(10), Close);
|
||||
}
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
var locationQuery = _entityManager.EntityQueryEnumerator<TeleportLocationComponent, TransformComponent>();
|
||||
var state = new TeleportSpellEuiState();
|
||||
|
||||
while (locationQuery.MoveNext(out var locationUid, out var locationComponent, out var transformComponent))
|
||||
{
|
||||
var station = _station.GetOwningStation(locationUid, transformComponent);
|
||||
if (_entityManager.EntityQuery<WizardRuleComponent>(true)
|
||||
.Any(wizardRule => wizardRule.TargetStation == station))
|
||||
{
|
||||
state.Locations.Add((int) locationUid, locationComponent.Location);
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public override void HandleMessage(EuiMessageBase msg)
|
||||
{
|
||||
base.HandleMessage(msg);
|
||||
|
||||
if (_used)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg is not TeleportSpellTargetLocationSelected cast)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var transform = _entityManager.GetComponent<TransformComponent>(_performer);
|
||||
var oldCoords = transform.Coordinates;
|
||||
|
||||
TransformComponent? locationTransform = null;
|
||||
|
||||
var teleportLocationQuery = _entityManager
|
||||
.EntityQueryEnumerator<TeleportLocationComponent, TransformComponent>();
|
||||
while (teleportLocationQuery.MoveNext(out var locationUid, out _, out var transformComponent))
|
||||
{
|
||||
if (locationUid == new EntityUid(cast.LocationUid))
|
||||
{
|
||||
locationTransform = transformComponent;
|
||||
}
|
||||
}
|
||||
|
||||
if (locationTransform is null)
|
||||
{
|
||||
_popupSystem.PopupEntity("Can't teleport", _performer, _performer);
|
||||
DoStateUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
_used = true;
|
||||
|
||||
var coords = locationTransform.Coordinates;
|
||||
|
||||
_transformSystem.SetCoordinates(_performer, coords);
|
||||
_transformSystem.AttachToGridOrMap(_performer, transform);
|
||||
|
||||
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", oldCoords);
|
||||
_entityManager.SpawnEntity("AdminInstantEffectSmoke10", coords);
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public sealed partial class WizardRuleComponent : Component
|
||||
{
|
||||
public readonly List<EntityUid> WizardMinds = new();
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public EntityUid? TargetStation;
|
||||
|
||||
[DataField("minPlayers")]
|
||||
|
||||
Reference in New Issue
Block a user