Client LuaCsForBarotrauma
HumanoidAnimations.cs
1 using Microsoft.Xna.Framework;
2 
3 namespace Barotrauma
4 {
6  {
7  public static HumanWalkParams GetDefaultAnimParams(Character character) => GetDefaultAnimParams<HumanWalkParams>(character, AnimationType.Walk);
8  public static HumanWalkParams GetAnimParams(Character character, Either<string, ContentPath> file, bool throwErrors = true)
9  {
10  return GetAnimParams<HumanWalkParams>(character, AnimationType.Walk, file, throwErrors);
11  }
12 
13  public override void StoreSnapshot() => StoreSnapshot<HumanWalkParams>();
14  }
15 
17  {
18  public static HumanRunParams GetDefaultAnimParams(Character character) => GetDefaultAnimParams<HumanRunParams>(character, AnimationType.Run);
19  public static HumanRunParams GetAnimParams(Character character, Either<string, ContentPath> file, bool throwErrors = true)
20  {
21  return GetAnimParams<HumanRunParams>(character, AnimationType.Run, file, throwErrors);
22  }
23 
24  public override void StoreSnapshot() => StoreSnapshot<HumanRunParams>();
25  }
26 
28  {
29  [Serialize(0.0f, IsPropertySaveable.Yes, description: "How much lower the character's head and torso move when stationary."), Editable(MinValueFloat = 0, MaxValueFloat = 2, DecimalCount = 2)]
30  public float MoveDownAmountWhenStationary { get; set; }
31 
32  [Serialize(0.0f, IsPropertySaveable.Yes), Editable(-360f, 360f)]
33  public float ExtraHeadAngleWhenStationary { get; set; }
34 
35  [Serialize(0.0f, IsPropertySaveable.Yes), Editable(-360f, 360f)]
36  public float ExtraTorsoAngleWhenStationary { get; set; }
37 
38  public static HumanCrouchParams GetDefaultAnimParams(Character character) => GetDefaultAnimParams<HumanCrouchParams>(character, AnimationType.Crouch);
39  public static HumanCrouchParams GetAnimParams(Character character, Either<string, ContentPath> file, bool throwErrors = true)
40  {
41  return GetAnimParams<HumanCrouchParams>(character, AnimationType.Crouch, file, throwErrors);
42  }
43 
44  public override void StoreSnapshot() => StoreSnapshot<HumanCrouchParams>();
45  }
46 
48  {
49  public static HumanSwimFastParams GetDefaultAnimParams(Character character) => GetDefaultAnimParams<HumanSwimFastParams>(character, AnimationType.SwimFast);
50  public static HumanSwimFastParams GetAnimParams(Character character, Either<string, ContentPath> file, bool throwErrors = true)
51  {
52  return GetAnimParams<HumanSwimFastParams>(character, AnimationType.SwimFast, file, throwErrors);
53  }
54 
55 
56  public override void StoreSnapshot() => StoreSnapshot<HumanSwimFastParams>();
57  }
58 
60  {
61  public static HumanSwimSlowParams GetDefaultAnimParams(Character character) => GetDefaultAnimParams<HumanSwimSlowParams>(character, AnimationType.SwimSlow);
62  public static HumanSwimSlowParams GetAnimParams(Character character, Either<string, ContentPath> file, bool throwErrors = true)
63  {
64  return GetAnimParams<HumanSwimSlowParams>(character, AnimationType.SwimSlow, file, throwErrors);
65  }
66 
67  public override void StoreSnapshot() => StoreSnapshot<HumanSwimSlowParams>();
68  }
69 
71  {
72  [Header("Legs")]
73  [Serialize(0.5f, IsPropertySaveable.Yes), Editable(DecimalCount = 2)]
74  public float LegMoveAmount { get; set; }
75 
77  public float LegCycleLength { get; set; }
78 
82  [Serialize(0.0f, IsPropertySaveable.Yes), Editable(-360f, 360f)]
83  public float FootAngle
84  {
85  get => MathHelper.ToDegrees(FootAngleInRadians);
86  set
87  {
88  FootAngleInRadians = MathHelper.ToRadians(value);
89  }
90  }
91 
92  public float FootAngleInRadians { get; private set; }
93 
94  [Header("Arms")]
95  [Serialize("0.5, 0.1", IsPropertySaveable.Yes), Editable(DecimalCount = 2)]
96  public Vector2 HandMoveAmount { get; set; }
97 
99  public float HandCycleSpeed { get; set; }
100 
101  [Serialize("0.0, 0.0", IsPropertySaveable.Yes), Editable(DecimalCount = 2)]
102  public Vector2 HandMoveOffset { get; set; }
103 
104  [Serialize(1f, IsPropertySaveable.Yes, description: "How much force is used to move the arms."), Editable(MinValueFloat = 0, MaxValueFloat = 20, DecimalCount = 2)]
105  public float ArmMoveStrength { get; set; }
106 
107  [Serialize(1f, IsPropertySaveable.Yes, description: "How much force is used to move the hands."), Editable(MinValueFloat = 0, MaxValueFloat = 10, DecimalCount = 2)]
108  public float HandMoveStrength { get; set; }
109 
110  [Header("Other")]
111  [Serialize(true, IsPropertySaveable.Yes, description: "Is the head angle fixed or does the angle follow the mouse position?"), Editable]
112  public bool FixedHeadAngle { get; set; }
113  }
114 
116  {
117  [Header("Standing")]
118  [Serialize(0.3f, IsPropertySaveable.Yes, description: "How much force is used to force the character upright."), Editable(MinValueFloat = 0, MaxValueFloat = 1, DecimalCount = 2)]
119  public float GetUpForce { get; set; }
120 
121  [Serialize(0.25f, IsPropertySaveable.Yes, description: "How much the character's head leans forwards when moving."), Editable(DecimalCount = 2)]
122  public float HeadLeanAmount { get; set; }
123 
124  [Serialize(0.25f, IsPropertySaveable.Yes, description: "How much the character's torso leans forwards when moving."), Editable(DecimalCount = 2)]
125  public float TorsoLeanAmount { get; set; }
126 
127  [Header("Legs")]
128  [Serialize(15.0f, IsPropertySaveable.Yes, description: "How much force is used to move the feet to the correct position."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
129  public float FootMoveStrength { get; set; }
130 
131  [Serialize(0f, IsPropertySaveable.Yes, description: "How much the horizontal difference of waist and the foot positions has an effect to lifting the foot."), Editable(DecimalCount = 2, ValueStep = 0.1f, MinValueFloat = 0f, MaxValueFloat = 1f)]
132  public float FootLiftHorizontalFactor { get; set; }
133 
134  [Serialize("0,0", IsPropertySaveable.Yes, description: "Normally the character's feet are positioned at a scaled-down version of it's normal step position - this can be used to override that value if you want to e.g. make the character to spread out it's feet more when standing."), Editable(DecimalCount = 2, ValueStep = 0.01f)]
135  public Vector2 StepSizeWhenStanding
136  {
137  get;
138  set;
139  }
140 
144  [Serialize(0.0f, IsPropertySaveable.Yes), Editable(-360f, 360f)]
145  public float FootAngle
146  {
147  get => MathHelper.ToDegrees(FootAngleInRadians);
148  set
149  {
150  FootAngleInRadians = MathHelper.ToRadians(value);
151  }
152  }
153  public float FootAngleInRadians { get; private set; }
154 
155  [Serialize("0.0, 0.0", IsPropertySaveable.Yes, description: "Added to the calculated foot positions, e.g. a value of {-1.0, 0.0f} would make the character \"drag\" their feet one unit behind them."), Editable(DecimalCount = 2)]
156  public Vector2 FootMoveOffset { get; set; }
157 
158  [Serialize(10.0f, IsPropertySaveable.Yes, description: "How much torque is used to bend the characters legs when taking a step."), Editable(MinValueFloat = 0, MaxValueFloat = 100)]
159  public float LegBendTorque { get; set; }
160 
161  [Header("Arms")]
162  [Serialize("0.4, 0.15", IsPropertySaveable.Yes, description: "How much the hands move along each axis."), Editable(DecimalCount = 2)]
163  public Vector2 HandMoveAmount { get; set; }
164 
165  [Serialize("-0.15, 0.0", IsPropertySaveable.Yes, description: "Added to the calculated hand positions, e.g. a value of {-1.0, 0.0f} would make the character \"drag\" their hands one unit behind them."), Editable(DecimalCount = 2)]
166  public Vector2 HandMoveOffset { get; set; }
167 
168  [Serialize(-1.0f, IsPropertySaveable.Yes, description: "The position of the hands is clamped below this (relative to the position of the character's torso)."), Editable(DecimalCount = 2)]
169  public float HandClampY { get; set; }
170 
171  [Serialize(1f, IsPropertySaveable.Yes, description: "How much force is used to move the arms."), Editable(MinValueFloat = 0, MaxValueFloat = 10, DecimalCount = 2)]
172  public float ArmMoveStrength { get; set; }
173 
174  [Serialize(1f, IsPropertySaveable.Yes, description: "How much force is used to move the hands."), Editable(MinValueFloat = 0, MaxValueFloat = 10, DecimalCount = 2)]
175  public float HandMoveStrength { get; set; }
176 
177  [Header("Other")]
178  [Serialize(true, IsPropertySaveable.Yes, description: "Is the head angle fixed or does the angle follow the mouse position?"), Editable]
179  public bool FixedHeadAngle { get; set; }
180  }
181 
182  public interface IHumanAnimation
183  {
184  float FootAngle { get; set; }
185  float FootAngleInRadians { get; }
186 
187  float ArmMoveStrength { get; set; }
188 
189  float HandMoveStrength { get; set; }
190 
191  bool FixedHeadAngle { get; set; }
192  }
193 }
override void StoreSnapshot()
static HumanCrouchParams GetDefaultAnimParams(Character character)
static HumanCrouchParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanRunParams GetDefaultAnimParams(Character character)
override void StoreSnapshot()
static HumanRunParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanSwimFastParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanSwimFastParams GetDefaultAnimParams(Character character)
static HumanSwimSlowParams GetDefaultAnimParams(Character character)
static HumanSwimSlowParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
override void StoreSnapshot()
static HumanWalkParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanWalkParams GetDefaultAnimParams(Character character)