2 using Microsoft.Xna.Framework;
16 private const float ThrowAngleStart = -MathHelper.PiOver2, ThrowAngleEnd = MathHelper.PiOver2;
17 private float throwAngle = ThrowAngleStart;
21 private ThrowState throwState;
25 const float ContinuousCollisionThreshold = 5.0f;
33 [
Serialize(1.0f,
IsPropertySaveable.No, description:
"The impulse applied to the physics body of the item when thrown. Higher values make the item be thrown faster.")]
39 if (
aimPos == Vector2.Zero)
41 aimPos =
new Vector2(0.45f, 0.1f);
47 public override bool Use(
float deltaTime,
Character character =
null)
61 base.Drop(dropper, setTransform);
62 throwState = ThrowState.None;
63 throwAngle = ThrowAngleStart;
79 if (
item.
body.
LinearVelocity.LengthSquared() < ContinuousCollisionThreshold * ContinuousCollisionThreshold)
91 statusEffect.SetUser(
null);
98 statusEffect.SetUser(
null);
101 item.
body.
CollidesWith = Physics.CollisionWall | Physics.CollisionLevel | Physics.CollisionPlatform;
114 if (throwState != ThrowState.Throwing)
120 else if (throwState != ThrowState.Initiated)
122 throwAngle = ThrowAngleStart;
129 throwState = ThrowState.None;
147 if (throwState != ThrowState.Throwing)
149 if (aim || throwState == ThrowState.Initiated)
151 throwAngle = System.Math.Min(throwAngle + deltaTime * 8.0f, ThrowAngleEnd);
153 if (throwAngle >= ThrowAngleEnd && throwState == ThrowState.Initiated)
155 throwState = ThrowState.Throwing;
160 throwAngle = ThrowAngleStart;
166 throwAngle = MathUtils.WrapAnglePi(throwAngle - deltaTime * 15.0f);
173 if (!MathUtils.IsValid(throwVector)) { throwVector = Vector2.UnitY; }
208 throwAngle = ThrowAngleStart;
220 throwState = ThrowState.None;
void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 itemPos, bool aim, float holdAngle, float itemAngleRelativeToHoldAngle=0.0f, bool aimMelee=false, Vector2? targetPos=null)
Vector2? CursorWorldPosition
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...
virtual Vector2 WorldPosition
static NetworkMember NetworkMember
void Drop(Character dropper, bool createNetworkEvent=true, bool setTransform=true)
void ResetWaterDragCoefficient()
Removes the override value -> falls back to using the original value defined in the xml.
override void FlipX(bool relativeToSub)
Flip the entity horizontally
float?? WaterDragCoefficient
override string Name
Note that this is not a LocalizedString instance, just the current name of the item as a string....
void ApplyStatusEffects(ActionType type, float deltaTime, Character character=null, Limb targetLimb=null, Entity useTarget=null, Character user=null, Vector2? worldPosition=null, float afflictionMultiplier=1.0f)
readonly Dictionary< ActionType, List< StatusEffect > > statusEffectLists
override void UpdateBroken(float deltaTime, Camera cam)
const float WaterDragCoefficient
override void Update(float deltaTime, Camera cam)
override bool SecondaryUse(float deltaTime, Character character=null)
override void Drop(Character dropper, bool setTransform=true)
a Character has dropped the item
override bool Use(float deltaTime, Character character=null)
Throwable(Item item, ContentXElement element)
void ApplyLinearImpulse(Vector2 impulse)
Limb GetLimb(LimbType limbType, bool excludeSevered=true, bool excludeLimbsWithSecondaryType=false, bool useSecondaryType=false)
Note that if there are multiple limbs of the same type, only the first (valid) limb is returned.
ActionType
ActionTypes define when a StatusEffect is executed.