(f6c34b377) Fix crawlers not reacting to any targets if properly latched on walls.

This commit is contained in:
Joonas Rikkonen
2019-04-11 18:26:42 +03:00
parent 9b0e0ab278
commit a57b7184fb
9 changed files with 41 additions and 41 deletions

View File

@@ -33,7 +33,7 @@ namespace Barotrauma
set
{
if (_toggleOpen == value) { return; }
_toggleOpen = GameMain.Config.ChatOpen = value;
_toggleOpen = value;
foreach (GUIComponent child in ToggleButton.Children)
{
child.SpriteEffects = _toggleOpen == (HUDLayoutSettings.ChatBoxAlignment == Alignment.Right) ?
@@ -133,8 +133,6 @@ namespace Barotrauma
}
return true;
};
ToggleOpen = GameMain.Config.ChatOpen;
}
public bool TypingChatMessage(GUITextBox textBox, string text)
@@ -324,6 +322,8 @@ namespace Barotrauma
prevUIScale = GUI.Scale;
}
if (ToggleOpen || (inputBox != null && inputBox.Selected))
{
openState += deltaTime * 5.0f;

View File

@@ -56,7 +56,7 @@ namespace Barotrauma
set
{
if (toggleCrewAreaOpen == value) { return; }
toggleCrewAreaOpen = GameMain.Config.CrewMenuOpen = value;
toggleCrewAreaOpen = value;
foreach (GUIComponent child in toggleCrewButton.Children)
{
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
@@ -215,8 +215,6 @@ namespace Barotrauma
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
prevUIScale = GUI.Scale;
ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen;
}

View File

@@ -1114,9 +1114,7 @@ namespace Barotrauma.Networking
if (campaign == null)
{
GameMain.GameSession = missionIndex < 0 ?
new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, MissionType.None) :
new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, MissionPrefab.List[missionIndex]);
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, missionIndex < 0 ? null : MissionPrefab.List[missionIndex]);
GameMain.GameSession.StartRound(levelSeed, levelDifficulty, loadSecondSub);
}
else

View File

@@ -1754,10 +1754,11 @@ namespace Barotrauma.Networking
Log("Game mode: " + selectedMode.Name, ServerLog.MessageType.ServerMessage);
Log("Submarine: " + selectedSub.Name, ServerLog.MessageType.ServerMessage);
Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, ServerLog.MessageType.ServerMessage);
}
}
MissionMode missionMode = GameMain.GameSession.GameMode as MissionMode;
bool missionAllowRespawn = campaign == null && (missionMode?.Mission == null || missionMode.Mission.AllowRespawn);
bool missionAllowRespawn = campaign == null &&
(!(GameMain.GameSession.GameMode is MissionMode) ||
((MissionMode)GameMain.GameSession.GameMode).Mission.AllowRespawn);
if (serverSettings.AllowRespawn && missionAllowRespawn) respawnManager = new RespawnManager(this, usingShuttle ? selectedShuttle : null);
@@ -1940,8 +1941,10 @@ namespace Barotrauma.Networking
MultiPlayerCampaign campaign = GameMain.GameSession?.GameMode as MultiPlayerCampaign;
MissionMode missionMode = GameMain.GameSession.GameMode as MissionMode;
bool missionAllowRespawn = campaign == null && (missionMode?.Mission == null || missionMode.Mission.AllowRespawn);
bool missionAllowRespawn = campaign == null &&
(!(GameMain.GameSession.GameMode is MissionMode) ||
((MissionMode)GameMain.GameSession.GameMode).Mission.AllowRespawn);
msg.Write(serverSettings.AllowRespawn && missionAllowRespawn);
msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub

View File

