(af16ecdfa) Merge branch 'dev' into human-ai
This commit is contained in:
@@ -49,6 +49,8 @@ namespace Barotrauma
|
||||
|
||||
private GUIComponent orderTargetFrame, orderTargetFrameShadow;
|
||||
|
||||
public bool AllowCharacterSwitch = true;
|
||||
|
||||
public bool ToggleCrewAreaOpen
|
||||
{
|
||||
get { return toggleCrewAreaOpen; }
|
||||
@@ -63,6 +65,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public List<GUIButton> OrderOptionButtons = new List<GUIButton>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@@ -98,6 +102,20 @@ namespace Barotrauma
|
||||
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);
|
||||
characterInfos.Add(characterInfo);
|
||||
foreach (XElement invElement in subElement.Elements())
|
||||
@@ -159,6 +177,16 @@ namespace Barotrauma
|
||||
ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Character list management
|
||||
|
||||
public Rectangle GetCharacterListArea()
|
||||
{
|
||||
return characterListBox.Rect;
|
||||
}
|
||||
|
||||
partial void InitProjectSpecific()
|
||||
{
|
||||
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
||||
@@ -547,7 +575,10 @@ namespace Barotrauma
|
||||
orderButtonFrame.RectTransform;
|
||||
|
||||
var btn = new GUIButton(new RectTransform(new Point(iconSize, iconSize), btnParent, Anchor.CenterLeft),
|
||||
style: null);
|
||||
style: null)
|
||||
{
|
||||
UserData = order
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(1.5f), btn.RectTransform, Anchor.Center), "OuterGlow")
|
||||
{
|
||||
@@ -639,6 +670,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool CharacterClicked(GUIComponent component, object selection)
|
||||
{
|
||||
if (!AllowCharacterSwitch) { return false; }
|
||||
Character character = selection as Character;
|
||||
if (character == null || character.IsDead || character.IsUnconscious) return false;
|
||||
SelectCharacter(character);
|
||||
@@ -679,8 +711,33 @@ namespace Barotrauma
|
||||
{
|
||||
characterListBox.BarScroll = roundedPos;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
public void AddCharacterInfo(CharacterInfo characterInfo)
|
||||
{
|
||||
if (characterInfos.Contains(characterInfo))
|
||||
{
|
||||
DebugConsole.ThrowError("Tried to add the same character info to CrewManager twice.\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the character from the crew (and crew menus).
|
||||
/// </summary>
|
||||
/// <param name="character">The character to remove</param>
|
||||
/// <param name="removeInfo">If the character info is also removed, the character will not be visible in the round summary.</param>
|
||||
public void RemoveCharacter(Character character, bool removeInfo = false)
|
||||
{
|
||||
if (character == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Tried to remove a null character from CrewManager.\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
characters.Remove(character);
|
||||
if (removeInfo) characterInfos.Remove(character.Info);
|
||||
}
|
||||
|
||||
private IEnumerable<object> KillCharacterAnim(GUIComponent component)
|
||||
@@ -881,6 +938,22 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
character.SetOrder(order, option, orderGiver, speak: orderGiver != character);
|
||||
if (IsSinglePlayer)
|
||||
{
|
||||
orderGiver?.Speak(
|
||||
order.GetChatMessage(character.Name, orderGiver.CurrentHull?.DisplayName, givingOrderToSelf: character == orderGiver, orderOption: option), null);
|
||||
}
|
||||
else if (orderGiver != null)
|
||||
{
|
||||
OrderChatMessage msg = new OrderChatMessage(order, option, order.TargetItemComponent?.Item, character, orderGiver);
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.SendChatMessage(msg);
|
||||
}
|
||||
}
|
||||
DisplayCharacterOrder(character, order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -982,9 +1055,12 @@ namespace Barotrauma
|
||||
if (Character.Controlled == null) return false;
|
||||
SetCharacterOrder(character, userData as Order, option, Character.Controlled);
|
||||
orderTargetFrame = null;
|
||||
OrderOptionButtons.Clear();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
OrderOptionButtons.Add(optionButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1017,9 +1093,13 @@ namespace Barotrauma
|
||||
if (Character.Controlled == null) return false;
|
||||
SetCharacterOrder(character, userData as Order, option, Character.Controlled);
|
||||
orderTargetFrame = null;
|
||||
OrderOptionButtons.Clear();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
OrderOptionButtons.Add(optionButton);
|
||||
|
||||
//lines between the order buttons
|
||||
if (i < order.Options.Length - 1)
|
||||
{
|
||||
@@ -1035,6 +1115,24 @@ namespace Barotrauma
|
||||
color: matchingItems.Count > 1 ? Color.Black * 0.9f : Color.Black * 0.7f);
|
||||
}
|
||||
|
||||
public void HighlightOrderButton(Character character, string orderAiTag, Color color, Vector2? flashRectInflate = null)
|
||||
{
|
||||
var order = Order.PrefabList.Find(o => o.AITag == orderAiTag);
|
||||
if (order == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not find an order with the AI tag \"" + orderAiTag + "\".\n" + Environment.StackTrace);
|
||||
return;
|
||||
}
|
||||
var characterElement = characterListBox.Content.FindChild(character);
|
||||
GUIButton orderBtn = characterElement.FindChild(order, recursive: true) as GUIButton;
|
||||
if (orderBtn.Frame.FlashTimer <= 0)
|
||||
{
|
||||
orderBtn.Flash(color, 1.5f, false, flashRectInflate);
|
||||
}
|
||||
|
||||
//orderBtn.Pulsate(Vector2.One, Vector2.One * 2.0f, 1.5f);
|
||||
}
|
||||
|
||||
#region Updating and drawing the UI
|
||||
|
||||
private void DrawMiniMapOverlay(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
@@ -1092,6 +1190,7 @@ namespace Barotrauma
|
||||
|
||||
public void SelectNextCharacter()
|
||||
{
|
||||
if (!AllowCharacterSwitch) { return; }
|
||||
if (GameMain.IsMultiplayer) { return; }
|
||||
if (characters.None()) { return; }
|
||||
SelectCharacter(characters[TryAdjustIndex(1)]);
|
||||
@@ -1099,6 +1198,7 @@ namespace Barotrauma
|
||||
|
||||
public void SelectPreviousCharacter()
|
||||
{
|
||||
if (!AllowCharacterSwitch) { return; }
|
||||
if (GameMain.IsMultiplayer) { return; }
|
||||
if (characters.None()) { return; }
|
||||
SelectCharacter(characters[TryAdjustIndex(-1)]);
|
||||
@@ -1106,6 +1206,7 @@ namespace Barotrauma
|
||||
|
||||
private void SelectCharacter(Character character)
|
||||
{
|
||||
if (!AllowCharacterSwitch) { return; }
|
||||
//make the previously selected character wait in place for some time
|
||||
//(so they don't immediately start idling and walking away from their station)
|
||||
if (Character.Controlled?.AIController?.ObjectiveManager != null)
|
||||
|
||||
Reference in New Issue
Block a user