(12412e6fd) Determine the steering vector relative to the center of the sub, not the center of the display when clicking on the display
This commit is contained in:
@@ -138,6 +138,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool IgnoreLayoutGroups;
|
public bool IgnoreLayoutGroups;
|
||||||
|
|
||||||
|
public bool IgnoreLayoutGroups;
|
||||||
|
|
||||||
public virtual ScalableFont Font
|
public virtual ScalableFont Font
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ namespace Barotrauma
|
|||||||
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
|
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
|
||||||
Tag = tag;
|
Tag = tag;
|
||||||
|
|
||||||
|
InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null);
|
||||||
|
GUI.Style.Apply(InnerFrame, "", this);
|
||||||
|
|
||||||
|
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
|
||||||
|
Tag = tag;
|
||||||
|
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
{
|
{
|
||||||
string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font);
|
string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font);
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window);
|
GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window);
|
||||||
|
|
||||||
|
GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window);
|
||||||
|
|
||||||
|
|
||||||
|
PerformanceCounter = new PerformanceCounter();
|
||||||
|
|
||||||
PerformanceCounter = new PerformanceCounter();
|
PerformanceCounter = new PerformanceCounter();
|
||||||
|
|
||||||
@@ -786,20 +790,6 @@ namespace Barotrauma
|
|||||||
Config.SaveNewPlayerConfig();
|
Config.SaveNewPlayerConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
msgBox.Text.RectTransform.MaxSize = new Point(int.MaxValue, msgBox.Text.Rect.Height);
|
|
||||||
linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
|
|
||||||
msgBox.RectTransform.MinSize = new Point(0, msgBox.Rect.Height + linkHolder.Rect.Height + msgBox.Buttons.First().Rect.Height * 8);
|
|
||||||
Config.EditorDisclaimerShown = true;
|
|
||||||
Config.SaveNewPlayerConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
msgBox.Text.RectTransform.MaxSize = new Point(int.MaxValue, msgBox.Text.Rect.Height);
|
|
||||||
linkHolder.RectTransform.MaxSize = new Point(int.MaxValue, linkHolder.Rect.Height);
|
|
||||||
msgBox.RectTransform.MinSize = new Point(0, msgBox.Rect.Height + linkHolder.Rect.Height + msgBox.Buttons.First().Rect.Height * 8);
|
|
||||||
Config.EditorDisclaimerShown = true;
|
|
||||||
Config.SaveNewPlayerConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ToDo: Move texts/links to localization, when possible.
|
// ToDo: Move texts/links to localization, when possible.
|
||||||
public void ShowBugReporter()
|
public void ShowBugReporter()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,6 +98,20 @@ namespace Barotrauma
|
|||||||
CanBeFocused = false
|
CanBeFocused = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scrollButtonUp = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.TopLeft, Pivot.TopLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||||
|
{
|
||||||
|
Visible = false,
|
||||||
|
UserData = -1,
|
||||||
|
OnClicked = ScrollCharacterList
|
||||||
|
};
|
||||||
|
scrollButtonDown = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||||
|
{
|
||||||
|
Visible = false,
|
||||||
|
UserData = 1,
|
||||||
|
OnClicked = ScrollCharacterList
|
||||||
|
};
|
||||||
|
scrollButtonDown.Children.ForEach(c => c.SpriteEffects = SpriteEffects.FlipVertically);
|
||||||
|
|
||||||
var characterInfo = new CharacterInfo(subElement);
|
var characterInfo = new CharacterInfo(subElement);
|
||||||
characterInfos.Add(characterInfo);
|
characterInfos.Add(characterInfo);
|
||||||
foreach (XElement invElement in subElement.Elements())
|
foreach (XElement invElement in subElement.Elements())
|
||||||
@@ -159,6 +173,16 @@ namespace Barotrauma
|
|||||||
ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen;
|
ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Character list management
|
||||||
|
|
||||||
|
public Rectangle GetCharacterListArea()
|
||||||
|
{
|
||||||
|
return characterListBox.Rect;
|
||||||
|
}
|
||||||
|
|
||||||
partial void InitProjectSpecific()
|
partial void InitProjectSpecific()
|
||||||
{
|
{
|
||||||
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
||||||
|
|||||||
@@ -329,12 +329,20 @@ namespace Barotrauma.Items.Components
|
|||||||
int x = rect.X;
|
int x = rect.X;
|
||||||
int y = rect.Y;
|
int y = rect.Y;
|
||||||
|
|
||||||
if (voltage < minVoltage && currPowerConsumption > 0.0f) return;
|
//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);
|
||||||
|
|
||||||
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
|
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
|
||||||
|
Vector2 displaySubPos = (-sonar.DisplayOffset * sonar.Zoom) / sonar.Range * sonar.DisplayRadius * sonar.Zoom;
|
||||||
|
displaySubPos.Y = -displaySubPos.Y;
|
||||||
|
displaySubPos = displaySubPos.ClampLength(velRect.Width / 2);
|
||||||
|
displaySubPos = steerArea.Rect.Center.ToVector2() + displaySubPos;
|
||||||
|
|
||||||
GUI.DrawLine(spriteBatch,
|
GUI.DrawLine(spriteBatch,
|
||||||
new Vector2(velRect.Center.X, velRect.Center.Y),
|
displaySubPos,
|
||||||
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),
|
new Vector2(displaySubPos.X + currVelocity.X, displaySubPos.Y - currVelocity.Y),
|
||||||
Color.Gray);
|
Color.Gray);
|
||||||
|
|
||||||
if (!AutoPilot)
|
if (!AutoPilot)
|
||||||
@@ -344,17 +352,10 @@ namespace Barotrauma.Items.Components
|
|||||||
Vector2 steeringInputPos = new Vector2(
|
Vector2 steeringInputPos = new Vector2(
|
||||||
steeringInput.X * (float)Math.Sqrt(1.0f - 0.5f * unitSteeringInput.Y * unitSteeringInput.Y),
|
steeringInput.X * (float)Math.Sqrt(1.0f - 0.5f * unitSteeringInput.Y * unitSteeringInput.Y),
|
||||||
-steeringInput.Y * (float)Math.Sqrt(1.0f - 0.5f * unitSteeringInput.X * unitSteeringInput.X));
|
-steeringInput.Y * (float)Math.Sqrt(1.0f - 0.5f * unitSteeringInput.X * unitSteeringInput.X));
|
||||||
steeringInputPos.X += velRect.Center.X;
|
steeringInputPos += displaySubPos;
|
||||||
steeringInputPos.Y += velRect.Center.Y;
|
|
||||||
|
|
||||||
GUI.DrawLine(spriteBatch,
|
|
||||||
new Vector2(velRect.Center.X, velRect.Center.Y),
|
|
||||||
steeringInputPos,
|
|
||||||
Color.LightGray);
|
|
||||||
|
|
||||||
|
GUI.DrawLine(spriteBatch, displaySubPos, steeringInputPos, Color.LightGray);
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 5, (int)steeringInputPos.Y - 5, 10, 10), Color.White);
|
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 5, (int)steeringInputPos.Y - 5, 10, 10), Color.White);
|
||||||
|
|
||||||
//if (keyboardInput.Length() > 0 || Vector2.Distance(PlayerInput.MousePosition, new Vector2(velRect.Center.X, velRect.Center.Y)) < 200.0f)
|
|
||||||
if (velRect.Contains(PlayerInput.MousePosition))
|
if (velRect.Contains(PlayerInput.MousePosition))
|
||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 10, (int)steeringInputPos.Y - 10, 20, 20), Color.Red);
|
GUI.DrawRectangle(spriteBatch, new Rectangle((int)steeringInputPos.X - 10, (int)steeringInputPos.Y - 10, 20, 20), Color.Red);
|
||||||
@@ -385,11 +386,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 displaySubPos = ((posToMaintain.Value - sonar.DisplayOffset * sonar.Zoom - controlledSub.WorldPosition)) / sonar.Range * sonar.DisplayRadius * sonar.Zoom;
|
|
||||||
displaySubPos.Y = -displaySubPos.Y;
|
|
||||||
displaySubPos = displaySubPos.ClampLength(velRect.Width / 2);
|
|
||||||
displaySubPos = velRect.Center.ToVector2() + displaySubPos;
|
|
||||||
|
|
||||||
//map velocity from rectangle to circle
|
//map velocity from rectangle to circle
|
||||||
Vector2 unitTargetVel = targetVelocity / 100.0f;
|
Vector2 unitTargetVel = targetVelocity / 100.0f;
|
||||||
Vector2 steeringPos = new Vector2(
|
Vector2 steeringPos = new Vector2(
|
||||||
@@ -397,6 +393,15 @@ namespace Barotrauma.Items.Components
|
|||||||
-targetVelocity.Y * 0.9f * (float)Math.Sqrt(1.0f - 0.5f * unitTargetVel.X * unitTargetVel.X));
|
-targetVelocity.Y * 0.9f * (float)Math.Sqrt(1.0f - 0.5f * unitTargetVel.X * unitTargetVel.X));
|
||||||
steeringPos += displaySubPos;
|
steeringPos += displaySubPos;
|
||||||
|
|
||||||
|
public void DrawHUD(SpriteBatch spriteBatch, Rectangle rect)
|
||||||
|
{
|
||||||
|
int width = rect.Width, height = rect.Height;
|
||||||
|
int x = rect.X;
|
||||||
|
int y = rect.Y;
|
||||||
|
|
||||||
|
if (voltage < minVoltage && currPowerConsumption > 0.0f) return;
|
||||||
|
|
||||||
|
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
|
||||||
GUI.DrawLine(spriteBatch,
|
GUI.DrawLine(spriteBatch,
|
||||||
displaySubPos,
|
displaySubPos,
|
||||||
steeringPos,
|
steeringPos,
|
||||||
@@ -457,7 +462,6 @@ namespace Barotrauma.Items.Components
|
|||||||
Color.Lerp(Color.Green, Color.Orange, obstacle.Dot), width: 2);
|
Color.Lerp(Color.Green, Color.Orange, obstacle.Dot), width: 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
@@ -516,21 +520,13 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (Vector2.Distance(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerArea.Rect.Width / 2)
|
if (Vector2.Distance(PlayerInput.MousePosition, steerArea.Rect.Center.ToVector2()) < steerArea.Rect.Width / 2)
|
||||||
{
|
{
|
||||||
tipContainer.Visible = true;
|
if (PlayerInput.LeftButtonHeld())
|
||||||
tipContainer.Text = noPowerTip;
|
{
|
||||||
return;
|
Vector2 displaySubPos = (-sonar.DisplayOffset * sonar.Zoom) / sonar.Range * sonar.DisplayRadius * sonar.Zoom;
|
||||||
}
|
displaySubPos.Y = -displaySubPos.Y;
|
||||||
|
displaySubPos = steerArea.Rect.Center.ToVector2() + displaySubPos;
|
||||||
|
|
||||||
tipContainer.Visible = AutoPilot;
|
Vector2 inputPos = PlayerInput.MousePosition - displaySubPos;
|
||||||
if (AutoPilot)
|
|
||||||
{
|
|
||||||
if (maintainPos)
|
|
||||||
{
|
|
||||||
tipContainer.Text = autoPilotMaintainPosTip;
|
|
||||||
}
|
|
||||||
else if (LevelStartSelected)
|
|
||||||
{
|
|
||||||
Vector2 inputPos = PlayerInput.MousePosition - steerArea.Rect.Center.ToVector2();
|
|
||||||
inputPos.Y = -inputPos.Y;
|
inputPos.Y = -inputPos.Y;
|
||||||
if (AutoPilot && !LevelStartSelected && !LevelEndSelected)
|
if (AutoPilot && !LevelStartSelected && !LevelEndSelected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -434,6 +434,33 @@ namespace Barotrauma
|
|||||||
Color.Green, width: 2);
|
Color.Green, width: 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (MapEntity e in linkedTo)
|
||||||
|
{
|
||||||
|
if (e is Hull)
|
||||||
|
{
|
||||||
|
Hull linkedHull = (Hull)e;
|
||||||
|
Rectangle connectedHullRect = e.Submarine == null ?
|
||||||
|
linkedHull.rect :
|
||||||
|
new Rectangle(
|
||||||
|
(int)(Submarine.DrawPosition.X + linkedHull.WorldPosition.X),
|
||||||
|
(int)(Submarine.DrawPosition.Y + linkedHull.WorldPosition.Y),
|
||||||
|
linkedHull.WorldRect.Width, linkedHull.WorldRect.Height);
|
||||||
|
|
||||||
|
//center of the hull
|
||||||
|
Rectangle currentHullRect = Submarine == null ?
|
||||||
|
WorldRect :
|
||||||
|
new Rectangle(
|
||||||
|
(int)(Submarine.DrawPosition.X + WorldPosition.X),
|
||||||
|
(int)(Submarine.DrawPosition.Y + WorldPosition.Y),
|
||||||
|
WorldRect.Width, WorldRect.Height);
|
||||||
|
|
||||||
|
GUI.DrawLine(spriteBatch,
|
||||||
|
new Vector2(currentHullRect.X, -currentHullRect.Y),
|
||||||
|
new Vector2(connectedHullRect.X, -connectedHullRect.Y),
|
||||||
|
Color.Green, width: 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateVertices(GraphicsDevice graphicsDevice, Camera cam, WaterRenderer renderer)
|
public static void UpdateVertices(GraphicsDevice graphicsDevice, Camera cam, WaterRenderer renderer)
|
||||||
|
|||||||
@@ -1055,6 +1055,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
|
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
|
||||||
|
|
||||||
|
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
|
||||||
|
|
||||||
//goes through all the AItargets, evaluates how preferable it is to attack the target,
|
//goes through all the AItargets, evaluates how preferable it is to attack the target,
|
||||||
//whether the Character can see/hear the target and chooses the most preferable target within
|
//whether the Character can see/hear the target and chooses the most preferable target within
|
||||||
//sight/hearing range
|
//sight/hearing range
|
||||||
|
|||||||
@@ -2567,6 +2567,10 @@ namespace Barotrauma
|
|||||||
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
|
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CLIENT
|
||||||
|
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
|
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user