@@ -487,7 +487,7 @@ namespace Barotrauma
}
else
{
if (!IsProperlyLatched)
if (!IsProperlyLatchedOnSub)
{
UpdateWallTarget();
}
@@ -1003,11 +1003,12 @@ namespace Barotrauma
private void UpdateEating(float deltaTime)
{
if (SelectedAiTarget == null)
if (SelectedAiTarget == null) //SelectedAiTarget.Entity is Character c && !c.IsDead
{
State = AIState.Idle;
return;
}
Character targetChar = SelectedAiTarget.Entity as Character;
Limb mouthLimb = Array.Find(Character.AnimController.Limbs, l => l != null && l.MouthPos.HasValue);
if (mouthLimb == null) mouthLimb = Character.AnimController.GetLimb(LimbType.Head);
@@ -1039,14 +1040,14 @@ namespace Barotrauma
#region Targeting
private bool IsProperlyLatched => LatchOntoAI != null && LatchOntoAI.IsAttached && 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,
//whether the Character can see/hear the target and chooses the most preferable target within
//sight/hearing range
public AITarget UpdateTargets(Character character, out TargetingPriority priority)
{
if (IsProperlyLatched)
if (IsProperlyLatchedOnSub)
{
// If attached to a valid target, just keep the target.
// Priority not used in this case.

View File

@@ -54,6 +54,8 @@ namespace Barotrauma
get { return attachJoints.Count > 0; }
}
public bool IsAttachedToSub => IsAttached && attachTargetBody?.UserData is Entity entity && (entity is Submarine sub || entity?.Submarine != null);
public LatchOntoAI(XElement element, EnemyAIController enemyAI)
{
attachToWalls = element.GetAttributeBool("attachtowalls", false);
@@ -207,10 +209,10 @@ namespace Barotrauma
break;
}
if (attachTargetBody != null && deattachTimer < 0.0f)
if (IsAttached && attachTargetBody != null && deattachTimer < 0.0f)
{
Entity entity = attachTargetBody.UserData as Entity;
Submarine attachedSub = entity is Submarine ? (Submarine)entity : entity?.Submarine;
Submarine attachedSub = entity is Submarine sub ? sub : entity?.Submarine;
if (attachedSub != null)
{
float velocity = attachedSub.Velocity == Vector2.Zero ? 0.0f : attachedSub.Velocity.Length();

View File

@@ -209,6 +209,7 @@ namespace Barotrauma
//isActive = false;
bool spawnReady = false;
if (spawnPending)
{
//wait until there are no submarines at the spawnpos
@@ -219,25 +220,31 @@ namespace Barotrauma
if (Vector2.DistanceSquared(submarine.WorldPosition, spawnPos) < minDist * minDist) return;
}
spawnPending = false;
//+1 because Range returns an integer less than the max value
int amount = Rand.Range(minAmount, maxAmount + 1, Rand.RandSync.Server);
monsters = new Character[amount];
monsters = new List<Character>();
float offsetAmount = spawnPosType == Level.PositionType.MainPath ? 1000 : 100;
for (int i = 0; i < amount; i++)
{
bool isClient = false;
{
CoroutineManager.InvokeAfter(() =>
{
bool isClient = false;
#if CLIENT
isClient = GameMain.Client != null;
isClient = GameMain.Client != null;
#endif
monsters[i] = Character.Create(
characterFile, spawnPos + Rand.Vector(100.0f, Rand.RandSync.Server),
i.ToString(), null, isClient, true, true);
monsters.Add(Character.Create(characterFile, spawnPos + Rand.Vector(offsetAmount, Rand.RandSync.Server), i.ToString(), null, isClient, true, true));
if (monsters.Count == amount)
{
spawnReady = true;
}
}, Rand.Range(0f, amount / 2, Rand.RandSync.Server));
}
spawnPending = false;
}
if (!spawnReady) { return; }
Entity targetEntity = Submarine.FindClosest(GameMain.GameScreen.Cam.WorldViewCenter);
#if CLIENT
if (Character.Controlled != null) targetEntity = (Entity)Character.Controlled;

View File

@@ -150,9 +150,6 @@ namespace Barotrauma
public bool EnableMouseLook { get; set; } = true;
public bool CrewMenuOpen { get; set; } = true;
public bool ChatOpen { get; set; } = true;
private bool unsavedSettings;
public bool UnsavedSettings
{
@@ -850,9 +847,6 @@ namespace Barotrauma
AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", AimAssistAmount);
EnableMouseLook = doc.Root.GetAttributeBool("enablemouselook", EnableMouseLook);
CrewMenuOpen = doc.Root.GetAttributeBool("crewmenuopen", CrewMenuOpen);
ChatOpen = doc.Root.GetAttributeBool("chatopen", ChatOpen);
foreach (XElement subElement in doc.Root.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -1028,9 +1022,7 @@ namespace Barotrauma
new XAttribute("requiresteamauthentication", requireSteamAuthentication),
new XAttribute("autoupdateworkshopitems", AutoUpdateWorkshopItems),
new XAttribute("aimassistamount", aimAssistAmount),
new XAttribute("enablemouselook", EnableMouseLook),
new XAttribute("chatopen", ChatOpen),
new XAttribute("crewmenuopen", CrewMenuOpen));
new XAttribute("enablemouselook", EnableMouseLook));
if (!ShowUserStatisticsPrompt)
{

View File

@@ -44,7 +44,6 @@ namespace Barotrauma
base.Deselect();
#if CLIENT
GameMain.Config.SaveNewPlayerConfig();
GameMain.SoundManager.SetCategoryMuffle("default", false);
GUI.ClearMessages();
#endif