- fix: Shooting now uses grid velocity. (#8)
This commit is contained in:
@@ -21,6 +21,7 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Physics.Components;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization.Manager;
|
using Robust.Shared.Serialization.Manager;
|
||||||
using Robust.Shared.Spawners;
|
using Robust.Shared.Spawners;
|
||||||
@@ -164,16 +165,24 @@ public sealed class MagicSystem : EntitySystem
|
|||||||
Speak(ev);
|
Speak(ev);
|
||||||
|
|
||||||
var xform = Transform(ev.Performer);
|
var xform = Transform(ev.Performer);
|
||||||
var userVelocity = _physics.GetMapLinearVelocity(ev.Performer);
|
|
||||||
|
// var userVelocity = _physics.GetMapLinearVelocity(ev.Performer); WD EDIT
|
||||||
|
|
||||||
foreach (var pos in GetSpawnPositions(xform, ev.Pos))
|
foreach (var pos in GetSpawnPositions(xform, ev.Pos))
|
||||||
{
|
{
|
||||||
// If applicable, this ensures the projectile is parented to grid on spawn, instead of the map.
|
// If applicable, this ensures the projectile is parented to grid on spawn, instead of the map.
|
||||||
var mapPos = pos.ToMap(EntityManager);
|
var mapPos = pos.ToMap(EntityManager);
|
||||||
var spawnCoords = _mapManager.TryFindGridAt(mapPos, out var gridUid, out _)
|
var spawnCoords = _mapManager.TryFindGridAt(mapPos, out var gridUid, out var grid) // WD EDIT
|
||||||
? pos.WithEntityId(gridUid, EntityManager)
|
? pos.WithEntityId(gridUid, EntityManager)
|
||||||
: new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position);
|
: new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position);
|
||||||
|
|
||||||
|
// WD EDIT
|
||||||
|
var userVelocity = Vector2.Zero;
|
||||||
|
|
||||||
|
if (grid != null && TryComp(gridUid, out PhysicsComponent? physics))
|
||||||
|
userVelocity = physics.LinearVelocity;
|
||||||
|
// WD EDIT
|
||||||
|
|
||||||
var ent = Spawn(ev.Prototype, spawnCoords);
|
var ent = Spawn(ev.Prototype, spawnCoords);
|
||||||
var direction = ev.Target.ToMapPos(EntityManager, _transformSystem) -
|
var direction = ev.Target.ToMapPos(EntityManager, _transformSystem) -
|
||||||
spawnCoords.ToMapPos(EntityManager, _transformSystem);
|
spawnCoords.ToMapPos(EntityManager, _transformSystem);
|
||||||
|
|||||||
@@ -115,7 +115,14 @@ public sealed partial class GunSystem : SharedGunSystem
|
|||||||
// Update shot based on the recoil
|
// Update shot based on the recoil
|
||||||
toMap = fromMap.Position + angle.ToVec() * mapDirection.Length();
|
toMap = fromMap.Position + angle.ToVec() * mapDirection.Length();
|
||||||
mapDirection = toMap - fromMap.Position;
|
mapDirection = toMap - fromMap.Position;
|
||||||
var gunVelocity = Physics.GetMapLinearVelocity(gunUid);
|
|
||||||
|
// WD EDIT START
|
||||||
|
// var gunVelocity = Physics.GetMapLinearVelocity(gunUid);
|
||||||
|
var gunVelocity = Vector2.Zero;
|
||||||
|
|
||||||
|
if (grid != null && TryComp(gridUid, out PhysicsComponent? physics))
|
||||||
|
gunVelocity = physics.LinearVelocity;
|
||||||
|
// WD EDIT END
|
||||||
|
|
||||||
// I must be high because this was getting tripped even when true.
|
// I must be high because this was getting tripped even when true.
|
||||||
// DebugTools.Assert(direction != Vector2.Zero);
|
// DebugTools.Assert(direction != Vector2.Zero);
|
||||||
|
|||||||
Reference in New Issue
Block a user