Sending NetTime at the start of a combined networkevent instead of individual networkevents, syncing itemcomponents for spectators, AICharacter importantentityupdates are sent again, misc bugfixes, some new heads
This commit is contained in:
@@ -319,6 +319,12 @@
|
|||||||
<Content Include="Content\Characters\Human\fhead4.png">
|
<Content Include="Content\Characters\Human\fhead4.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\fhead5.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\fhead6.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\firstnames.txt">
|
<Content Include="Content\Characters\Human\firstnames.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -337,6 +343,12 @@
|
|||||||
<Content Include="Content\Characters\Human\head4.png">
|
<Content Include="Content\Characters\Human\head4.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\head5.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Characters\Human\head6.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Characters\Human\lastnames.txt">
|
<Content Include="Content\Characters\Human\lastnames.txt">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<Character name ="human" humanoid="true" needsair="true" genders="true" maleheadid="1,4" femaleheadid="1,4" drowningtime="30">
|
<Character name ="human" humanoid="true" needsair="true" genders="true" maleheadid="1,6" femaleheadid="1,6" drowningtime="30">
|
||||||
|
|
||||||
<name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" />
|
<name firstname="Content/Characters/Human/[GENDER]firstnames.txt" lastname="Content/Characters/Human/lastnames.txt" />
|
||||||
|
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
case NetworkEventType.EntityUpdate:
|
case NetworkEventType.EntityUpdate:
|
||||||
if (AnimController.RefLimb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
if (AnimController.RefLimb.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) return false;
|
||||||
|
|
||||||
message.Write((float)NetTime.Now);
|
|
||||||
|
|
||||||
message.Write(AnimController.TargetDir == Direction.Right);
|
message.Write(AnimController.TargetDir == Direction.Right);
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
|
||||||
@@ -127,8 +125,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
@@ -182,11 +180,9 @@ namespace Barotrauma
|
|||||||
aiController.ReadNetworkData(message);
|
aiController.ReadNetworkData(message);
|
||||||
return;
|
return;
|
||||||
case NetworkEventType.EntityUpdate:
|
case NetworkEventType.EntityUpdate:
|
||||||
float sendingTime = 0.0f;
|
|
||||||
Vector2 targetMovement = Vector2.Zero;
|
Vector2 targetMovement = Vector2.Zero;
|
||||||
bool targetDir = false;
|
bool targetDir = false;
|
||||||
|
|
||||||
sendingTime = message.ReadFloat();
|
|
||||||
if (sendingTime <= LastNetworkUpdate) return;
|
if (sendingTime <= LastNetworkUpdate) return;
|
||||||
|
|
||||||
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
|
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
|
||||||
|
|||||||
@@ -581,19 +581,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateUpdateNetworkEvent(bool isClient)
|
|
||||||
{
|
|
||||||
//new NetworkEvent(importantUpdateTimer <= 0 ? NetworkEventType.ImportantEntityUpdate : NetworkEventType.EntityUpdate, ID, isClient);
|
|
||||||
|
|
||||||
new NetworkEvent(NetworkEventType.EntityUpdate, ID, isClient);
|
|
||||||
|
|
||||||
|
|
||||||
//importantUpdateTimer -= 1;
|
|
||||||
//if (importantUpdateTimer < 0) importantUpdateTimer = (this is AICharacter) ? 30 : 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool HasSelectedItem(Item item)
|
public bool HasSelectedItem(Item item)
|
||||||
{
|
{
|
||||||
return selectedItems.Contains(item);
|
return selectedItems.Contains(item);
|
||||||
@@ -1035,7 +1023,7 @@ namespace Barotrauma
|
|||||||
health -= attackResult.Damage;
|
health -= attackResult.Damage;
|
||||||
if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn);
|
if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn);
|
||||||
|
|
||||||
bleeding += attackResult.Bleeding;
|
Bleeding += attackResult.Bleeding;
|
||||||
|
|
||||||
return attackResult;
|
return attackResult;
|
||||||
}
|
}
|
||||||
@@ -1274,9 +1262,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
case NetworkEventType.EntityUpdate:
|
case NetworkEventType.EntityUpdate:
|
||||||
|
|
||||||
message.Write((float)NetTime.Now);
|
|
||||||
|
|
||||||
message.Write(keys[(int)InputType.Use].DequeueHeld);
|
message.Write(keys[(int)InputType.Use].DequeueHeld);
|
||||||
|
|
||||||
bool secondaryHeld = keys[(int)InputType.Aim].DequeueHeld;
|
bool secondaryHeld = keys[(int)InputType.Aim].DequeueHeld;
|
||||||
@@ -1321,7 +1306,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
data = null;
|
data = null;
|
||||||
@@ -1362,7 +1347,7 @@ namespace Barotrauma
|
|||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
Client sender =GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
Client sender =GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||||
if (sender ==null || sender.Character != this)
|
if (sender == null || sender.Character != this)
|
||||||
throw new Exception("Received a KillCharacter message from someone else than the client controlling the Character!");
|
throw new Exception("Received a KillCharacter message from someone else than the client controlling the Character!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1390,7 +1375,7 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
case NetworkEventType.InventoryUpdate:
|
case NetworkEventType.InventoryUpdate:
|
||||||
if (inventory == null) return;
|
if (inventory == null) return;
|
||||||
inventory.ReadNetworkData(NetworkEventType.InventoryUpdate, message);
|
inventory.ReadNetworkData(NetworkEventType.InventoryUpdate, message, sendingTime);
|
||||||
return;
|
return;
|
||||||
case NetworkEventType.ImportantEntityUpdate:
|
case NetworkEventType.ImportantEntityUpdate:
|
||||||
|
|
||||||
@@ -1406,8 +1391,7 @@ namespace Barotrauma
|
|||||||
Bleeding = message.ReadRangedSingle(0.0f, 5.0f, 8);
|
Bleeding = message.ReadRangedSingle(0.0f, 5.0f, 8);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case NetworkEventType.EntityUpdate:
|
case NetworkEventType.EntityUpdate:
|
||||||
float sendingTime = 0.0f;
|
|
||||||
Vector2 relativeCursorPos = Vector2.Zero;
|
Vector2 relativeCursorPos = Vector2.Zero;
|
||||||
|
|
||||||
bool actionKeyState, secondaryKeyState;
|
bool actionKeyState, secondaryKeyState;
|
||||||
@@ -1416,8 +1400,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sendingTime = message.ReadFloat();
|
|
||||||
|
|
||||||
if (sendingTime > LastNetworkUpdate) ClearInputs();
|
if (sendingTime > LastNetworkUpdate) ClearInputs();
|
||||||
|
|
||||||
actionKeyState = message.ReadBoolean();
|
actionKeyState = message.ReadBoolean();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Barotrauma
|
|||||||
headSpriteId = value;
|
headSpriteId = value;
|
||||||
Vector2 spriteRange = headSpriteRange[gender == Gender.Male ? 0 : 1];
|
Vector2 spriteRange = headSpriteRange[gender == Gender.Male ? 0 : 1];
|
||||||
|
|
||||||
if (headSpriteId < (int)spriteRange.X) headSpriteId = (int)(spriteRange.Y-1);
|
if (headSpriteId < (int)spriteRange.X) headSpriteId = (int)(spriteRange.Y);
|
||||||
if (headSpriteId > (int)spriteRange.Y) headSpriteId = (int)(spriteRange.X);
|
if (headSpriteId > (int)spriteRange.Y) headSpriteId = (int)(spriteRange.X);
|
||||||
|
|
||||||
if (headSpriteId != oldId) headSprite = null;
|
if (headSpriteId != oldId) headSprite = null;
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
static class DebugConsole
|
static class DebugConsole
|
||||||
{
|
{
|
||||||
public static List<ColoredText> messages = new List<ColoredText>();
|
public static List<ColoredText> Messages = new List<ColoredText>();
|
||||||
|
|
||||||
static bool isOpen;
|
static bool isOpen;
|
||||||
|
|
||||||
|
|
||||||
|
static GUIFrame frame;
|
||||||
|
static GUIListBox listBox;
|
||||||
static GUITextBox textBox;
|
static GUITextBox textBox;
|
||||||
|
|
||||||
//used for keeping track of the message entered when pressing up/down
|
//used for keeping track of the message entered when pressing up/down
|
||||||
@@ -42,9 +45,20 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Init(GameWindow window)
|
public static void Init(GameWindow window)
|
||||||
{
|
{
|
||||||
textBox = new GUITextBox(new Rectangle(30, 480,780, 30), Color.Black, Color.White, Alignment.Left, Alignment.Left);
|
int x = 20, y = 20;
|
||||||
NewMessage("Press F3 to open/close the debug console", Color.Cyan);
|
int width = 800, height = 500;
|
||||||
|
|
||||||
|
frame = new GUIFrame(new Rectangle(x, y, width, height), new Color(0.4f, 0.4f, 0.4f, 0.5f));
|
||||||
|
frame.Color = Color.White * 0.4f;
|
||||||
|
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||||
|
|
||||||
|
listBox = new GUIListBox(new Rectangle(0,0,0, frame.Rect.Height-40), Color.Black*0.8f, null, frame);
|
||||||
|
|
||||||
|
textBox = new GUITextBox(new Rectangle(0,0,0,20), Color.Black*0.6f, Color.White, Alignment.BottomLeft, Alignment.Left, null, frame);
|
||||||
|
NewMessage("Press F3 to open/close the debug console", Color.Cyan);
|
||||||
|
NewMessage("Enter ''help'' for a list of available console commands", Color.Cyan);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Update(GameMain game, float deltaTime)
|
public static void Update(GameMain game, float deltaTime)
|
||||||
@@ -81,18 +95,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (PlayerInput.GetKeyboardState.IsKeyDown(Keys.Enter) && textBox.Text != "")
|
if (PlayerInput.GetKeyboardState.IsKeyDown(Keys.Enter) && textBox.Text != "")
|
||||||
{
|
{
|
||||||
messages.Add(new ColoredText(textBox.Text, Color.White));
|
NewMessage(textBox.Text, Color.White);
|
||||||
ExecuteCommand(textBox.Text, game);
|
ExecuteCommand(textBox.Text, game);
|
||||||
textBox.Text = "";
|
textBox.Text = "";
|
||||||
|
|
||||||
selectedIndex = messages.Count;
|
//selectedIndex = messages.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SelectMessage(int direction)
|
private static void SelectMessage(int direction)
|
||||||
{
|
{
|
||||||
int messageCount = messages.Count;
|
int messageCount = listBox.children.Count;
|
||||||
if (messageCount == 0) return;
|
if (messageCount == 0) return;
|
||||||
|
|
||||||
direction = Math.Min(Math.Max(-1, direction), 1);
|
direction = Math.Min(Math.Max(-1, direction), 1);
|
||||||
@@ -101,42 +115,43 @@ namespace Barotrauma
|
|||||||
if (selectedIndex < 0) selectedIndex = messageCount - 1;
|
if (selectedIndex < 0) selectedIndex = messageCount - 1;
|
||||||
selectedIndex = selectedIndex % messageCount;
|
selectedIndex = selectedIndex % messageCount;
|
||||||
|
|
||||||
textBox.Text = messages[selectedIndex].Text;
|
textBox.Text = (listBox.children[selectedIndex] as GUITextBlock).Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Draw(SpriteBatch spriteBatch)
|
public static void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
if (!isOpen) return;
|
if (!isOpen) return;
|
||||||
|
|
||||||
int x = 20, y = 20;
|
frame.Update(1.0f / 60.0f);
|
||||||
int width = 800, height = 500;
|
|
||||||
|
|
||||||
int margin = 5;
|
int margin = 5;
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
//GUI.DrawRectangle(spriteBatch,
|
||||||
new Vector2(x, y),
|
// new Vector2(x, y),
|
||||||
new Vector2(width, height),
|
// new Vector2(width, height),
|
||||||
new Color(0.4f, 0.4f, 0.4f, 0.6f), true);
|
// new Color(0.4f, 0.4f, 0.4f, 0.6f), true);
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
//GUI.DrawRectangle(spriteBatch,
|
||||||
new Vector2(x + margin, y + margin),
|
// new Vector2(x + margin, y + margin),
|
||||||
new Vector2(width - margin * 2, height - margin * 2),
|
// new Vector2(width - margin * 2, height - margin * 2),
|
||||||
new Color(0.0f, 0.0f, 0.0f, 0.6f), true);
|
// new Color(0.0f, 0.0f, 0.0f, 0.6f), true);
|
||||||
|
|
||||||
//remove messages that won't fit on the screen
|
//remove messages that won't fit on the screen
|
||||||
while (messages.Count() * 20 > height-70)
|
//while (messages.Count() * 20 > height - 70)
|
||||||
{
|
//{
|
||||||
messages.RemoveAt(0);
|
// messages.RemoveAt(0);
|
||||||
}
|
//}
|
||||||
|
|
||||||
Vector2 messagePos = new Vector2(x + margin * 2, y + height - 70 - messages.Count()*20);
|
//Vector2 messagePos = new Vector2(x + margin * 2, y + height - 70 - messages.Count()*20);
|
||||||
foreach (ColoredText message in messages)
|
//foreach (ColoredText message in messages)
|
||||||
{
|
//{
|
||||||
spriteBatch.DrawString(GUI.Font, message.Text, messagePos, message.Color);
|
// spriteBatch.DrawString(GUI.Font, message.Text, messagePos, message.Color);
|
||||||
messagePos.Y += 20;
|
// messagePos.Y += 20;
|
||||||
}
|
//}
|
||||||
|
|
||||||
textBox.Draw(spriteBatch);
|
//textBox.Draw(spriteBatch);
|
||||||
|
|
||||||
|
frame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ExecuteCommand(string command, GameMain game)
|
public static void ExecuteCommand(string command, GameMain game)
|
||||||
@@ -154,6 +169,49 @@ namespace Barotrauma
|
|||||||
|
|
||||||
switch (commands[0].ToLower())
|
switch (commands[0].ToLower())
|
||||||
{
|
{
|
||||||
|
case "help":
|
||||||
|
NewMessage("menu: go to main menu", Color.Cyan);
|
||||||
|
NewMessage("game: enter the ''game screen''", Color.Cyan);
|
||||||
|
NewMessage("edit: switch to submarine editor", Color.Cyan);
|
||||||
|
NewMessage("load [submarine name]: load a submarine!", Color.Cyan);
|
||||||
|
NewMessage("save [submarine name]: save the current submarine using the specified name", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
|
||||||
|
NewMessage("spawn: spawn a creature at a random spawnpoint", Color.Cyan);
|
||||||
|
NewMessage("spawn: spawn a creature at a random spawnpoint", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage("lights: disable lighting", Color.Cyan);
|
||||||
|
NewMessage("los: disable the line of sight effect", Color.Cyan);
|
||||||
|
NewMessage("freecam: detach the camera from the controlled character", Color.Cyan);
|
||||||
|
NewMessage("control [character name]: start controlling the specified character", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage("water: allows adding water into rooms or removing it by holding the left/right mouse buttons", Color.Cyan);
|
||||||
|
NewMessage("fire: allows putting up fires by left clicking", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage("heal: restore the controlled character to full health", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage("fixwalls: fixes all the walls", Color.Cyan);
|
||||||
|
NewMessage("fixitems: fixes every item/device in the sub", Color.Cyan);
|
||||||
|
NewMessage("oxygen: replenishes the oxygen in every room to 100%", Color.Cyan);
|
||||||
|
NewMessage("power [amount]: immediately sets the temperature of the reactor to the specified value", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage(" ", Color.Cyan);
|
||||||
|
|
||||||
|
NewMessage("debugdraw: toggles the ''debug draw mode''", Color.Cyan);
|
||||||
|
NewMessage("netstats: toggles the visibility of the network statistics panel", Color.Cyan);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
case "createfilelist":
|
case "createfilelist":
|
||||||
UpdaterUtil.SaveFileList("filelist.xml");
|
UpdaterUtil.SaveFileList("filelist.xml");
|
||||||
break;
|
break;
|
||||||
@@ -264,10 +322,13 @@ namespace Barotrauma
|
|||||||
Item reactorItem = Item.ItemList.Find(i => i.GetComponent<Reactor>() != null);
|
Item reactorItem = Item.ItemList.Find(i => i.GetComponent<Reactor>() != null);
|
||||||
if (reactorItem == null) return;
|
if (reactorItem == null) return;
|
||||||
|
|
||||||
|
float power = 5000.0f;
|
||||||
|
if (commands.Length>1) float.TryParse(commands[1], out power);
|
||||||
|
|
||||||
var reactor = reactorItem.GetComponent<Reactor>();
|
var reactor = reactorItem.GetComponent<Reactor>();
|
||||||
reactor.ShutDownTemp = 7000.0f;
|
reactor.ShutDownTemp = 7000.0f;
|
||||||
reactor.AutoTemp = true;
|
reactor.AutoTemp = true;
|
||||||
reactor.Temperature = 5000.0f;
|
reactor.Temperature = power;
|
||||||
break;
|
break;
|
||||||
case "shake":
|
case "shake":
|
||||||
GameMain.GameScreen.Cam.Shake = 10.0f;
|
GameMain.GameScreen.Cam.Shake = 10.0f;
|
||||||
@@ -357,9 +418,26 @@ namespace Barotrauma
|
|||||||
public static void NewMessage(string msg, Color color)
|
public static void NewMessage(string msg, Color color)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty((msg))) return;
|
if (String.IsNullOrEmpty((msg))) return;
|
||||||
messages.Add(new ColoredText(msg, color));
|
|
||||||
|
|
||||||
if (textBox != null && textBox.Text == "") selectedIndex = messages.Count;
|
Messages.Add(new ColoredText(msg, color));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 15), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
|
||||||
|
textBlock.CanBeFocused = false;
|
||||||
|
textBlock.TextColor = color;
|
||||||
|
|
||||||
|
listBox.AddChild(textBlock);
|
||||||
|
listBox.BarScroll = 1.0f;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//messages.Add(new ColoredText(msg, color));
|
||||||
|
|
||||||
|
if (textBox != null && textBox.Text == "") selectedIndex = listBox.children.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ThrowError(string error, Exception e = null)
|
public static void ThrowError(string error, Exception e = null)
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Barotrauma
|
|||||||
scrollBarHidden = true;
|
scrollBarHidden = true;
|
||||||
|
|
||||||
scrollBar = new GUIScrollBar(
|
scrollBar = new GUIScrollBar(
|
||||||
new Rectangle(this.rect.X + this.rect.Width-20, this.rect.Y, 20, this.rect.Height), color, 1.0f, style);
|
new Rectangle(this.rect.X + this.rect.Width-20, this.rect.Y, 20, this.rect.Height), color, 1.0f, GUI.Style);
|
||||||
|
|
||||||
frame = new GUIFrame(Rectangle.Empty, style, this);
|
frame = new GUIFrame(Rectangle.Empty, style, this);
|
||||||
if (style != null) style.Apply(frame, this);
|
if (style != null) style.Apply(frame, this);
|
||||||
|
|||||||
@@ -203,8 +203,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2 MeasureText(string text)
|
private Vector2 MeasureText(string text)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(text) || Font==null) return Vector2.Zero;
|
||||||
|
|
||||||
Vector2 size = Vector2.Zero;
|
Vector2 size = Vector2.Zero;
|
||||||
while (size == Vector2.Zero)
|
while (size == Vector2.Zero)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
graphics.SetRenderTarget(null);
|
graphics.SetRenderTarget(null);
|
||||||
|
|
||||||
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
|
if (Hull.renderer != null)
|
||||||
|
{
|
||||||
|
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
|
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
|
||||||
|
|
||||||
|
|||||||
@@ -181,8 +181,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
sw = new Stopwatch();
|
sw = new Stopwatch();
|
||||||
|
|
||||||
|
|
||||||
|
GUIComponent.Init(Window);
|
||||||
|
DebugConsole.Init(Window);
|
||||||
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
LightManager = new Lights.LightManager(GraphicsDevice);
|
LightManager = new Lights.LightManager(GraphicsDevice);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Hull.renderer = new WaterRenderer(GraphicsDevice);
|
Hull.renderer = new WaterRenderer(GraphicsDevice);
|
||||||
TitleScreen.LoadState = 1.0f;
|
TitleScreen.LoadState = 1.0f;
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
@@ -235,10 +242,6 @@ namespace Barotrauma
|
|||||||
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
|
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
GUIComponent.Init(Window);
|
|
||||||
DebugConsole.Init(Window);
|
|
||||||
yield return CoroutineStatus.Running;
|
|
||||||
|
|
||||||
LocationType.Init("Content/Map/locationTypes.xml");
|
LocationType.Init("Content/Map/locationTypes.xml");
|
||||||
MainMenuScreen.Select();
|
MainMenuScreen.Select();
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|||||||
@@ -475,8 +475,10 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
public override void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
|
if (sendingTime < lastUpdate) return;
|
||||||
|
|
||||||
character.ClearInput(InputType.Use);
|
character.ClearInput(InputType.Use);
|
||||||
|
|
||||||
for (int i = 0; i<capacity; i++)
|
for (int i = 0; i<capacity; i++)
|
||||||
@@ -496,6 +498,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastUpdate = sendingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,13 +263,15 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(item.SimPosition.X);
|
message.Write(item.SimPosition.X);
|
||||||
message.Write(item.SimPosition.Y);
|
message.Write(item.SimPosition.Y);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
Vector2 newPos = Vector2.Zero;
|
Vector2 newPos = Vector2.Zero;
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ namespace Barotrauma.Items.Components
|
|||||||
get { return updated; }
|
get { return updated; }
|
||||||
set { updated = value; }
|
set { updated = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool NetworkUpdateSent;
|
||||||
|
|
||||||
public virtual bool IsActive
|
public virtual bool IsActive
|
||||||
{
|
{
|
||||||
@@ -701,11 +703,12 @@ namespace Barotrauma.Items.Components
|
|||||||
return ic;
|
return ic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void FillNetworkData(NetworkEventType type, NetBuffer message)
|
public virtual bool FillNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
float? targetLevel;
|
float? targetLevel;
|
||||||
|
|
||||||
|
float lastUpdate;
|
||||||
|
|
||||||
Hull hull1, hull2;
|
Hull hull1, hull2;
|
||||||
|
|
||||||
[HasDefaultValue(0.0f, true)]
|
[HasDefaultValue(0.0f, true)]
|
||||||
@@ -125,12 +127,12 @@ namespace Barotrauma.Items.Components
|
|||||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "OUT", false))
|
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "OUT", false))
|
||||||
{
|
{
|
||||||
FlowPercentage -= 10.0f;
|
FlowPercentage -= 10.0f;
|
||||||
item.NewComponentEvent(this, true, false);
|
item.NewComponentEvent(this, true, true);
|
||||||
}
|
}
|
||||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "IN", false))
|
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "IN", false))
|
||||||
{
|
{
|
||||||
FlowPercentage += 10.0f;
|
FlowPercentage += 10.0f;
|
||||||
item.NewComponentEvent(this, true, false);
|
item.NewComponentEvent(this, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,18 +168,22 @@ namespace Barotrauma.Items.Components
|
|||||||
if (!IsActive) currPowerConsumption = 0.0f;
|
if (!IsActive) currPowerConsumption = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f));
|
message.WriteRangedInteger(-10,10,(int)(flowPercentage/10.0f));
|
||||||
message.Write(IsActive);
|
message.Write(IsActive);
|
||||||
message.WritePadBits();
|
message.WritePadBits();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
float newFlow = 0.0f;
|
float newFlow = 0.0f;
|
||||||
bool newActive;
|
bool newActive;
|
||||||
|
|
||||||
|
if (sendingTime < lastUpdate) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newFlow = message.ReadRangedInteger(-10,10)*10.0f;
|
newFlow = message.ReadRangedInteger(-10,10)*10.0f;
|
||||||
@@ -194,6 +200,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
FlowPercentage = newFlow;
|
FlowPercentage = newFlow;
|
||||||
IsActive = newActive;
|
IsActive = newActive;
|
||||||
|
|
||||||
|
lastUpdate = sendingTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,12 +301,14 @@ namespace Barotrauma.Items.Components
|
|||||||
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
spriteBatch.DrawString(GUI.SmallFont, (int)(dist / 80.0f) + " m", new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(IsActive);
|
message.Write(IsActive);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private float load;
|
private float load;
|
||||||
|
|
||||||
|
private float lastUpdate;
|
||||||
|
|
||||||
private PropertyTask powerUpTask;
|
private PropertyTask powerUpTask;
|
||||||
|
|
||||||
[Editable, HasDefaultValue(9500.0f, true)]
|
[Editable, HasDefaultValue(9500.0f, true)]
|
||||||
@@ -445,7 +447,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(NetworkEventType type, NetBuffer message)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(autoTemp);
|
message.Write(autoTemp);
|
||||||
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
|
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
|
||||||
@@ -453,10 +455,14 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
message.WriteRangedSingle(coolingRate, 0.0f, 100.0f, 8);
|
message.WriteRangedSingle(coolingRate, 0.0f, 100.0f, 8);
|
||||||
message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8);
|
message.WriteRangedSingle(fissionRate, 0.0f, 100.0f, 8);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
public override void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
|
if (sendingTime < lastUpdate) return;
|
||||||
|
|
||||||
bool newAutoTemp;
|
bool newAutoTemp;
|
||||||
float newTemperature, newShutDownTemp;
|
float newTemperature, newShutDownTemp;
|
||||||
float newCoolingRate, newFissionRate;
|
float newCoolingRate, newFissionRate;
|
||||||
@@ -486,6 +492,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
CoolingRate = newCoolingRate;
|
CoolingRate = newCoolingRate;
|
||||||
FissionRate = newFissionRate;
|
FissionRate = newFissionRate;
|
||||||
|
|
||||||
|
lastUpdate = sendingTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,15 +209,17 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write(targetVelocity.X);
|
message.Write(targetVelocity.X);
|
||||||
message.Write(targetVelocity.Y);
|
message.Write(targetVelocity.Y);
|
||||||
|
|
||||||
message.Write(autoPilot);
|
message.Write(autoPilot);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
Vector2 newTargetVelocity = Vector2.Zero;
|
Vector2 newTargetVelocity = Vector2.Zero;
|
||||||
bool newAutoPilot = false;
|
bool newAutoPilot = false;
|
||||||
|
|||||||
@@ -196,13 +196,15 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed/MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed/MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(charge/capacity,0.0f, 1.0f), 0.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(charge/capacity,0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
float newRechargeSpeed = 0f;
|
float newRechargeSpeed = 0f;
|
||||||
float newCharge = 0.0f;
|
float newCharge = 0.0f;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace Barotrauma.Items.Components
|
|||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
foreach (Connection c in connections)
|
foreach (Connection c in connections)
|
||||||
{
|
{
|
||||||
@@ -135,9 +135,11 @@ namespace Barotrauma.Items.Components
|
|||||||
message.Write(wires[i].Item.ID);
|
message.Write(wires[i].Item.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("connectionpanel update");
|
System.Diagnostics.Debug.WriteLine("connectionpanel update");
|
||||||
foreach (Connection c in connections)
|
foreach (Connection c in connections)
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ namespace Barotrauma.Items.Components
|
|||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.Write((byte)Math.Min(Nodes.Count, 10));
|
message.Write((byte)Math.Min(Nodes.Count, 10));
|
||||||
for (int i = 0; i < Math.Min(Nodes.Count,10); i++)
|
for (int i = 0; i < Math.Min(Nodes.Count,10); i++)
|
||||||
@@ -436,9 +436,11 @@ namespace Barotrauma.Items.Components
|
|||||||
message.Write(Nodes[i].X);
|
message.Write(Nodes[i].X);
|
||||||
message.Write(Nodes[i].Y);
|
message.Write(Nodes[i].Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
Nodes.Clear();
|
Nodes.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public readonly Entity Owner;
|
public readonly Entity Owner;
|
||||||
|
|
||||||
|
protected float lastUpdate;
|
||||||
|
|
||||||
private int slotsPerRow;
|
private int slotsPerRow;
|
||||||
|
|
||||||
public int SlotsPerRow
|
public int SlotsPerRow
|
||||||
@@ -324,8 +326,10 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message)
|
public virtual void ReadNetworkData(NetworkEventType type, NetBuffer message, float sendingTime)
|
||||||
{
|
{
|
||||||
|
if (sendingTime < lastUpdate) return;
|
||||||
|
|
||||||
List<ushort> newItemIDs = new List<ushort>();
|
List<ushort> newItemIDs = new List<ushort>();
|
||||||
|
|
||||||
byte count = message.ReadByte();
|
byte count = message.ReadByte();
|
||||||
@@ -350,6 +354,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
TryPutItem(item, item.AllowedSlots, false);
|
TryPutItem(item, item.AllowedSlots, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastUpdate = sendingTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1249,8 +1249,9 @@ namespace Barotrauma
|
|||||||
if (componentIndex < 0 || componentIndex >= components.Count) return false;
|
if (componentIndex < 0 || componentIndex >= components.Count) return false;
|
||||||
|
|
||||||
message.Write((byte)componentIndex);
|
message.Write((byte)componentIndex);
|
||||||
components[componentIndex].FillNetworkData(type, message);
|
bool sent = components[componentIndex].FillNetworkData(type, message);
|
||||||
break;
|
if (sent) components[componentIndex].NetworkUpdateSent = true;
|
||||||
|
return sent;
|
||||||
case NetworkEventType.UpdateProperty:
|
case NetworkEventType.UpdateProperty:
|
||||||
var allProperties = GetProperties<InGameEditable>();
|
var allProperties = GetProperties<InGameEditable>();
|
||||||
|
|
||||||
@@ -1292,7 +1293,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
@@ -1319,7 +1320,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var itemContainer = GetComponent<ItemContainer>();
|
var itemContainer = GetComponent<ItemContainer>();
|
||||||
if (itemContainer == null || itemContainer.inventory == null) return;
|
if (itemContainer == null || itemContainer.inventory == null) return;
|
||||||
itemContainer.inventory.ReadNetworkData(NetworkEventType.DropItem, message);
|
itemContainer.inventory.ReadNetworkData(NetworkEventType.DropItem, message, sendingTime);
|
||||||
break;
|
break;
|
||||||
case NetworkEventType.ComponentUpdate:
|
case NetworkEventType.ComponentUpdate:
|
||||||
case NetworkEventType.ImportantComponentUpdate:
|
case NetworkEventType.ImportantComponentUpdate:
|
||||||
@@ -1328,7 +1329,9 @@ namespace Barotrauma
|
|||||||
data = componentIndex;
|
data = componentIndex;
|
||||||
|
|
||||||
if (componentIndex < 0 || componentIndex > components.Count - 1) return;
|
if (componentIndex < 0 || componentIndex > components.Count - 1) return;
|
||||||
components[componentIndex].ReadNetworkData(type, message);
|
|
||||||
|
components[componentIndex].NetworkUpdateSent = true;
|
||||||
|
components[componentIndex].ReadNetworkData(type, message, sendingTime);
|
||||||
break;
|
break;
|
||||||
case NetworkEventType.UpdateProperty:
|
case NetworkEventType.UpdateProperty:
|
||||||
string propertyName = "";
|
string propertyName = "";
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,7 +559,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
|
|||||||
@@ -639,8 +639,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
|
||||||
{
|
{
|
||||||
message.Write((float)NetTime.Now);
|
|
||||||
|
|
||||||
//var updateSections = Array.FindAll(sections, s => s != null && Math.Abs(s.damage - s.lastSentDamage) > 0.01f);
|
//var updateSections = Array.FindAll(sections, s => s != null && Math.Abs(s.damage - s.lastSentDamage) > 0.01f);
|
||||||
|
|
||||||
//if (updateSections.Length == 0) return false;
|
//if (updateSections.Length == 0) return false;
|
||||||
@@ -662,12 +660,11 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
float updateTime = message.ReadFloat();
|
if (sendingTime < lastUpdate) return;
|
||||||
if (updateTime < lastUpdate) return;
|
|
||||||
|
|
||||||
// int sectionCount = message.ReadByte();
|
// int sectionCount = message.ReadByte();
|
||||||
|
|
||||||
@@ -681,7 +678,7 @@ namespace Barotrauma
|
|||||||
SetDamage(i, damage);
|
SetDamage(i, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUpdate = updateTime;
|
lastUpdate = sendingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -391,7 +391,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (subBody == null) return false;
|
if (subBody == null) return false;
|
||||||
|
|
||||||
message.Write((float)NetTime.Now);
|
|
||||||
message.Write(Position.X);
|
message.Write(Position.X);
|
||||||
message.Write(Position.Y);
|
message.Write(Position.Y);
|
||||||
|
|
||||||
@@ -401,16 +400,13 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message, out object data)
|
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message, float sendingTime, out object data)
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
|
|
||||||
float sendingTime;
|
|
||||||
Vector2 newTargetPosition, newSpeed;
|
Vector2 newTargetPosition, newSpeed;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sendingTime = message.ReadFloat();
|
|
||||||
|
|
||||||
if (sendingTime <= lastNetworkUpdate) return;
|
if (sendingTime <= lastNetworkUpdate) return;
|
||||||
|
|
||||||
newTargetPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
newTargetPosition = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||||
|
|||||||
@@ -195,9 +195,19 @@ namespace Barotrauma
|
|||||||
Vector2 translateAmount = speed * deltaTime;
|
Vector2 translateAmount = speed * deltaTime;
|
||||||
translateAmount += ConvertUnits.ToDisplayUnits(body.Position) * collisionRigidness;
|
translateAmount += ConvertUnits.ToDisplayUnits(body.Position) * collisionRigidness;
|
||||||
|
|
||||||
if (targetPosition != Vector2.Zero && Vector2.Distance(targetPosition, sub.Position) > 50.0f)
|
if (targetPosition != Vector2.Zero && targetPosition != sub.Position)
|
||||||
{
|
{
|
||||||
translateAmount += (targetPosition - sub.Position) * 0.01f;
|
float dist = Vector2.Distance(targetPosition, sub.Position);
|
||||||
|
|
||||||
|
if (dist>1000.0f)
|
||||||
|
{
|
||||||
|
sub.SetPosition(targetPosition);
|
||||||
|
targetPosition = Vector2.Zero;
|
||||||
|
}
|
||||||
|
else if (dist>50.0f)
|
||||||
|
{
|
||||||
|
translateAmount += (targetPosition - sub.Position) * 0.01f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
else if (gameStarted)
|
else if (gameStarted)
|
||||||
{
|
{
|
||||||
myCharacter.CreateUpdateNetworkEvent(true);
|
new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (gameStarted)
|
if (gameStarted)
|
||||||
{
|
{
|
||||||
if (myCharacter != null) myCharacter.CreateUpdateNetworkEvent(false);
|
if (myCharacter != null) new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, false);
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
@@ -290,7 +290,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
|
if (c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
|
||||||
|
|
||||||
c.CreateUpdateNetworkEvent(false);
|
new NetworkEvent(NetworkEventType.EntityUpdate, c.ID, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
if (c is AICharacter || c.IsDead) continue;
|
if (c.IsDead) continue;
|
||||||
|
|
||||||
|
if (c is AICharacter && c.SimPosition.Length() > NetConfig.CharacterIgnoreDistance) continue;
|
||||||
|
|
||||||
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false);
|
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, c.ID, false);
|
||||||
}
|
}
|
||||||
@@ -652,8 +654,6 @@ namespace Barotrauma.Networking
|
|||||||
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, hull.ID, false);
|
new NetworkEvent(NetworkEventType.ImportantEntityUpdate, hull.ID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendNetworkEvents(new List<Client>() { sender });
|
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
new NetworkEvent(NetworkEventType.EntityUpdate, c.ID, false);
|
new NetworkEvent(NetworkEventType.EntityUpdate, c.ID, false);
|
||||||
@@ -661,17 +661,30 @@ namespace Barotrauma.Networking
|
|||||||
if (c.IsDead) new NetworkEvent(NetworkEventType.KillCharacter, c.ID, false);
|
if (c.IsDead) new NetworkEvent(NetworkEventType.KillCharacter, c.ID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendNetworkEvents(new List<Client>() { sender });
|
|
||||||
|
|
||||||
foreach (Item item in Item.ItemList)
|
foreach (Item item in Item.ItemList)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < item.components.Count; i++)
|
||||||
|
{
|
||||||
|
if (!item.components[i].NetworkUpdateSent) continue;
|
||||||
|
item.NewComponentEvent(item.components[i], false, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (item.body == null || item.body.Enabled == false) continue;
|
if (item.body == null || item.body.Enabled == false) continue;
|
||||||
new NetworkEvent(NetworkEventType.DropItem, item.ID, false);
|
new NetworkEvent(NetworkEventType.DropItem, item.ID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendNetworkEvents(new List<Client>() { sender });
|
List<NetworkEvent> syncMessages = new List<NetworkEvent>(NetworkEvent.Events);
|
||||||
|
while (syncMessages.Any())
|
||||||
|
{
|
||||||
|
NetworkEvent.Events = syncMessages.GetRange(0, Math.Min(syncMessages.Count, 5));
|
||||||
|
SendNetworkEvents(new List<Client>() { sender });
|
||||||
|
syncMessages.RemoveRange(0, Math.Min(syncMessages.Count, 5));
|
||||||
|
|
||||||
|
NetworkEvent.Events = existingEvents;
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public static void ReadMessage(NetIncomingMessage message, bool resend=false)
|
public static void ReadMessage(NetIncomingMessage message, bool resend=false)
|
||||||
{
|
{
|
||||||
|
float sendingTime = message.ReadFloat();
|
||||||
|
|
||||||
byte msgCount = message.ReadByte();
|
byte msgCount = message.ReadByte();
|
||||||
long currPos = message.PositionInBytes;
|
long currPos = message.PositionInBytes;
|
||||||
|
|
||||||
@@ -161,7 +163,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NetworkEvent.ReadData(message, resend);
|
NetworkEvent.ReadData(message, sendingTime, resend);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -173,7 +175,7 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ReadData(NetIncomingMessage message, bool resend=false)
|
public static bool ReadData(NetIncomingMessage message, float sendingTime, bool resend=false)
|
||||||
{
|
{
|
||||||
NetworkEventType eventType;
|
NetworkEventType eventType;
|
||||||
ushort id;
|
ushort id;
|
||||||
@@ -207,7 +209,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
e.ReadNetworkData(eventType, message, out data);
|
e.ReadNetworkData(eventType, message, sendingTime, out data);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ namespace Barotrauma.Networking
|
|||||||
NetOutgoingMessage message = netPeer.CreateMessage();
|
NetOutgoingMessage message = netPeer.CreateMessage();
|
||||||
message.Write((byte)PacketTypes.NetworkEvent);
|
message.Write((byte)PacketTypes.NetworkEvent);
|
||||||
|
|
||||||
|
message.Write((float)NetTime.Now);
|
||||||
|
|
||||||
message.Write((byte)msgBytes.Count);
|
message.Write((byte)msgBytes.Count);
|
||||||
foreach (byte[] msgData in msgBytes)
|
foreach (byte[] msgData in msgBytes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Barotrauma
|
|||||||
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
|
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
|
||||||
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
|
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
|
||||||
sb.AppendLine("Loaded submarine: " + ((Submarine.Loaded == null) ? "none" : Submarine.Loaded.Name +" ("+Submarine.Loaded.MD5Hash+")"));
|
sb.AppendLine("Loaded submarine: " + ((Submarine.Loaded == null) ? "none" : Submarine.Loaded.Name +" ("+Submarine.Loaded.MD5Hash+")"));
|
||||||
sb.AppendLine("Selected screen: " + Screen.Selected.ToString());
|
sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
@@ -80,9 +80,9 @@ namespace Barotrauma
|
|||||||
sb.AppendLine("\n");
|
sb.AppendLine("\n");
|
||||||
|
|
||||||
sb.AppendLine("Last debug messages:");
|
sb.AppendLine("Last debug messages:");
|
||||||
for (int i = DebugConsole.messages.Count - 1; i > 0 && i > DebugConsole.messages.Count - 10; i-- )
|
for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 10; i-- )
|
||||||
{
|
{
|
||||||
sb.AppendLine(" "+DebugConsole.messages[i].Time+" - "+DebugConsole.messages[i].Text);
|
sb.AppendLine(" "+DebugConsole.Messages[i].Time+" - "+DebugConsole.Messages[i].Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user