(02bbfb6a3) Let the ai objectives handle waiting (after switching characters). Currently only idle objective uses wait timer, others ignore it. Reduce the wait time from 20 to 10 secs.

This commit is contained in:
Joonas Rikkonen
2019-04-08 15:59:36 +03:00
parent eaf8b1275d
commit 28f2c00255
3 changed files with 33 additions and 12 deletions

View File

@@ -17,10 +17,9 @@ namespace Barotrauma
const float ChatMessageFadeTime = 10.0f;
/// <summary>
/// How long the previously selected character waits doing nothing when switching to another character
/// How long the previously selected character waits doing nothing when switching to another character. Only affects idling.
/// </summary>
const float CharacterWaitOnSwitch = 20.0f;
const float CharacterWaitOnSwitch = 10.0f;
private List<CharacterInfo> characterInfos = new List<CharacterInfo>();
private List<Character> characters = new List<Character>();
@@ -272,6 +271,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Tried to add the same character info to CrewManager twice.\n" + Environment.StackTrace);
return;
}
}
characterInfos.Add(characterInfo);
}
@@ -599,7 +599,20 @@ namespace Barotrauma
characterListBox.BarScroll = roundedPos;
}
return false;
#region Dialog
/// <summary>
/// Adds the message to the single player chatbox.
/// </summary>
public void AddSinglePlayerChatMessage(string senderName, string text, ChatMessageType messageType, Character sender)
{
if (!isSinglePlayer)
{
DebugConsole.ThrowError("Cannot add messages to single player chat box in multiplayer mode!\n" + Environment.StackTrace);
return;
}
if (string.IsNullOrEmpty(text)) { return; }
chatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender));
}
private IEnumerable<object> KillCharacterAnim(GUIComponent component)
@@ -612,6 +625,12 @@ namespace Barotrauma
{
comp.Color = Color.DarkRed;
}
List<Character> availableSpeakers = Character.CharacterList.FindAll(c =>
c.AIController is HumanAIController &&
!c.IsDead &&
c.SpeechImpediment <= 100.0f);
pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers));
}
yield return new WaitForSeconds(1.0f);

View File

@@ -54,10 +54,17 @@ namespace Barotrauma
character.SelectedConstruction = null;
}
bool currentHullForbidden = IsForbidden(character.CurrentHull);
if (!currentHullForbidden && !character.AnimController.InWater && !character.IsClimbing && HumanAIController.ObjectiveManager.WaitTimer > 0)
{
SteeringManager.Reset();
return;
}
bool currentTargetIsInvalid = currentTarget == null || IsForbidden(currentTarget) ||
(PathSteering.CurrentPath != null && PathSteering.CurrentPath.Nodes.Any(n => HumanAIController.UnsafeHulls.Contains(n.CurrentHull)));
if (currentTargetIsInvalid || (currentTarget == null && IsForbidden(character.CurrentHull)))
if (currentTargetIsInvalid || (currentTarget == null && currentHullForbidden))
{
newTargetTimer = 0;
standStillTimer = 0;

View File

@@ -18,7 +18,7 @@ namespace Barotrauma
private Character character;
/// <summary>
/// When set above zero, the character will stand still doing nothing until the timer runs out (assuming they don't a high priority order active)
/// When set above zero, the character will stand still doing nothing until the timer runs out. Only affects idling.
/// </summary>
public float WaitTimer;
@@ -134,12 +134,7 @@ namespace Barotrauma
public void DoCurrentObjective(float deltaTime)
{
if (CurrentObjective == null || (CurrentObjective.GetPriority(this) < OrderPriority && WaitTimer > 0.0f))
{
WaitTimer -= deltaTime;
character.AIController.SteeringManager.Reset();
return;
}
if (WaitTimer > 0.0f) { WaitTimer -= deltaTime; }
CurrentObjective?.TryComplete(deltaTime);
}