Disable aiming with holdable items when using a (railgun) controller, syncing ViewTargetID properly between clients, dropping connected wires when a button is picked up, placing large InterestingPositions on the main path through the level
This commit is contained in:
@@ -301,7 +301,7 @@ namespace Barotrauma
|
||||
{
|
||||
Structure structure = f2.Body.UserData as Structure;
|
||||
|
||||
if (f2.Body.UserData as SubmarineBody != null) return true;
|
||||
if (f2.Body.UserData as Submarine != null && character.Submarine == f2.Body.UserData as Submarine) return false;
|
||||
|
||||
//always collides with bodies other than structures
|
||||
if (structure == null)
|
||||
|
||||
@@ -106,6 +106,8 @@ namespace Barotrauma
|
||||
private float[] soundRange;
|
||||
//which AIstate each sound is for
|
||||
private AIController.AiState[] soundStates;
|
||||
|
||||
private Entity viewTarget;
|
||||
|
||||
|
||||
private CharacterInfo info;
|
||||
@@ -1380,15 +1382,21 @@ namespace Barotrauma
|
||||
|
||||
if (secondaryHeld)
|
||||
{
|
||||
if (Character.controlled==this)
|
||||
{
|
||||
viewTarget = Lights.LightManager.ViewTarget == null ? this : Lights.LightManager.ViewTarget;
|
||||
}
|
||||
if (viewTarget == null) viewTarget = this;
|
||||
|
||||
Vector2 relativeCursorPosition = cursorPosition;
|
||||
relativeCursorPosition -= Lights.LightManager.ViewTarget == null ? Position : Lights.LightManager.ViewTarget.Position;
|
||||
relativeCursorPosition -= viewTarget.Position;
|
||||
|
||||
if (relativeCursorPosition.Length()>500.0f)
|
||||
{
|
||||
relativeCursorPosition = Vector2.Normalize(relativeCursorPosition) * 495.0f;
|
||||
}
|
||||
|
||||
message.Write(Lights.LightManager.ViewTarget == null ? (ushort)0 : Lights.LightManager.ViewTarget.ID);
|
||||
message.Write(viewTarget.ID);
|
||||
|
||||
message.WriteRangedSingle(relativeCursorPosition.X, -500.0f, 500.0f, 8);
|
||||
message.WriteRangedSingle(relativeCursorPosition.Y, -500.0f, 500.0f, 8);
|
||||
@@ -1556,13 +1564,14 @@ namespace Barotrauma
|
||||
float dir = 1.0f;
|
||||
Vector2 pos = Vector2.Zero;
|
||||
|
||||
ushort viewTargetId = 0;
|
||||
ushort viewTargetID = 0;
|
||||
viewTarget = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (secondaryKeyState)
|
||||
{
|
||||
viewTargetId = message.ReadUInt16();
|
||||
viewTargetID = message.ReadUInt16();
|
||||
|
||||
relativeCursorPos = new Vector2(
|
||||
message.ReadRangedSingle(-500.0f, 500.0f, 8),
|
||||
@@ -1600,7 +1609,7 @@ namespace Barotrauma
|
||||
{
|
||||
|
||||
cursorPosition = MathUtils.IsValid(relativeCursorPos) ? relativeCursorPos : Vector2.Zero;
|
||||
Entity viewTarget = viewTargetId == 0 ? this : Entity.FindEntityByID(viewTargetId);
|
||||
viewTarget = viewTargetID == 0 ? this : Entity.FindEntityByID(viewTargetID);
|
||||
if (viewTarget == null) viewTarget = this;
|
||||
|
||||
cursorPosition += viewTarget.Position;
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Drop(Character dropper)
|
||||
{
|
||||
DropConnectedWires(dropper);
|
||||
|
||||
if (body != null) item.body = body;
|
||||
|
||||
@@ -246,6 +247,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
item.Submarine = picker.Submarine;
|
||||
|
||||
if (picker.SelectedConstruction != null && picker.SelectedConstruction.GetComponent<Controller>() != null) return;
|
||||
|
||||
//item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f;
|
||||
|
||||
ac.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle);
|
||||
|
||||
@@ -97,20 +97,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
item.linkedTo.Clear();
|
||||
|
||||
var connectionPanel = item.GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel != null)
|
||||
{
|
||||
foreach (Connection c in connectionPanel.Connections)
|
||||
{
|
||||
foreach (Wire w in c.Wires)
|
||||
{
|
||||
if (w == null) continue;
|
||||
|
||||
w.Item.Drop(picker);
|
||||
w.Item.SetTransform(picker.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
DropConnectedWires(picker);
|
||||
|
||||
ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
|
||||
|
||||
@@ -134,7 +121,9 @@ namespace Barotrauma.Items.Components
|
||||
pickTimer = 0.0f;
|
||||
while (pickTimer < requiredTime)
|
||||
{
|
||||
if (picker.IsKeyHit(InputType.Aim) || !item.IsInPickRange(picker.WorldPosition))
|
||||
if (picker.IsKeyDown(InputType.Aim) ||
|
||||
!item.IsInPickRange(picker.WorldPosition) ||
|
||||
picker.Stun > 0.0f || picker.IsDead)
|
||||
{
|
||||
StopPicking(picker);
|
||||
yield return CoroutineStatus.Success;
|
||||
@@ -159,7 +148,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
StopPicking(picker);
|
||||
|
||||
OnPicked(picker);
|
||||
if (!picker.IsNetworkPlayer) OnPicked(picker);
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
@@ -170,6 +159,25 @@ namespace Barotrauma.Items.Components
|
||||
pickTimer = 0.0f;
|
||||
}
|
||||
|
||||
protected void DropConnectedWires(Character character)
|
||||
{
|
||||
if (character == null) return;
|
||||
|
||||
var connectionPanel = item.GetComponent<ConnectionPanel>();
|
||||
if (connectionPanel == null) return;
|
||||
|
||||
foreach (Connection c in connectionPanel.Connections)
|
||||
{
|
||||
foreach (Wire w in c.Wires)
|
||||
{
|
||||
if (w == null) continue;
|
||||
|
||||
w.Item.Drop(character);
|
||||
w.Item.SetTransform(character.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
@@ -198,7 +206,9 @@ namespace Barotrauma.Items.Components
|
||||
//}
|
||||
}
|
||||
|
||||
if (picker==null || picker.Inventory == null) return;
|
||||
if (picker == null || picker.Inventory == null) return;
|
||||
|
||||
DropConnectedWires(picker);
|
||||
|
||||
item.Submarine = picker.Submarine;
|
||||
|
||||
|
||||
@@ -68,13 +68,14 @@ namespace Barotrauma.Items.Components
|
||||
this.cam = cam;
|
||||
|
||||
if (character == null
|
||||
|| character.IsDead
|
||||
|| character.Stun > 0.0f
|
||||
|| character.SelectedConstruction != item
|
||||
|| Vector2.Distance(character.Position, item.Position) > item.PickDistance * 1.5f)
|
||||
|| Vector2.Distance(character.Position, item.Position) > item.PickDistance * 2.0f)
|
||||
{
|
||||
if (character != null)
|
||||
{
|
||||
character.SelectedConstruction = null;
|
||||
character.AnimController.Anim = AnimController.Animation.None;
|
||||
CancelUsing(character);
|
||||
character = null;
|
||||
}
|
||||
IsActive = false;
|
||||
@@ -119,15 +120,13 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
limb.Disabled = true;
|
||||
|
||||
FixedMouseJoint fmj = limb.pullJoint;
|
||||
if (fmj == null) continue;
|
||||
if (limb.pullJoint == null) continue;
|
||||
|
||||
Vector2 position = ConvertUnits.ToSimUnits(lb.position + new Vector2(item.Rect.X, item.Rect.Y));
|
||||
fmj.Enabled = true;
|
||||
fmj.WorldAnchorB = position;
|
||||
limb.pullJoint.Enabled = true;
|
||||
limb.pullJoint.WorldAnchorB = position;
|
||||
}
|
||||
|
||||
item.SendSignal(ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character activator = null)
|
||||
@@ -153,6 +152,8 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (character!=null) item.SendSignal(ToolBox.Vector2ToString(character.CursorWorldPosition), "position_out");
|
||||
|
||||
foreach (Connection c in item.Connections)
|
||||
{
|
||||
if (c.Name != "position_out") continue;
|
||||
@@ -183,20 +184,42 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CancelUsing(Character character)
|
||||
{
|
||||
foreach (LimbPos lb in limbPositions)
|
||||
{
|
||||
Limb limb = character.AnimController.GetLimb(lb.limbType);
|
||||
if (limb == null) continue;
|
||||
|
||||
limb.Disabled = false;
|
||||
|
||||
limb.pullJoint.Enabled = false;
|
||||
}
|
||||
|
||||
character.AnimController.Anim = AnimController.Animation.None;
|
||||
}
|
||||
|
||||
public override bool Select(Character activator = null)
|
||||
{
|
||||
if (character!=null && character.SelectedConstruction == item)
|
||||
{
|
||||
character = null;
|
||||
IsActive = false;
|
||||
if (activator != null) activator.AnimController.Anim = AnimController.Animation.None;
|
||||
if (activator == null) return false;
|
||||
|
||||
return true;
|
||||
//someone already using the item
|
||||
if (character != null)
|
||||
{
|
||||
if (character == activator)
|
||||
{
|
||||
IsActive = false;
|
||||
CancelUsing(character);
|
||||
character = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
character = activator;
|
||||
if (activator == null) return false;
|
||||
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
@@ -166,11 +166,11 @@ namespace Barotrauma
|
||||
for (float x = startPosition.X; x < endPosition.X; x += Rand.Range(5000.0f, 10000.0f, false))
|
||||
{
|
||||
pathNodes.Add(new Vector2(x, Rand.Range(pathBorders.Y, pathBorders.Bottom, false)));
|
||||
}
|
||||
|
||||
//if (x > borders.Center.X)
|
||||
//{
|
||||
// positionsOfInterest.Add(pathNodes.Last());
|
||||
//}
|
||||
for (int i = 2; i < pathNodes.Count; i+=3 )
|
||||
{
|
||||
positionsOfInterest.Add(new InterestingPosition(pathNodes[i], true));
|
||||
}
|
||||
|
||||
pathNodes.Add(endPosition);
|
||||
@@ -1021,7 +1021,7 @@ namespace Barotrauma
|
||||
var positionsWithSpace = positionsOfInterest.FindAll(p => (bool)preferLarge == p.IsLarge);
|
||||
if (!positionsWithSpace.Any()) return Size * 0.5f;
|
||||
|
||||
return positionsWithSpace[Rand.Int(positionsOfInterest.Count, !useSyncedRand)].Position;
|
||||
return positionsWithSpace[Rand.Int(positionsWithSpace.Count, !useSyncedRand)].Position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user