Skip to content

Commit

Permalink
Allow editing angle of the fired projectile (#33254)
Browse files Browse the repository at this point in the history
Add Angle datafield to `ProjectileComponent`. It allows to change the angle of the fired projectile
  • Loading branch information
MilenVolf authored Nov 12, 2024
1 parent 8776c71 commit 8b15489
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Content.Shared/Projectiles/ProjectileComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void ShootProjectile(EntityUid uid, Vector2 direction, Vector2 gunVelocit
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);
Expand Down

0 comments on commit 8b15489

Please sign in to comment.