(fdc038d5d) Keymapping and UX test: - Map use to "E" and Select to "Left Mouse". - Introduce a dedicated key for deselecting ("Right Mouse"). - Introduce a dedicated key for shooting ("Left Mouse"). - Define certain objects as shootables, which simply means that they use the "Shoot" key instead of using the "Use" key. This required the least amount of refactoring the existing code. - TODO: don't register the "Select" input when aiming or when an interface is open -> should prevent interacting through UI elements. - TODO: sync the new input types with the server.
This commit is contained in:
@@ -1264,18 +1264,39 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < selectedItems.Length; i++ )
|
||||
{
|
||||
if (selectedItems[i] == null) continue;
|
||||
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
|
||||
|
||||
if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
|
||||
if (selectedItems[i] == null) { continue; }
|
||||
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)
|
||||
{
|
||||
item.Use(deltaTime, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedConstruction != null)
|
||||
{
|
||||
if (IsKeyDown(InputType.Use)) SelectedConstruction.Use(deltaTime, this);
|
||||
if (SelectedConstruction != null && IsKeyDown(InputType.Aim)) SelectedConstruction.SecondaryUse(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Use) && !SelectedConstruction.IsShootable)
|
||||
{
|
||||
SelectedConstruction.Use(deltaTime, this);
|
||||
}
|
||||
if (IsKeyDown(InputType.Aim))
|
||||
{
|
||||
SelectedConstruction.SecondaryUse(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Shoot) && SelectedConstruction.IsShootable)
|
||||
{
|
||||
SelectedConstruction.Use(deltaTime, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedCharacter != null)
|
||||
@@ -1753,7 +1774,7 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (IsKeyHit(InputType.Select) && SelectedConstruction != null)
|
||||
else if (IsKeyHit(InputType.Deselect) && SelectedConstruction != null)
|
||||
{
|
||||
SelectedConstruction = null;
|
||||
#if CLIENT
|
||||
@@ -1898,7 +1919,7 @@ namespace Barotrauma
|
||||
//cannot be protected from pressure when below crush depth
|
||||
protectedFromPressure = protectedFromPressure && WorldPosition.Y > CharacterHealth.CrushDepth;
|
||||
//implode if not protected from pressure, and either outside or in a high-pressure hull
|
||||
if (!protectedFromPressure &&
|
||||
if (!protectedFromPressure &&
|
||||
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 80.0f))
|
||||
{
|
||||
if (CharacterHealth.PressureKillDelay <= 0.0f)
|
||||
@@ -1913,7 +1934,7 @@ namespace Barotrauma
|
||||
|
||||
if (PressureTimer >= 100.0f)
|
||||
{
|
||||
if (Controlled == this) { cam.Zoom = 5.0f; }
|
||||
if (Controlled == this) cam.Zoom = 5.0f;
|
||||
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
|
||||
{
|
||||
Implode();
|
||||
@@ -2194,7 +2215,7 @@ namespace Barotrauma
|
||||
|
||||
if (limbHit == null) return new AttackResult();
|
||||
|
||||
limbHit.body?.ApplyLinearImpulse(attack.TargetImpulseWorld + attack.TargetForceWorld * deltaTime, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
limbHit.body?.ApplyLinearImpulse(attack.TargetImpulseWorld + attack.TargetForceWorld * deltaTime);
|
||||
#if SERVER
|
||||
if (attacker is Character attackingCharacter && attackingCharacter.AIController == null)
|
||||
{
|
||||
@@ -2280,8 +2301,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 diff = dir;
|
||||
if (diff == Vector2.Zero) diff = Rand.Vector(1.0f);
|
||||
hitLimb.body.ApplyLinearImpulse(Vector2.Normalize(diff) * attackImpulse, hitLimb.SimPosition + ConvertUnits.ToSimUnits(diff),
|
||||
maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
hitLimb.body.ApplyLinearImpulse(Vector2.Normalize(diff) * attackImpulse, hitLimb.SimPosition + ConvertUnits.ToSimUnits(diff));
|
||||
}
|
||||
Vector2 simPos = hitLimb.SimPosition + ConvertUnits.ToSimUnits(dir);
|
||||
AttackResult attackResult = hitLimb.AddDamage(simPos, afflictions, playSound);
|
||||
|
||||
Reference in New Issue
Block a user