MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / AnimateWeaponUndraw

Function AnimateWeaponUndraw

TombEngine/Game/Lara/lara_two_guns.cpp:224–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224static int AnimateWeaponUndraw(ItemInfo& laraItem, LaraWeaponType weaponType, bool isRightWeapon)
225{
226 auto& player = GetLaraInfo(laraItem);
227 auto& arm = isRightWeapon ? player.RightArm : player.LeftArm;
228 const auto& weapon = Weapons[(int)weaponType];
229 const auto& weaponAnimData = GetWeaponAnimData(player.Control.Weapon.GunType);
230
231 int frame = arm.FrameNumber;
232
233 // Finish recoil anim before reholstering weapon.
234 if (frame >= weaponAnimData.RecoilAnim && frame < (weaponAnimData.RecoilAnim + weapon.RecoilFrame))
235 frame++;
236
237 if (frame == (weaponAnimData.RecoilAnim + weapon.RecoilFrame))
238 {
239 frame = weaponAnimData.Draw1Anim2;
240 }
241 else if (frame > 0 && frame < weaponAnimData.Draw1Anim)
242 {
243 arm.Orientation -= arm.Orientation / frame;
244 frame--;
245 }
246 else if (frame == 0)
247 {
248 arm.Orientation = EulerAngles::Identity;
249 frame = weaponAnimData.RecoilAnim - 1;
250 }
251 else if (frame > weaponAnimData.Draw1Anim && frame < weaponAnimData.RecoilAnim)
252 {
253 frame--;
254
255 if (frame == (weaponAnimData.Draw2Anim - 1))
256 {
257 UndrawPistolMesh(laraItem, weaponType, isRightWeapon);
258 SoundEffect(SFX_TR4_LARA_HOLSTER, &laraItem.Pose);
259 }
260 }
261
262 SetArmInfo(laraItem, arm, frame);
263 return frame;
264}
265
266void HandlePistols(ItemInfo& laraItem, LaraWeaponType weaponType)
267{

Callers 1

UndrawPistolsFunction · 0.85

Calls 4

GetWeaponAnimDataFunction · 0.85
UndrawPistolMeshFunction · 0.85
SoundEffectFunction · 0.85
SetArmInfoFunction · 0.85

Tested by

no test coverage detected