Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GSGE.Code.Things.PlayerUnit
- public void handleInput(InputHandler input)
- {
- if (base.isAlive())
- {
- if (input.isDown(Controls.Heal))
- {
- if (this.m_map.isHub())
- {
- if (input.wasPressed(Controls.Heal) && World.isTimePast(this.m_lastZoomSwitch + 0.25f + 0.1f))
- {
- float zoomRequestValue = Camera.getZoomRequestValue("TOWN_VIEW");
- if (zoomRequestValue >= 1f)
- {
- Camera.requestZoom("TOWN_VIEW", 0.5f, 0.25f, 3.40282347E+38f);
- }
- else if (zoomRequestValue <= 0.5f)
- {
- Camera.requestZoom("TOWN_VIEW", 1f, 0.25f, 3.40282347E+38f);
- }
- this.m_lastZoomSwitch = World.getElapsedTime();
- AudioManager.PlayCue("CameraZoom");
- }
- }
- else if (!base.InBottomlessPit && !base.isPassedOutOrGettingUp())
- {
- Weapon weapon = base.fireWeapon(Weapon.SlotType.CONSUMABLE);
- InGameUI.onAttackInput(weapon);
- }
- }
- if (this.m_map.isHub() && (input.wasPressed(Controls.PrimaryAttack) || input.wasPressed(Controls.SecondaryAttack) || input.wasPressed(Controls.Shield) || input.wasPressed(Controls.SpecialAttack)))
- {
- InGameUI.showHud();
- }
- if (input.wasPressed(Controls.Inventory))
- {
- InGameUI.showMoneyImmediately();
- App.getScreenManager().AddScreen(new SeedInventoryScreen(App.getScreenManager(), null));
- return;
- }
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.isDown(Controls.Move))
- {
- Vector2 screenLocation = input.getCursorLocation();
- screenLocation = Functions.convertScreenToWorldLocation(screenLocation);
- }
- Weapon weapon2 = this.handleUseAndWeaponInput(input);
- if (!this.m_player.AllowInput && !ConfigOptions.GodMode)
- {
- return;
- }
- if (weapon2 != null && !weapon2.getData().FullyAutomatic && weapon2.getFramesTriggerHeldFor() > 1)
- {
- weapon2 = null;
- }
- Vector2 vector = Vector2.Zero;
- Vector2 vector2 = Vector2.Zero;
- if (!ConfigOptions.UseMouse)
- {
- vector2 += input.getLeftStickLocation();
- }
- if (!ConfigOptions.UseMouse || ConfigOptions.UseWASD)
- {
- vector2 += input.getDirection();
- vector = Functions.rotateInput(vector2);
- if (ConfigOptions.UseMouse && ConfigOptions.UseWASD && !this.m_strafe && vector != Vector2.Zero)
- {
- double angle = Functions.getAngle(Vector2.Zero, vector);
- double num = Functions.arcDistance(this.m_angle, angle);
- if (num < 1.727875996925089 && num > 0.3490658503988659)
- {
- Vector2 vector3 = Vector2.Subtract(vector, this.m_direction);
- vector3.Normalize();
- vector3 = Vector2.Multiply(vector3, 0.2f);
- vector = Vector2.Add(this.m_direction, vector3);
- }
- }
- }
- else
- {
- if (input.wasPressed(Controls.Stop))
- {
- this.stopMoving();
- }
- else if (input.isDown(Controls.Move) && base.canMove() && !this.m_somethingUsed)
- {
- Vector2 vector4 = input.getCursorLocation();
- vector4 = Functions.convertScreenToWorldLocation(vector4);
- if (Vector2.Subtract(vector4, this.m_location).LengthSquared() > 256f)
- {
- this.m_moveTarget = vector4;
- AnimationManager.create("MoveMarker", this.m_moveTarget, 0.0);
- }
- }
- if (this.m_moveTarget != Vector2.Zero)
- {
- vector = this.m_moveTarget - this.m_location;
- }
- }
- double num2 = 0.0;
- if (vector != Vector2.Zero)
- {
- if (this.m_passedOut)
- {
- this.getUp();
- return;
- }
- if (this.m_hardLandPassedOut)
- {
- this.hardLandGetUp();
- return;
- }
- num2 = Functions.getAngle(Vector2.Zero, vector);
- this.m_lastMoveInputTime = World.getElapsedTime();
- base.cancelAnimation(base.m_thingData.FidgetGraphic);
- this.setNextFidgetTime();
- }
- bool flag = false;
- float num3 = vector.Length();
- if (num3 > 0f)
- {
- num3 = 1f;
- }
- if ((weapon2 == null || !weapon2.getData().AutoLockWithMouse) && ConfigOptions.UseMouse && !input.isDown(Controls.Shield))
- {
- Vector2 vector5 = input.getCursorLocation();
- vector5 = Functions.convertScreenToWorldLocation(vector5);
- if (!World.isTimePast(this.m_lockUntilTime) || (weapon2 != null && weapon2.getData().SlotType != Weapon.SlotType.MOVE))
- {
- if (weapon2 != null)
- {
- this.m_lockUntilTime = World.getElapsedTime() + weapon2.getAutoLockDuration();
- }
- if (vector5 != Vector2.Zero)
- {
- flag = true;
- double angle2 = Functions.getAngle(base.getLocation(), vector5);
- base.setGoalAngle(angle2);
- float amount = (float)(Functions.arcDistance(angle2, num2) / 3.1415926535897931);
- float num4 = MathHelper.Lerp(1f, this.m_data.BackpedalSpeedModifier, amount);
- num3 *= num4;
- Weapon weapon3 = weapon2;
- if (weapon3 == null)
- {
- weapon3 = base.LastWeaponFired;
- }
- if (weapon3 == null || weapon3.getData().ShowLockLine)
- {
- InGameUI.getPlayerUI(this.m_player.Index).showLockOnLine(this, vector5, 150f);
- }
- }
- }
- this.m_lockTarget = null;
- }
- else
- {
- Vector2 vector6 = input.getRightStickLocation();
- vector6 = Functions.rotateInput(vector6);
- Weapon defaultWeapon = this.m_weaponArsenal.getDefaultWeapon(Weapon.SlotType.DEFENSE);
- if (!ConfigOptions.UseMouse && vector6.LengthSquared() > 0.0225f && defaultWeapon != null && base.isWeaponAllowed(defaultWeapon.getName()))
- {
- double angle3 = Functions.getAngle(Vector2.Zero, vector6);
- this.m_lockTarget = null;
- this.m_incomingProjectiles.Clear();
- base.setGoalAngle(angle3);
- if (vector2 != Vector2.Zero)
- {
- flag = true;
- }
- }
- else
- {
- this.updateLock(input, weapon2);
- }
- if (this.m_lockTarget != null && this.m_lockTarget.isAlive())
- {
- flag = true;
- double angle4 = Functions.getAngle(this, this.m_lockTarget);
- float amount2 = (float)(Functions.arcDistance(angle4, num2) / 3.1415926535897931);
- float num5 = MathHelper.Lerp(1f, this.m_data.BackpedalSpeedModifier, amount2);
- num3 *= num5;
- }
- else if (ConfigOptions.UseMouse && ((weapon2 != null && weapon2.getData().AutoLockWithMouse) || (!ConfigOptions.UseWASD && input.isDown(Controls.Shield))))
- {
- Vector2 vector7 = input.getCursorLocation();
- vector7 = Functions.convertScreenToWorldLocation(vector7);
- if (vector7 != Vector2.Zero)
- {
- flag = true;
- double angle5 = Functions.getAngle(base.getLocation(), vector7);
- base.setGoalAngle(angle5);
- if (weapon2 != null && weapon2.getData().ShowLockLine)
- {
- InGameUI.getPlayerUI(this.m_player.Index).showLockOnLine(this, vector7, 150f);
- }
- }
- }
- }
- if (this.m_legAnimation != null && this.m_legAnimation.Data.OwnerMoveFractionPlaySpeed > 0f)
- {
- this.m_legAnimation.PlaySpeed = num3 * this.m_legAnimation.Data.OwnerMoveFractionPlaySpeed;
- }
- if (this.m_animation.Data.OwnerMoveFractionPlaySpeed > 0f)
- {
- this.m_animation.PlaySpeed = Math.Min(1f, num3 * this.m_animation.Data.OwnerMoveFractionPlaySpeed);
- }
- if (num3 > 0f)
- {
- double num6 = this.m_angle;
- if (this.m_animation.shouldMirror())
- {
- num6 -= (double)this.m_animation.Data.RotateLegs;
- }
- else
- {
- num6 += (double)this.m_animation.Data.RotateLegs;
- }
- this.setMoveStyle(flag, num6, num2);
- }
- if (this.m_allowInput)
- {
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD)
- {
- if (this.m_moveTarget != Vector2.Zero && this.m_moveTarget != this.m_location)
- {
- if (flag)
- {
- base.moveInput(this.m_moveTarget, num3, flag);
- }
- else
- {
- base.moveInput(this.m_moveTarget, num3);
- }
- }
- else
- {
- base.moveInput(this.m_angle, 0f, flag);
- this.m_moveTarget = Vector2.Zero;
- }
- }
- else
- {
- base.moveInput(num2, num3, flag);
- }
- }
- else
- {
- this.m_strafe = false;
- }
- Weapon primaryWeapon = base.getPrimaryWeapon();
- if (primaryWeapon != null)
- {
- primaryWeapon.setAngle(base.getAngle());
- }
- if (!this.m_allowInput)
- {
- return;
- }
- }
- if (this.m_animation.getName() == this.m_data.m_thingData.Graphic && World.isTimePast(this.m_nextFidgetTime))
- {
- base.setAnimation(base.m_thingData.FidgetGraphic);
- this.setNextFidgetTime();
- }
- }
- // GSGE.Code.Things.PlayerUnit
- private Weapon handleUseAndWeaponInput(InputHandler input)
- {
- if (base.InBottomlessPit)
- {
- this.m_somethingUsed = false;
- return null;
- }
- if (base.isPassedOutOrGettingUp())
- {
- this.m_somethingUsed = false;
- return null;
- }
- if (base.TriggerLockedWeapon != null)
- {
- if (!base.InBottomlessPit && this.getZLocation() <= 0f && !base.TriggerLockedWeapon.isClipEmpty() && base.TriggerLockedWeapon.isEquipped() && (base.TriggerLockedWeapon.hasAmmo() || base.TriggerLockedWeapon.ClipShotNum != 1))
- {
- this.m_somethingUsed = false;
- return base.fireWeapon(base.TriggerLockedWeapon.getData().SlotType);
- }
- base.TriggerLockedWeapon = null;
- }
- Weapon weapon = null;
- bool flag = true;
- Thing useTarget = this.m_player.getUseTarget();
- if (useTarget != null && (input.wasPressed(Controls.Use) || (ConfigOptions.UseMouse && input.wasMouseButtonPressed(Controls.MouseButtons.Left) && InGameUI.getPlayerUI(ProfileManager.PlayerIndex).isNearUseIcon(input.getCursorLocationWithHeight(), 70f))))
- {
- this.m_player.useThing();
- this.m_somethingUsed = true;
- flag = false;
- }
- if (this.m_somethingUsed)
- {
- if (input.isDown(Controls.Use))
- {
- flag = false;
- }
- else
- {
- this.m_somethingUsed = false;
- }
- }
- if (flag)
- {
- bool flag2 = false;
- if (input.wasPressed(Controls.Reload))
- {
- flag2 = this.manualReload();
- }
- if (!flag2)
- {
- if (input.isDown(Controls.SpecialAttack))
- {
- weapon = base.fireWeapon(Weapon.SlotType.SPECIAL);
- InGameUI.onAttackInput(weapon);
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.wasPressed(Controls.SpecialAttack))
- {
- this.stopMoving();
- }
- }
- else if ((!ConfigOptions.UseMouse || input.isShiftDown()) && input.isDown(Controls.PrimaryAttack))
- {
- weapon = base.fireWeapon(Weapon.SlotType.PRIMARY);
- InGameUI.onAttackInput(weapon);
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.wasPressed(Controls.PrimaryAttack))
- {
- this.stopMoving();
- }
- }
- else if (input.isDown(Controls.PrimaryAttack))
- {
- weapon = base.fireWeapon(Weapon.SlotType.PRIMARY);
- InGameUI.onAttackInput(weapon);
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.wasPressed(Controls.PrimaryAttack))
- {
- this.stopMoving();
- }
- }
- else if (this.shouldFireSecondary(input))
- {
- weapon = base.fireWeapon(Weapon.SlotType.SECONDARY);
- InGameUI.onAttackInput(weapon);
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.wasPressed(Controls.SecondaryAttack))
- {
- this.stopMoving();
- }
- }
- else if ((!ConfigOptions.UseMouse && input.getRightStickLocation().LengthSquared() > 0.0225f) || input.isDown(Controls.Shield))
- {
- weapon = base.fireWeapon(Weapon.SlotType.DEFENSE);
- InGameUI.onAttackInput(weapon);
- if (ConfigOptions.UseMouse && !ConfigOptions.UseWASD && input.wasPressed(Controls.Shield))
- {
- this.stopMoving();
- }
- }
- else if (input.wasPressed(Controls.Dodge))
- {
- weapon = base.fireWeapon(Weapon.SlotType.MOVE);
- }
- }
- }
- return weapon;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement