(2edf7845f) Progress on docking interface (nudge controls), focus sonar on the center of the submarine instead of the nav terminal
This commit is contained in:
@@ -233,8 +233,7 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 transducerCenter = UseTransducers ? GetTransducerCenter() : item.WorldPosition;
|
||||
transducerCenter += DisplayOffset;
|
||||
Vector2 transducerCenter = GetTransducerPos() + DisplayOffset;
|
||||
|
||||
if (Level.Loaded != null)
|
||||
{
|
||||
@@ -290,16 +289,16 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
float dockingDist = Vector2.Distance(steering.DockingSource.Item.WorldPosition, steering.DockingTarget.Item.WorldPosition);
|
||||
if (prevDockingDist > steering.DockingAssistThreshold && dockingDist <= steering.DockingAssistThreshold)
|
||||
{
|
||||
zoom = Math.Max(zoom, MathHelper.Lerp(MinZoom, MaxZoom, 0.25f));
|
||||
}
|
||||
else if (prevDockingDist > steering.DockingAssistThreshold * 0.75f && dockingDist <= steering.DockingAssistThreshold * 0.75f)
|
||||
{
|
||||
zoom = Math.Max(zoom, MathHelper.Lerp(MinZoom, MaxZoom, 0.5f));
|
||||
}
|
||||
else if (prevDockingDist > steering.DockingAssistThreshold * 0.6f && dockingDist <= steering.DockingAssistThreshold * 0.6f)
|
||||
else if (prevDockingDist > steering.DockingAssistThreshold * 0.5f && dockingDist <= steering.DockingAssistThreshold * 0.5f)
|
||||
{
|
||||
zoom = Math.Max(zoom, MathHelper.Lerp(MinZoom, MaxZoom, 0.75f));
|
||||
}
|
||||
else if (prevDockingDist > steering.DockingAssistThreshold * 0.3f && dockingDist <= steering.DockingAssistThreshold * 0.3f)
|
||||
{
|
||||
zoom = Math.Max(zoom, MaxZoom);
|
||||
zoom = Math.Max(zoom, MathHelper.Lerp(MinZoom, MaxZoom, 0.25f));
|
||||
}
|
||||
prevDockingDist = Math.Min(dockingDist, prevDockingDist);
|
||||
}
|
||||
@@ -378,7 +377,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 transducerCenter = UseTransducers && connectedTransducers.Count > 0 ? GetTransducerCenter() : item.WorldPosition;
|
||||
Vector2 transducerCenter = GetTransducerPos();
|
||||
|
||||
if (item.Submarine != null && !DetectSubmarineWalls)
|
||||
{
|
||||
@@ -606,13 +605,16 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Vector2 dockingDir = sourcePortPos - targetPortPos;
|
||||
Vector2 normalizedDockingDir = Vector2.Normalize(dockingDir);
|
||||
if (steering.DockingSource.IsHorizontal)
|
||||
if (!DynamicDockingIndicator)
|
||||
{
|
||||
normalizedDockingDir = new Vector2(Math.Sign(normalizedDockingDir.X), 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
normalizedDockingDir = new Vector2(0.0f, Math.Sign(normalizedDockingDir.Y));
|
||||
if (steering.DockingSource.IsHorizontal)
|
||||
{
|
||||
normalizedDockingDir = new Vector2(Math.Sign(normalizedDockingDir.X), 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
normalizedDockingDir = new Vector2(0.0f, Math.Sign(normalizedDockingDir.Y));
|
||||
}
|
||||
}
|
||||
|
||||
Color staticLineColor = Color.White * 0.8f;
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
private GUITickBox maintainPosTickBox, levelEndTickBox, levelStartTickBox;
|
||||
|
||||
private GUIComponent statusContainer, dockingContainer;
|
||||
|
||||
private GUIFrame autoPilotControlsDisabler;
|
||||
|
||||
private GUIComponent steerArea;
|
||||
@@ -78,7 +80,7 @@ namespace Barotrauma.Items.Components
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
var statusContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
statusContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0) }, "SonarFrame");
|
||||
var paddedStatusContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), statusContainer.RectTransform, Anchor.Center))
|
||||
{
|
||||
@@ -107,7 +109,9 @@ namespace Barotrauma.Items.Components
|
||||
AutoPilot = box.Selected;
|
||||
if (AutoPilot && MaintainPos)
|
||||
{
|
||||
posToMaintain = controlledSub == null ? item.WorldPosition : controlledSub.WorldPosition;
|
||||
posToMaintain = controlledSub != null ?
|
||||
controlledSub.WorldPosition :
|
||||
item.Submarine == null ? item.WorldPosition : item.Submarine.WorldPosition;
|
||||
}
|
||||
unsentChanges = true;
|
||||
user = Character.Controlled;
|
||||
@@ -278,6 +282,34 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
steerArea = new GUICustomComponent(new RectTransform(new Point(viewSize), GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawHUD(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
|
||||
//docking interface ----------------------------------------------------
|
||||
dockingContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0) }, style: null);
|
||||
var paddedDockingContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), dockingContainer.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
var dockButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.3f), paddedDockingContainer.RectTransform, Anchor.Center), "Dock");
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.3f), paddedDockingContainer.RectTransform, Anchor.CenterLeft), "<")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = -Vector2.UnitX
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.3f), paddedDockingContainer.RectTransform, Anchor.CenterRight), ">")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = Vector2.UnitX
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.3f), paddedDockingContainer.RectTransform, Anchor.TopCenter), "U")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = Vector2.UnitY
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.3f), paddedDockingContainer.RectTransform, Anchor.BottomCenter), "D")
|
||||
{
|
||||
OnClicked = NudgeButtonClicked,
|
||||
UserData = -Vector2.UnitY
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -431,6 +463,9 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
dockingContainer.Visible = DockingModeEnabled;
|
||||
statusContainer.Visible = !DockingModeEnabled;
|
||||
|
||||
autoPilotControlsDisabler.Visible = !AutoPilot;
|
||||
|
||||
if (voltage < minVoltage && currPowerConsumption > 0.0f)
|
||||
@@ -472,9 +507,9 @@ namespace Barotrauma.Items.Components
|
||||
inputPos.Y = -inputPos.Y;
|
||||
if (AutoPilot && !LevelStartSelected && !LevelEndSelected)
|
||||
{
|
||||
posToMaintain = controlledSub == null ?
|
||||
item.WorldPosition :
|
||||
controlledSub.WorldPosition + (sonar.DisplayOffset * sonar.Zoom) + inputPos / sonar.DisplayRadius * sonar.Range / sonar.Zoom;
|
||||
posToMaintain = controlledSub != null ?
|
||||
controlledSub.WorldPosition + (sonar.DisplayOffset * sonar.Zoom) + inputPos / sonar.DisplayRadius * sonar.Range / sonar.Zoom :
|
||||
item.Submarine == null ? item.WorldPosition : item.Submarine.WorldPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -570,6 +605,26 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool NudgeButtonClicked(GUIButton btn, object userdata)
|
||||
{
|
||||
if (!MaintainPos)
|
||||
{
|
||||
posToMaintain = item.Submarine.WorldPosition;
|
||||
}
|
||||
MaintainPos = true;
|
||||
if (userdata is Vector2)
|
||||
{
|
||||
Sonar sonar = item.GetComponent<Sonar>();
|
||||
Vector2 nudgeAmount = (Vector2)userdata;
|
||||
if (sonar != null)
|
||||
{
|
||||
nudgeAmount *= sonar == null ? 500.0f : 500.0f / sonar.Zoom;
|
||||
}
|
||||
PosToMaintain += nudgeAmount;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClientWrite(Lidgren.Network.NetBuffer msg, object[] extraData = null)
|
||||
{
|
||||
msg.Write(autoPilot);
|
||||
|
||||
Reference in New Issue
Block a user