(c7ebe3cdb) Fixed: Old TextManager.Get call

This commit is contained in:
Joonas Rikkonen
2019-03-27 20:45:30 +02:00
parent 3f82c9a2cb
commit ff4ecd15b3
11 changed files with 67 additions and 130 deletions
@@ -220,5 +220,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\MathUtils.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Utils\MathUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\TextureLoader.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Utils\TextureLoader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Utils\ToolBox.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Source\Utils\ToolBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\GUI\VideoPlayer.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -567,45 +567,6 @@ namespace Barotrauma
} }
}, isCheat: true)); }, isCheat: true));
commands.Add(new Command("alpha", "Change the alpha (as bytes from 0 to 255) of the selected item/structure instances. Applied only in the subeditor.", (string[] args) =>
{
if (Screen.Selected == GameMain.SubEditorScreen)
{
if (!MapEntity.SelectedAny)
{
ThrowError("You have to select item(s)/structure(s) first!");
}
else
{
if (args.Length > 0)
{
if (!byte.TryParse(args[0], out byte a))
{
ThrowError($"Failed to parse value for ALPHA from {args[0]}");
}
else
{
foreach (var mapEntity in MapEntity.SelectedList)
{
if (mapEntity is Structure s)
{
s.SpriteColor = new Color(s.SpriteColor.R, s.SpriteColor.G, s.SpriteColor.G, a);
}
else if (mapEntity is Item i)
{
i.SpriteColor = new Color(i.SpriteColor.R, i.SpriteColor.G, i.SpriteColor.G, a);
}
}
}
}
else
{
ThrowError("Not enough arguments provided! One required!");
}
}
}
}, isCheat: true));
commands.Add(new Command("tutorial", "", (string[] args) => commands.Add(new Command("tutorial", "", (string[] args) =>
{ {
TutorialMode.StartTutorial(Tutorials.Tutorial.Tutorials[0]); TutorialMode.StartTutorial(Tutorials.Tutorial.Tutorials[0]);
@@ -974,6 +935,30 @@ namespace Barotrauma
} }
} }
} }
XNode nextNode = destinationElement.NextNode;
while ((!(nextNode is XElement) || nextNode == element) && nextNode != null) nextNode = nextNode.NextNode;
destinationElement = nextNode as XElement;
}
destinationDoc.Save(destinationPath);
},
() =>
{
var files = TextManager.GetTextFiles().Where(f => Path.GetExtension(f) == ".xml").Select(f => f.Replace("\\", "/")).ToArray();
return new string[][]
{
files,
files
};
}));
commands.Add(new Command("dumpentitytexts", "dumpentitytexts [filepath]: gets the names and descriptions of all entity prefabs and writes them into a file along with xml tags that can be used in translation files. If the filepath is omitted, the file is written to Content/Texts/EntityTexts.txt", (string[] args) =>
{
string filePath = args.Length > 0 ? args[0] : "Content/Texts/EntityTexts.txt";
List<string> lines = new List<string>();
foreach (MapEntityPrefab me in MapEntityPrefab.List)
{
lines.Add("<EntityName." + me.Identifier + ">" + me.Name + "</" + me.Identifier + ".Name>");
lines.Add("<EntityDescription." + me.Identifier + ">" + me.Description + "</" + me.Identifier + ".Description>");
} }
}, isCheat: false)); }, isCheat: false));
#endif #endif
@@ -481,7 +481,7 @@ namespace Barotrauma.Tutorials
} }
break; break;
case ContentTypes.Text: case ContentTypes.Text:
infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Name), TextManager.Get(activeSegment.Content.GetAttributeString("tag", ""), false, args), infoBox = CreateInfoFrame(TextManager.Get(activeSegment.Name), TextManager.GetFormatted(activeSegment.Content.GetAttributeString("tag", ""), false, args),
activeSegment.Content.GetAttributeInt("width", 300), activeSegment.Content.GetAttributeInt("width", 300),
activeSegment.Content.GetAttributeInt("height", 80), activeSegment.Content.GetAttributeInt("height", 80),
activeSegment.Content.GetAttributeString("anchor", "Center"), true, CurrentSegmentStopCallback); activeSegment.Content.GetAttributeString("anchor", "Center"), true, CurrentSegmentStopCallback);
@@ -865,40 +865,14 @@ namespace Barotrauma.Networking
CoroutineManager.StopCoroutines("WaitInServerQueue"); CoroutineManager.StopCoroutines("WaitInServerQueue");
} }
else else
{
//disconnected/denied for some other reason than the server being full
// -> stop queuing and show a message box
waitInServerQueueBox?.Close();
waitInServerQueueBox = null;
CoroutineManager.StopCoroutines("WaitInServerQueue");
}
if (allowReconnect && disconnectReason == DisconnectReason.Unknown)
{
DebugConsole.NewMessage("Attempting to reconnect...");
string msg = TextManager.GetServerMessage(disconnectMsg);
msg = string.IsNullOrWhiteSpace(msg) ?
TextManager.Get("ConnectionLostReconnecting") :
msg + '\n' + TextManager.Get("ConnectionLostReconnecting");
reconnectBox = new GUIMessageBox(
TextManager.Get("ConnectionLost"),
msg, new string[0]);
connected = false;
ConnectToServer(serverIP);
}
else
{ {
string msg = ""; string msg = "";
if (disconnectReason == DisconnectReason.Unknown) if (disconnectReason == DisconnectReason.Unknown)
{ {
DebugConsole.NewMessage("Do not attempt reconnect (not allowed).");
msg = disconnectMsg; msg = disconnectMsg;
} }
else else
{ {
DebugConsole.NewMessage("Do not attempt to reconnect (DisconnectReason doesn't allow reconnection).");
msg = TextManager.Get("DisconnectReason." + disconnectReason.ToString()); msg = TextManager.Get("DisconnectReason." + disconnectReason.ToString());
if (allowReconnect && disconnectReason == DisconnectReason.Unknown) if (allowReconnect && disconnectReason == DisconnectReason.Unknown)
@@ -1394,6 +1368,9 @@ namespace Barotrauma.Networking
case ServerNetObject.CLIENT_LIST: case ServerNetObject.CLIENT_LIST:
ReadClientList(inc); ReadClientList(inc);
break; break;
case ServerNetObject.CLIENT_LIST:
ReadClientList(inc);
break;
case ServerNetObject.CHAT_MESSAGE: case ServerNetObject.CHAT_MESSAGE:
ChatMessage.ClientRead(inc); ChatMessage.ClientRead(inc);
break; break;
@@ -365,12 +365,6 @@ namespace Barotrauma.Networking
msg.Write((byte)ServerNetObject.ENTITY_EVENT); msg.Write((byte)ServerNetObject.ENTITY_EVENT);
Write(msg, eventsToSync, out sentEvents, client); Write(msg, eventsToSync, out sentEvents, client);
} }
foreach (NetEntityEvent entityEvent in sentEvents)
{
(entityEvent as ServerEntityEvent).Sent = true;
client.EntityEventLastSent[entityEvent.ID] = NetTime.Now;
}
sentEvents = eventsToSync; sentEvents = eventsToSync;
} }
@@ -475,18 +475,6 @@ namespace Barotrauma
} }
attackSimPos = ConvertUnits.ToSimUnits(attackWorldPos); attackSimPos = ConvertUnits.ToSimUnits(attackWorldPos);
} }
else
{
// Take the sub position into account in the sim pos
if (Character.Submarine == null && SelectedAiTarget.Entity.Submarine != null)
{
attackSimPos += SelectedAiTarget.Entity.Submarine.SimPosition;
}
else if (Character.Submarine != null && SelectedAiTarget.Entity.Submarine == null)
{
attackSimPos -= Character.Submarine.SimPosition;
}
}
if (raycastTimer > 0.0) if (raycastTimer > 0.0)
{ {
@@ -546,9 +534,7 @@ namespace Barotrauma
} }
} }
} }
else
bool canAttack = true;
if (IsCoolDownRunning)
{ {
UpdateWallTarget(); UpdateWallTarget();
raycastTimer = RaycastInterval; raycastTimer = RaycastInterval;
@@ -1032,46 +1018,15 @@ namespace Barotrauma
{ {
targetingTag = targetCharacter.SpeciesName.ToLowerInvariant(); targetingTag = targetCharacter.SpeciesName.ToLowerInvariant();
} }
else if (targetCharacter.Submarine != null && Character.Submarine == null)
{
//target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms
targetingTag = "room";
}
else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant())) else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant()))
{
targetingTag = targetCharacter.SpeciesName.ToLowerInvariant();
}
}
else if (target.Entity != null)
{
//skip the target if it's a room and the character is already inside a sub
if (character.CurrentHull != null && target.Entity is Hull) continue;
Door door = null;
if (target.Entity is Item item)
{ {
if (targetCharacter.AIController is EnemyAIController enemy) if (targetCharacter.AIController is EnemyAIController enemy)
{ {
targetingTag = "room"; if (enemy.combatStrength > combatStrength)
}
door = item.GetComponent<Door>();
foreach (TargetingPriority prio in targetingPriorities.Values)
{
if (item.HasTag(prio.TargetTag))
{ {
targetingTag = "stronger"; targetingTag = "stronger";
} }
} else if (enemy.combatStrength < combatStrength)
}
else if (target.Entity is Structure s)
{
targetingTag = "wall";
if (aggressiveBoarding)
{
// Ignore walls when inside.
valueModifier = character.CurrentHull == null ? 2 : 0;
if (valueModifier > 0)
{ {
targetingTag = "weaker"; targetingTag = "weaker";
} }
@@ -1203,14 +1158,6 @@ namespace Barotrauma
#endregion #endregion
protected override void OnStateChanged(AIState from, AIState to)
{
latchOntoAI?.DeattachFromBody();
Character.AnimController.ReleaseStuckLimbs();
escapePoint = Vector2.Zero;
wallTarget = null;
}
if (toBeRemoved != null) if (toBeRemoved != null)
{ {
foreach (AITarget target in toBeRemoved) foreach (AITarget target in toBeRemoved)
@@ -1232,6 +1179,19 @@ namespace Barotrauma
return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize); return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize);
} }
#endregion
protected override void OnStateChanged(AIState from, AIState to)
{
latchOntoAI?.DeattachFromBody();
Character.AnimController.ReleaseStuckLimbs();
}
private int GetMinimumPassableHoleCount()
{
return (int)Math.Ceiling(ConvertUnits.ToDisplayUnits(colliderSize) / Structure.WallSectionSize);
}
private bool CanPassThroughHole(Structure wall, int sectionIndex) private bool CanPassThroughHole(Structure wall, int sectionIndex)
{ {
int requiredHoleCount = GetMinimumPassableHoleCount(); int requiredHoleCount = GetMinimumPassableHoleCount();
@@ -408,7 +408,7 @@ namespace Barotrauma
} }
} }
} }
else if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) while (MainLimb.Rotation - (movementAngle + mainLimbAngle) < -MathHelper.Pi)
{ {
movementAngle = Dir > 0 ? -MathHelper.PiOver2 : MathHelper.PiOver2; movementAngle = Dir > 0 ? -MathHelper.PiOver2 : MathHelper.PiOver2;
if (MainLimb.type == LimbType.Head && HeadAngle.HasValue) if (MainLimb.type == LimbType.Head && HeadAngle.HasValue)
@@ -1037,6 +1037,8 @@ namespace Barotrauma
CheckValidity(); CheckValidity();
CheckValidity();
UpdateNetPlayerPosition(deltaTime); UpdateNetPlayerPosition(deltaTime);
CheckDistFromCollider(); CheckDistFromCollider();
UpdateCollisionCategories(); UpdateCollisionCategories();
@@ -1348,7 +1350,7 @@ namespace Barotrauma
SetInitialLimbPositions(); SetInitialLimbPositions();
return; return;
} }
return true; UpdateProjSpecific(deltaTime);
} }
partial void UpdateProjSpecific(float deltaTime); partial void UpdateProjSpecific(float deltaTime);
@@ -179,6 +179,9 @@ namespace Barotrauma.Items.Components
newConnection.Item.Position - refSub.HiddenSubPosition; newConnection.Item.Position - refSub.HiddenSubPosition;
if (nodes.Count > 0 && nodes[0] == nodePos) break;
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break;
if (nodes.Count > 0 && nodes[0] == nodePos) break; if (nodes.Count > 0 && nodes[0] == nodePos) break;
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break; if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) break;
@@ -186,6 +186,9 @@ namespace Barotrauma
Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false); Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false);
bool underWater = hull == null || explosionPos.Y < hull.Surface; bool underWater = hull == null || explosionPos.Y < hull.Surface;
Hull hull = Hull.FindHull(ConvertUnits.ToDisplayUnits(explosionPos), null, false);
bool underWater = hull == null || explosionPos.Y < hull.Surface;
explosionPos = ConvertUnits.ToSimUnits(explosionPos); explosionPos = ConvertUnits.ToSimUnits(explosionPos);
Dictionary<Limb, float> distFactors = new Dictionary<Limb, float>(); Dictionary<Limb, float> distFactors = new Dictionary<Limb, float>();
@@ -48,6 +48,18 @@ namespace Barotrauma
private set; private set;
} }
public Vector2 LinearVelocity
{
get;
private set;
}
public float AngularVelocity
{
get;
private set;
}
public readonly float Timestamp; public readonly float Timestamp;
public readonly UInt16 ID; public readonly UInt16 ID;