Mjollnir and Singularity Hammer for Wizard (#34446)

This commit is contained in:
keronshb
2025-02-20 18:38:52 -05:00
committed by GitHub
parent f3c681153a
commit a9054c5e9c
29 changed files with 698 additions and 206 deletions

View File

@@ -2,6 +2,7 @@ using System.Numerics;
using Content.Shared.Administration.Logs;
using Content.Shared.Camera;
using Content.Shared.CCVar;
using Content.Shared.Construction.Components;
using Content.Shared.Database;
using Content.Shared.Friction;
using Content.Shared.Gravity;
@@ -57,7 +58,8 @@ public sealed class ThrowingSystem : EntitySystem
bool recoil = true,
bool animated = true,
bool playSound = true,
bool doSpin = true)
bool doSpin = true,
bool unanchor = false)
{
var thrownPos = _transform.GetMapCoordinates(uid);
var mapPos = _transform.ToMapCoordinates(coordinates);
@@ -65,7 +67,7 @@ public sealed class ThrowingSystem : EntitySystem
if (mapPos.MapId != thrownPos.MapId)
return;
TryThrow(uid, mapPos.Position - thrownPos.Position, baseThrowSpeed, user, pushbackRatio, friction, compensateFriction: compensateFriction, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin);
TryThrow(uid, mapPos.Position - thrownPos.Position, baseThrowSpeed, user, pushbackRatio, friction, compensateFriction: compensateFriction, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin, unanchor: unanchor);
}
/// <summary>
@@ -78,6 +80,7 @@ public sealed class ThrowingSystem : EntitySystem
/// <param name="friction">friction value used for the distance calculation. If set to null this defaults to the standard tile values</param>
/// <param name="compensateFriction">True will adjust the throw so the item stops at the target coordinates. False means it will land at the target and keep sliding.</param>
/// <param name="doSpin">Whether spin will be applied to the thrown entity.</param>
/// <param name="unanchor">If true and the thrown entity has <see cref="AnchorableComponent"/>, unanchor the thrown entity</param>
public void TryThrow(EntityUid uid,
Vector2 direction,
float baseThrowSpeed = 10.0f,
@@ -88,7 +91,8 @@ public sealed class ThrowingSystem : EntitySystem
bool recoil = true,
bool animated = true,
bool playSound = true,
bool doSpin = true)
bool doSpin = true,
bool unanchor = false)
{
var physicsQuery = GetEntityQuery<PhysicsComponent>();
if (!physicsQuery.TryGetComponent(uid, out var physics))
@@ -105,7 +109,7 @@ public sealed class ThrowingSystem : EntitySystem
baseThrowSpeed,
user,
pushbackRatio,
friction, compensateFriction: compensateFriction, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin);
friction, compensateFriction: compensateFriction, recoil: recoil, animated: animated, playSound: playSound, doSpin: doSpin, unanchor: unanchor);
}
/// <summary>
@@ -118,6 +122,7 @@ public sealed class ThrowingSystem : EntitySystem
/// <param name="friction">friction value used for the distance calculation. If set to null this defaults to the standard tile values</param>
/// <param name="compensateFriction">True will adjust the throw so the item stops at the target coordinates. False means it will land at the target and keep sliding.</param>
/// <param name="doSpin">Whether spin will be applied to the thrown entity.</param>
/// <param name="unanchor">If true and the thrown entity has <see cref="AnchorableComponent"/>, unanchor the thrown entity</param>
public void TryThrow(EntityUid uid,
Vector2 direction,
PhysicsComponent physics,
@@ -131,16 +136,17 @@ public sealed class ThrowingSystem : EntitySystem
bool recoil = true,
bool animated = true,
bool playSound = true,
bool doSpin = true)
bool doSpin = true,
bool unanchor = false)
{
if (baseThrowSpeed <= 0 || direction == Vector2Helpers.Infinity || direction == Vector2Helpers.NaN || direction == Vector2.Zero || friction < 0)
return;
if (unanchor && HasComp<AnchorableComponent>(uid))
_transform.Unanchor(uid);
if ((physics.BodyType & (BodyType.Dynamic | BodyType.KinematicController)) == 0x0)
{
Log.Warning($"Tried to throw entity {ToPrettyString(uid)} but can't throw {physics.BodyType} bodies!");
return;
}
// Allow throwing if this projectile only acts as a projectile when shot, otherwise disallow
if (projectileQuery.TryGetComponent(uid, out var proj) && !proj.OnlyCollideWhenShot)