using Godot; namespace Movementtests.systems; public partial class WeaponSystem : RigidBody3D { private Node3D _head; private ShapeCast3D _dashCast3D; private Camera3D _camera; private TweenQueueSystem _tweenQueueSystem; private Transform3D _startTransform; private Vector3 _throwDirection; private Vector3 _plantLocation; private Vector3 _plantNormal; public void Init(Node3D head, Camera3D camera) { _head = head; _camera = camera; _tweenQueueSystem = GetNode("TweenQueueSystem"); _tweenQueueSystem.Init(this); _startTransform = Transform; Freeze = true; } public void ThrowWeapon(Vector3 start, Vector3 end, bool hasHit, Vector3 collisionLocation, Vector3 collisionNormal) { _throwDirection = (end - start).Normalized(); _plantLocation = collisionLocation; _plantNormal = collisionNormal; LookAt(GlobalTransform.Origin + _throwDirection); RotateX(-Mathf.Pi / 2); var tween = _tweenQueueSystem.TweenToLocation(new TweenQueueSystem.TweenInputs(end, 1f)); if (hasHit) tween.Finished += PlantWeaponInWall; else tween.Finished += ThrowWeaponOnCurve; } public void ThrowWeaponOnCurve() { Freeze = false; } public void PlantWeaponInWall() { Position = _plantLocation; LookAt(_plantLocation + _plantNormal, Vector3.Up); } public void ResetWeapon() { Transform = _startTransform; Freeze = true; } }