public override bool Shoot(PlayerCmd pCmd, float delta) { // track spin up if (_spinUpTime >= _spinUpTimeRequired) { if (Idle) { _idleSound.Play(); } else { // if spun up enough, shoot _shootSound.Play(); Vector3 shootTo = _playerOwner.Head.GlobalTransform.origin + pCmd.attackDir; PhysicsDirectSpaceState spaceState = _playerOwner.GetWorld().DirectSpaceState; Godot.Collections.Dictionary res = spaceState.IntersectRay(_playerOwner.Head.GlobalTransform.origin, shootTo, new Godot.Collections.Array { this, _playerOwner }, 1); // if hits, use that as our far point if (res.Count > 0) { Vector3 shotLoc = ((Vector3)res["position"]); Vector3 norm = (Vector3)res["normal"]; SpreadShoot(5, true, true, shotLoc, norm); } } } else { if (_spinSound != SPINSOUND.UP) { _spinUpSound.Play(); _spinSound = SPINSOUND.UP; } _spinUpTime += delta; } return(true); }
override public void PhysicsProcess(float delta) { this.TimeSinceLastShot += delta; this.TimeSinceReloaded += delta; if (_spinUpTime != 0 && !ShootPressed) { if (_spinUpTime <= 0) { _spinUpTime = 0; } else { _spinUpTime = (_spinUpTime - delta) < 0 ? 0 : _spinUpTime - delta; if (_spinSound != SPINSOUND.DOWN) { _spinDownSound.Play(); _spinSound = SPINSOUND.DOWN; } } } }