(883c460d5) Don't require holding the aim key when using the periscope/controller. Move the RequireAimToUse from Controller component to Item. Change the use and shoot logic accordingly. TODO: fix the camera centering.
This commit is contained in:
@@ -360,11 +360,6 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
inadequateSkills = selectedItem.RequiredSkills.FindAll(skill => user.GetSkillLevel(skill.Identifier) < skill.Level);
|
||||
}
|
||||
|
||||
if (selectedItem.RequiredSkills.Any())
|
||||
{
|
||||
string text = TextManager.Get("FabricatorRequiredSkills") + ":\n";
|
||||
foreach (Skill skill in selectedItem.RequiredSkills)
|
||||
|
||||
@@ -204,7 +204,10 @@ namespace Barotrauma
|
||||
private void Attack(float deltaTime)
|
||||
{
|
||||
character.CursorPosition = Enemy.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
if (Weapon.RequireAimToUse)
|
||||
{
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
}
|
||||
if (WeaponComponent is MeleeWeapon meleeWeapon)
|
||||
{
|
||||
if (Vector2.DistanceSquared(character.Position, Enemy.Position) <= meleeWeapon.Range * meleeWeapon.Range)
|
||||
|
||||
@@ -161,7 +161,10 @@ namespace Barotrauma
|
||||
private void OperateRepairTool(float deltaTime)
|
||||
{
|
||||
character.CursorPosition = Item.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
if (Item.RequireAimToUse)
|
||||
{
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
}
|
||||
Vector2 fromToolToTarget = Item.Position - repairTool.Item.Position;
|
||||
if (fromToolToTarget.LengthSquared() < MathUtils.Pow(repairTool.Range / 2, 2))
|
||||
{
|
||||
|
||||
@@ -1276,14 +1276,20 @@ namespace Barotrauma
|
||||
if (i == 1 && selectedItems[0] == selectedItems[1]) { continue; }
|
||||
var item = selectedItems[i];
|
||||
if (item == null) { continue; }
|
||||
if (IsKeyDown(InputType.Use) && !item.IsShootable)
|
||||
{
|
||||
item.Use(deltaTime, this);
|
||||
}
|
||||
if (IsKeyDown(InputType.Aim))
|
||||
{
|
||||
item.SecondaryUse(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Shoot) && item.IsShootable)
|
||||
}
|
||||
if (IsKeyDown(InputType.Use) && !item.IsShootable)
|
||||
{
|
||||
if (!item.RequireAimToUse || IsKeyDown(InputType.Aim))
|
||||
{
|
||||
item.Use(deltaTime, this);
|
||||
}
|
||||
}
|
||||
if (IsKeyDown(InputType.Shoot) && item.IsShootable)
|
||||
{
|
||||
if (!item.RequireAimToUse || IsKeyDown(InputType.Aim))
|
||||
{
|
||||
item.Use(deltaTime, this);
|
||||
}
|
||||
@@ -1293,14 +1299,20 @@ namespace Barotrauma
|
||||
|
||||
if (SelectedConstruction != null)
|
||||
{
|
||||
if (IsKeyDown(InputType.Use) && !SelectedConstruction.IsShootable)
|
||||
{
|
||||
SelectedConstruction.Use(deltaTime, this);
|
||||
}
|
||||
if (IsKeyDown(InputType.Aim))
|
||||
{
|
||||
SelectedConstruction.SecondaryUse(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Shoot) && SelectedConstruction.IsShootable)
|
||||
}
|
||||
if (IsKeyDown(InputType.Use) && !SelectedConstruction.IsShootable)
|
||||
{
|
||||
if (!SelectedConstruction.RequireAimToUse || IsKeyDown(InputType.Aim))
|
||||
{
|
||||
SelectedConstruction.Use(deltaTime, this);
|
||||
}
|
||||
}
|
||||
if (IsKeyDown(InputType.Shoot) && SelectedConstruction.IsShootable)
|
||||
{
|
||||
if (!SelectedConstruction.RequireAimToUse || IsKeyDown(InputType.Aim))
|
||||
{
|
||||
SelectedConstruction.Use(deltaTime, this);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace Barotrauma.Items.Components
|
||||
attack = new Attack(subElement, item.Name + ", MeleeWeapon");
|
||||
}
|
||||
item.IsShootable = true;
|
||||
item.RequireAimToUse = true;
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Barotrauma.Items.Components
|
||||
: base(item, element)
|
||||
{
|
||||
item.IsShootable = true;
|
||||
item.RequireAimToUse = true;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
item.IsShootable = true;
|
||||
item.RequireAimToUse = true;
|
||||
InitProjSpecific(element);
|
||||
}
|
||||
|
||||
@@ -311,7 +312,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
sinTime += deltaTime;
|
||||
character.CursorPosition = leak.Position + VectorExtensions.Forward(Item.body.TransformedRotation + (float)Math.Sin(sinTime), dist);
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
if (item.RequireAimToUse)
|
||||
{
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
}
|
||||
|
||||
// Press the trigger only when the tool is approximately facing the target.
|
||||
// If the character is climbing, ignore the check, because we cannot aim while climbing.
|
||||
|
||||
@@ -43,12 +43,6 @@ namespace Barotrauma.Items.Components
|
||||
set { userPos = value; }
|
||||
}
|
||||
|
||||
[Serialize(false, true)]
|
||||
public bool RequireAimToUse
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Controller(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
@@ -152,7 +146,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
limb.PullJointEnabled = true;
|
||||
limb.PullJointWorldAnchorB = limb.SimPosition + ConvertUnits.ToSimUnits(diff);
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.RequireAimToUse)
|
||||
{
|
||||
Control(deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character activator = null)
|
||||
@@ -169,8 +168,6 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RequireAimToUse && !activator.IsKeyDown(InputType.Aim)) return false;
|
||||
|
||||
item.SendSignal(0, "1", "trigger_out", character);
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, activator);
|
||||
@@ -179,6 +176,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (item.RequireAimToUse)
|
||||
{
|
||||
return Control(deltaTime, character);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool Control(float deltaTime, Character character = null)
|
||||
{
|
||||
if (this.character != character)
|
||||
{
|
||||
@@ -191,7 +197,7 @@ namespace Barotrauma.Items.Components
|
||||
this.character = null;
|
||||
return false;
|
||||
}
|
||||
if (character == null) return false;
|
||||
if (character == null) return false;
|
||||
|
||||
focusTarget = GetFocusTarget();
|
||||
if (focusTarget == null)
|
||||
@@ -204,7 +210,7 @@ namespace Barotrauma.Items.Components
|
||||
targetRotation = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(offset));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
character.ViewTarget = focusTarget;
|
||||
#if CLIENT
|
||||
if (character == Character.Controlled && cam != null)
|
||||
@@ -215,7 +221,7 @@ namespace Barotrauma.Items.Components
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (focusTarget as Item).Prefab.OffsetOnSelected, deltaTime * 10.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (!character.IsRemotePlayer || character.ViewTarget == focusTarget)
|
||||
{
|
||||
Vector2 centerPos = new Vector2(item.WorldRect.Center.X, item.WorldRect.Center.Y);
|
||||
@@ -235,7 +241,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
targetRotation = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(offset));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
item.IsShootable = true;
|
||||
item.RequireAimToUse = false;
|
||||
InitProjSpecific(element);
|
||||
}
|
||||
|
||||
@@ -488,7 +489,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
character.CursorPosition = closestEnemy.WorldPosition;
|
||||
if (item.Submarine != null) character.CursorPosition -= item.Submarine.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
if (item.RequireAimToUse)
|
||||
{
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
}
|
||||
|
||||
float enemyAngle = MathUtils.VectorToAngle(closestEnemy.WorldPosition - item.WorldPosition);
|
||||
float turretAngle = -rotation;
|
||||
|
||||
@@ -241,6 +241,15 @@ namespace Barotrauma
|
||||
[Serialize(false, false)]
|
||||
public bool IsShootable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the user has to hold the "aim" key before use is registered.
|
||||
/// </summary>
|
||||
[Serialize(false, false)]
|
||||
public bool RequireAimToUse
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return spriteColor; }
|
||||
@@ -1459,6 +1468,11 @@ namespace Barotrauma
|
||||
|
||||
public void Use(float deltaTime, Character character = null, Limb targetLimb = null)
|
||||
{
|
||||
if (RequireAimToUse && !character.IsKeyDown(InputType.Aim))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (condition == 0.0f) return;
|
||||
|
||||
bool remove = false;
|
||||
|
||||
Reference in New Issue
Block a user