4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Graphics;
7 using System.Collections.Generic;
12 partial class RangedWeapon : ItemComponent
27 get => _chargeSoundWindupPitchSlide;
30 _chargeSoundWindupPitchSlide =
new Vector2(
35 private Vector2 _chargeSoundWindupPitchSlide;
37 private readonly List<ParticleEmitter> particleEmitters =
new List<ParticleEmitter>();
38 private readonly List<ParticleEmitter> particleEmitterCharges =
new List<ParticleEmitter>();
44 private float crossHairPosDirtyTimer;
55 foreach (var subElement
in rangedWeaponElement.
Elements())
58 switch (subElement.Name.ToString().ToLowerInvariant())
65 case "crosshairpointer":
67 crosshairPointerSprite =
new Sprite(subElement, path: textureDir);
70 case "particleemitter":
73 case "particleemittercharge":
85 crossHairPosDirtyTimer -= deltaTime;
93 Vector2 barrelDir =
new Vector2((
float)Math.Cos(rotation), -(float)Math.Sin(rotation));
100 float spread = GetSpread(character);
102 if (projectile !=
null)
104 spread += MathHelper.ToRadians(projectile.
Spread);
108 float spreadDist = (float)Math.Sin(spread) * crossHairDist;
116 public override void FlipX(
bool relativeToSub)
118 crossHairPosDirtyTimer = 0.02f;
120 public override void FlipY(
bool relativeToSub)
122 crossHairPosDirtyTimer = 0.02f;
125 partial
void UpdateProjSpecific(
float deltaTime)
129 switch (currentChargingState)
131 case ChargingState.WindingUp:
132 case ChargingState.WindingDown:
134 float sizeMultiplier = Math.Clamp(chargeRatio, 0.1f, 1f);
140 if (chargeSoundChannel ==
null || !chargeSoundChannel.
IsPlaying)
142 if (chargeSound !=
null)
145 if (chargeSoundChannel !=
null) { chargeSoundChannel.
Looping =
true; }
148 else if (chargeSoundChannel !=
null)
155 if (chargeSoundChannel !=
null)
160 chargeSoundChannel.
Looping =
false;
164 chargeSoundChannel =
null;
180 GUI.HideCursor = (
crosshairSprite !=
null || crosshairPointerSprite !=
null) &&
185 if (crossHairPosDirtyTimer <= 0.0f)
189 crosshairPointerSprite?.
Draw(spriteBatch, crosshairPointerPos, 0, currentCrossHairPointerScale);
196 GUI.DrawLine(spriteBatch, barrelPos - Vector2.UnitY * 3, barrelPos + Vector2.UnitY * 3, Color.Red);
197 GUI.DrawLine(spriteBatch, barrelPos - Vector2.UnitX * 3, barrelPos + Vector2.UnitX * 3, Color.Red);
201 partial
void LaunchProjSpecific()
205 if (
item.
body.
Dir < 0.0f) { rotation += MathHelper.Pi; }
208 emitter.
Emit(1.0f, particlePos, hullGuess:
item.
CurrentHull, angle: rotation, particleRotation: -rotation);
214 base.RemoveComponentSpecific();
217 crosshairPointerSprite?.
Remove();
Vector2 WorldToScreen(Vector2 coords)
Vector2 ScreenToWorld(Vector2 coords)
bool IsKeyDown(InputType inputType)
readonly AnimController AnimController
IEnumerable< Item >?? HeldItems
Items the character has in their hand slots. Doesn't return nulls and only returns items held in both...
IEnumerable< ContentXElement > Elements()
virtual Vector2 DrawPosition
static int GraphicsHeight
static bool IsMouseOnInventory
string GetTextureDirectory(ContentXElement subElement)
Projectile FindProjectile(bool triggerOnUseOnContainers=false)
override void RemoveComponentSpecific()
override void FlipY(bool relativeToSub)
override void UpdateHUDComponentSpecific(Character character, float deltaTime, Camera cam)
override void FlipX(bool relativeToSub)
override void DrawHUD(SpriteBatch spriteBatch, Character character)
Vector2 ChargeSoundWindupPitchSlide
float currentCrossHairScale
Vector2? TransformedBarrelPos
readonly ParticleEmitterPrefab Prefab
void Emit(float deltaTime, Vector2 position, Hull? hullGuess=null, float angle=0.0f, float particleRotation=0.0f, float velocityMultiplier=1.0f, float sizeMultiplier=1.0f, float amountMultiplier=1.0f, Color? colorMultiplier=null, ParticlePrefab? overrideParticle=null, bool mirrorAngle=false, Tuple< Vector2, Vector2 >? tracerPoints=null)
readonly ParticleEmitterProperties Properties
bool IsHoldingToRope
Is attached to something with a rope.
static ? RoundSound Load(ContentXElement element, bool stream=false)
float GetRandomFrequencyMultiplier()
readonly bool IgnoreMuffling
const float MaxFrequencyMultiplier
float FrequencyMultiplier
const float MinFrequencyMultiplier
void Draw(ISpriteBatch spriteBatch, Vector2 pos, float rotate=0.0f, float scale=1.0f, SpriteEffects spriteEffect=SpriteEffects.None)
override Vector2? Position