Husk improvements, option for admin to talk to dead players, spectators or one specific player, entitygrid bugfix

This commit is contained in:
Regalis
2016-02-14 22:22:24 +02:00
parent 94e34c0ed9
commit ef78f2d0f6
12 changed files with 81 additions and 32 deletions
@@ -107,6 +107,14 @@ namespace Barotrauma
Character.AnimController.IgnorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
if (Character.AnimController is HumanoidAnimController)
{
if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
{
Character.AnimController.TargetDir = Character.AnimController.TargetMovement.X > 0.0f ? Direction.Right : Direction.Left;
}
}
if (updateTargetsTimer > 0.0)
{
updateTargetsTimer -= deltaTime;
@@ -43,6 +43,9 @@ namespace Barotrauma
stepSize = ToolBox.GetAttributeVector2(element, "stepsize", Vector2.One);
stepSize = ConvertUnits.ToSimUnits(stepSize);
walkSpeed = ToolBox.GetAttributeFloat(element, "walkspeed", 1.0f);
swimSpeed = ToolBox.GetAttributeFloat(element, "swimspeed", 1.0f);
//stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.One);
//stepOffset = ConvertUnits.ToSimUnits(stepOffset);
@@ -31,9 +31,6 @@ namespace Barotrauma
flip = ToolBox.GetAttributeBool(element, "flip", false);
walkSpeed = ToolBox.GetAttributeFloat(element, "walkspeed", 1.0f);
swimSpeed = ToolBox.GetAttributeFloat(element, "swimspeed", 1.0f);
float footRot = ToolBox.GetAttributeFloat(element,"footrotation", float.NaN);
if (float.IsNaN(footRot))
{
@@ -241,7 +241,7 @@ namespace Barotrauma
float footMid = waist.SimPosition.X;// (leftFoot.SimPosition.X + rightFoot.SimPosition.X) / 2.0f;
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
movement = MathUtils.SmoothStep(movement, TargetMovement*walkSpeed, movementLerp);
movement.Y = 0.0f;
for (int i = 0; i < 2; i++)
@@ -502,7 +502,7 @@ namespace Barotrauma
if (TargetMovement == Vector2.Zero) return;
movement = MathUtils.SmoothStep(movement, TargetMovement, 0.3f);
movement = MathUtils.SmoothStep(movement, TargetMovement*swimSpeed, 0.3f);
//dont try to move upwards if head is already out of water
if (surfaceLimiter > 1.0f && TargetMovement.Y > 0.0f)
+16 -9
View File
@@ -391,7 +391,10 @@ namespace Barotrauma
Properties = ObjectProperty.GetProperties(this);
Info = characterInfo==null ? new CharacterInfo(file) : characterInfo;
if (file == humanConfigFile)
{
Info = characterInfo == null ? new CharacterInfo(file) : characterInfo;
}
XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null || doc.Root == null) return;
@@ -453,22 +456,26 @@ namespace Barotrauma
}
}
if (Info.PickedItemIDs.Any())
if (file == humanConfigFile)
{
for (ushort i = 0; i < Info.PickedItemIDs.Count; i++ )
if (Info.PickedItemIDs.Any())
{
if (Info.PickedItemIDs[i] == 0) continue;
for (ushort i = 0; i < Info.PickedItemIDs.Count; i++ )
{
if (Info.PickedItemIDs[i] == 0) continue;
Item item = FindEntityByID(Info.PickedItemIDs[i]) as Item;
Item item = FindEntityByID(Info.PickedItemIDs[i]) as Item;
System.Diagnostics.Debug.Assert(item != null);
if (item == null) continue;
System.Diagnostics.Debug.Assert(item != null);
if (item == null) continue;
item.Pick(this, true, true, true);
inventory.TryPutItem(item, i, false);
item.Pick(this, true, true, true);
inventory.TryPutItem(item, i, false);
}
}
}
AnimController.FindHull(null);
if (AnimController.CurrentHull != null) Submarine = AnimController.CurrentHull.Submarine;
@@ -132,6 +132,8 @@ namespace Barotrauma
return;
}
name = "";
if (doc.Root.Element("name") != null)
{
string firstNamePath = ToolBox.GetAttributeString(doc.Root.Element("name"), "firstname", "");
+5 -4
View File
@@ -32,16 +32,17 @@ namespace Barotrauma
Rectangle rect = entity.Rect;
//if (Submarine.Loaded != null) rect.Offset(-Submarine.HiddenSubPosition);
Rectangle indices = GetIndices(rect);
if (indices.X < 0 || indices.Width >= entities.GetLength(0) ||
indices.Y < 0 || indices.Height >= entities.GetLength(1))
if (indices.Width < 0 || indices.X >= entities.GetLength(0) ||
indices.Height < 0 || indices.Y >= entities.GetLength(1))
{
DebugConsole.ThrowError("Error in EntityGrid.InsertEntity: " + entity + " is outside the grid");
return;
}
for (int x = indices.X; x <= indices.Width; x++)
for (int x = Math.Max(indices.X, 0); x <= Math.Min(indices.Width, entities.GetLength(0)); x++)
{
for (int y = indices.Y; y <= indices.Height; y++)
for (int y = Math.Max(indices.Y,0); y <= Math.Min(indices.Height, entities.GetLength(1)); y++)
{
entities[x, y].Add(entity);
}
+34 -5
View File
@@ -882,6 +882,9 @@ namespace Barotrauma.Networking
GameMain.GameScreen.Select();
AddChatMessage("Press TAB to chat. Use ''/d'' to talk to dead players and spectators, and ''/playername'' to only send the message to a specific player.", ChatMessageType.Server);
yield return CoroutineStatus.Success;
}
@@ -1267,17 +1270,43 @@ namespace Barotrauma.Networking
public override void SendChatMessage(string message, ChatMessageType type = ChatMessageType.Server)
{
AddChatMessage(message, type);
if (server.Connections.Count == 0) return;
string[] words = message.Split(' ');
List<Client> recipients = new List<Client>();
Client targetClient = null;
foreach (Client c in ConnectedClients)
if (words.Length > 2)
{
if (type!=ChatMessageType.Dead || (c.Character != null && c.Character.IsDead)) recipients.Add(c);
if (words[1] == "/dead" || words[1] == "/d")
{
type = ChatMessageType.Dead;
}
else
{
targetClient = ConnectedClients.Find(c =>
words[0] == "/" + c.name.ToLower() ||
c.Character != null && words[0] == "/" + c.Character.Name.ToLower());
}
message = words[0] + " " + string.Join(" ", words, 2, words.Length - 2);
}
if (targetClient != null)
{
recipients.Add(targetClient);
}
else
{
foreach (Client c in ConnectedClients)
{
if (type != ChatMessageType.Dead || (c.Character != null && c.Character.IsDead)) recipients.Add(c);
}
}
AddChatMessage(message, type);
if (!server.Connections.Any()) return;
foreach (Client c in recipients)
{
ReliableMessage msg = c.ReliableChannel.CreateMessage();
+1 -1
View File
@@ -9,7 +9,7 @@ namespace Barotrauma.Networking
{
class ServerLog
{
const int LinesPerFile = 500;
const int LinesPerFile = 300;
const string SavePath = "ServerLogs";