Allow editing angle of the fired projectile (#33254)

Add Angle datafield to `ProjectileComponent`. It allows to change the angle of the fired projectile
This commit is contained in:
MilenVolf
2024-11-12 22:11:02 +03:00
committed by GitHub
parent 8776c71e59
commit 8b154899b5
2 changed files with 7 additions and 1 deletions

View File

@@ -8,6 +8,12 @@ namespace Content.Shared.Projectiles;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ProjectileComponent : Component
{
/// <summary>
/// The angle of the fired projectile.
/// </summary>
[DataField, AutoNetworkedField]
public Angle Angle;
/// <summary>
/// The effect that appears when a projectile collides with an entity.
/// </summary>

View File

@@ -429,7 +429,7 @@ public abstract partial class SharedGunSystem : EntitySystem
Projectiles.SetShooter(uid, projectile, user ?? gunUid);
projectile.Weapon = gunUid;
TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle());
TransformSystem.SetWorldRotation(uid, direction.ToWorldAngle() + projectile.Angle);
}
protected abstract void Popup(string message, EntityUid? uid, EntityUid? user);