Merge branch 'master' of https://github.com/Faerdan/Barotrauma into Faerdan-master
Conflicts: Barotrauma/BarotraumaClient/Source/Map/MapEntity.cs Barotrauma/BarotraumaClient/Source/Screens/GameScreen.cs Barotrauma/BarotraumaShared/Source/Characters/Character.cs Barotrauma/BarotraumaShared/Source/Items/Item.cs
This commit is contained in:
@@ -134,69 +134,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!LockHands)
|
||||
{
|
||||
//find the closest item if selectkey has been hit, or if the Character is being
|
||||
//controlled by the player (in order to highlight it)
|
||||
|
||||
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
|
||||
{
|
||||
closestCharacter = FindClosestCharacter(mouseSimPos);
|
||||
if (closestCharacter != null && closestCharacter.info == null)
|
||||
{
|
||||
closestCharacter = null;
|
||||
}
|
||||
|
||||
float closestItemDist = 0.0f;
|
||||
closestItem = FindClosestItem(mouseSimPos, out closestItemDist);
|
||||
|
||||
if (closestCharacter != null && closestItem != null)
|
||||
{
|
||||
if (Vector2.DistanceSquared(closestCharacter.SimPosition, mouseSimPos) < ConvertUnits.ToSimUnits(closestItemDist) * ConvertUnits.ToSimUnits(closestItemDist))
|
||||
{
|
||||
if (selectedConstruction != closestItem) closestItem = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
closestCharacter = null;
|
||||
}
|
||||
}
|
||||
|
||||
findClosestTimer = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
findClosestTimer -= deltaTime;
|
||||
}
|
||||
|
||||
if (selectedCharacter == null && closestItem != null)
|
||||
{
|
||||
closestItem.IsHighlighted = true;
|
||||
if (!LockHands && closestItem.Pick(this))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyHit(InputType.Select))
|
||||
{
|
||||
if (selectedCharacter != null)
|
||||
{
|
||||
DeselectCharacter();
|
||||
}
|
||||
else if (closestCharacter != null && closestCharacter.IsHumanoid && closestCharacter.CanBeSelected)
|
||||
{
|
||||
SelectCharacter(closestCharacter);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedCharacter != null) DeselectCharacter();
|
||||
selectedConstruction = null;
|
||||
closestItem = null;
|
||||
closestCharacter = null;
|
||||
}
|
||||
DoInteractionUpdate(deltaTime, mouseSimPos);
|
||||
|
||||
DisableControls = false;
|
||||
}
|
||||
|
||||
@@ -182,27 +182,27 @@ namespace Barotrauma
|
||||
if (cprButton.Visible) cprButton.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (character.ClosestCharacter != null && character.ClosestCharacter.CanBeSelected)
|
||||
if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected)
|
||||
{
|
||||
Vector2 startPos = character.DrawPosition + (character.ClosestCharacter.DrawPosition - character.DrawPosition) * 0.7f;
|
||||
Vector2 startPos = character.DrawPosition + (character.FocusedCharacter.DrawPosition - character.DrawPosition) * 0.7f;
|
||||
startPos = cam.WorldToScreen(startPos);
|
||||
|
||||
Vector2 textPos = startPos;
|
||||
textPos -= new Vector2(GUI.Font.MeasureString(character.ClosestCharacter.Info.Name).X / 2, 20);
|
||||
textPos -= new Vector2(GUI.Font.MeasureString(character.FocusedCharacter.Info.Name).X / 2, 20);
|
||||
|
||||
GUI.DrawString(spriteBatch, textPos, character.ClosestCharacter.Info.Name, Color.White, Color.Black, 2);
|
||||
GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.Info.Name, Color.White, Color.Black, 2);
|
||||
}
|
||||
else if (character.SelectedCharacter == null && character.ClosestItem != null && character.SelectedConstruction == null)
|
||||
else if (character.SelectedCharacter == null && character.FocusedItem != null && character.SelectedConstruction == null)
|
||||
{
|
||||
var hudTexts = character.ClosestItem.GetHUDTexts(character);
|
||||
var hudTexts = character.FocusedItem.GetHUDTexts(character);
|
||||
|
||||
Vector2 startPos = new Vector2((int)(GameMain.GraphicsWidth / 2.0f), GameMain.GraphicsHeight);
|
||||
startPos.Y -= 50 + hudTexts.Count * 25;
|
||||
|
||||
Vector2 textPos = startPos;
|
||||
textPos -= new Vector2((int)GUI.Font.MeasureString(character.ClosestItem.Name).X / 2, 20);
|
||||
textPos -= new Vector2((int)GUI.Font.MeasureString(character.FocusedItem.Name).X / 2, 20);
|
||||
|
||||
GUI.DrawString(spriteBatch, textPos, character.ClosestItem.Name, Color.White, Color.Black * 0.7f, 2);
|
||||
GUI.DrawString(spriteBatch, textPos, character.FocusedItem.Name, Color.White, Color.Black * 0.7f, 2);
|
||||
|
||||
textPos.Y += 30.0f;
|
||||
foreach (ColoredText coloredText in hudTexts)
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace Barotrauma.Tutorials
|
||||
while (!HasItem("Diving Mask") && !HasItem("Diving Suit"))
|
||||
{
|
||||
if (!divingMaskSelected &&
|
||||
Character.Controlled.ClosestItem != null && Character.Controlled.ClosestItem.Name == "Diving Suit")
|
||||
Character.Controlled.FocusedItem != null && Character.Controlled.FocusedItem.Name == "Diving Suit")
|
||||
{
|
||||
infoBox = CreateInfoFrame("There can only be one item in each inventory slot, so you need to take off "
|
||||
+ "the jumpsuit if you wish to wear a diving suit.");
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace Barotrauma.Items.Components
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Green * 0.1f, true);
|
||||
|
||||
if (character.ClosestCharacter == null) return;
|
||||
if (character.FocusedCharacter == null) return;
|
||||
|
||||
var target = character.ClosestCharacter;
|
||||
var target = character.FocusedCharacter;
|
||||
|
||||
Vector2 hudPos = GameMain.GameScreen.Cam.WorldToScreen(target.WorldPosition);
|
||||
hudPos += Vector2.UnitX * 50.0f;
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace Barotrauma
|
||||
get { return prefab.sprite; }
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (!Visible) return;
|
||||
@@ -32,8 +31,7 @@ namespace Barotrauma
|
||||
|
||||
if (prefab.sprite != null)
|
||||
{
|
||||
float depth = Sprite.Depth;
|
||||
depth += (ID % 255) * 0.000001f;
|
||||
float depth = GetDrawDepth();
|
||||
|
||||
if (body == null)
|
||||
{
|
||||
|
||||
@@ -163,15 +163,15 @@ namespace Barotrauma.Lights
|
||||
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
if (Character.Controlled.ClosestItem != null)
|
||||
if (Character.Controlled.FocusedItem != null)
|
||||
{
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
Character.Controlled.FocusedItem.IsHighlighted = true;
|
||||
Character.Controlled.FocusedItem.Draw(spriteBatch, false, true);
|
||||
Character.Controlled.FocusedItem.IsHighlighted = true;
|
||||
}
|
||||
else if (Character.Controlled.ClosestCharacter != null)
|
||||
else if (Character.Controlled.FocusedCharacter != null)
|
||||
{
|
||||
Character.Controlled.ClosestCharacter.Draw(spriteBatch);
|
||||
Character.Controlled.FocusedCharacter.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1071,7 +1071,7 @@ namespace Barotrauma
|
||||
dummyCharacter.SelectedConstruction.UpdateHUD(cam, dummyCharacter);
|
||||
}
|
||||
|
||||
if (PlayerInput.KeyHit(InputType.Select) && dummyCharacter.ClosestItem != dummyCharacter.SelectedConstruction) dummyCharacter.SelectedConstruction = null;
|
||||
if (PlayerInput.KeyHit(InputType.Select) && dummyCharacter.FocusedItem != dummyCharacter.SelectedConstruction) dummyCharacter.SelectedConstruction = null;
|
||||
}
|
||||
|
||||
CharacterHUD.Update((float)deltaTime, dummyCharacter);
|
||||
|
||||
@@ -56,21 +56,16 @@ namespace Barotrauma
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
|
||||
{
|
||||
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
|
||||
{
|
||||
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
|
||||
}
|
||||
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.AddToGUIUpdateList();
|
||||
|
||||
Character.AddAllToGUIUpdateList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
cam.UpdateTransform(true);
|
||||
@@ -80,12 +75,9 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable);
|
||||
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
|
||||
{
|
||||
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
|
||||
{
|
||||
Character.Controlled.SelectedConstruction.DrawHUD(spriteBatch, cam, Character.Controlled);
|
||||
}
|
||||
Character.Controlled.SelectedConstruction.DrawHUD(spriteBatch, cam, Character.Controlled);
|
||||
}
|
||||
|
||||
if (Character.Controlled != null && cam != null) Character.Controlled.DrawHUD(spriteBatch, cam);
|
||||
|
||||
Reference in New Issue
Block a user