Unstable v0.1100.0.4 (November 11th 2020)

This commit is contained in:
Joonas Rikkonen
2020-11-06 20:12:15 +02:00
parent 6b36bf809d
commit b772654326
297 changed files with 12502 additions and 4277 deletions
@@ -123,6 +123,36 @@ namespace Barotrauma
}
}
class SubmarineSpawnInfo : IEntitySpawnInfo
{
public readonly string Name;
public readonly Vector2 Position;
private readonly Action<Character> onSpawned;
public SubmarineSpawnInfo(string name, Vector2 worldPosition, Action<Character> onSpawn = null)
{
this.Name = name ?? throw new ArgumentException("ItemSpawnInfo prefab cannot be null.");
Position = worldPosition;
this.onSpawned = onSpawn;
}
public Entity Spawn()
{
var submarine = string.IsNullOrEmpty(Name) ? null :
new Submarine(SubmarineInfo.SavedSubmarines.First(s => s.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)));
return submarine;
}
public void OnSpawned(Entity spawnedCharacter)
{
if (!(spawnedCharacter is Character character)) { throw new ArgumentException($"The entity passed to CharacterSpawnInfo.OnSpawned must be a Character (value was {spawnedCharacter?.ToString() ?? "null"})."); }
onSpawned?.Invoke(character);
}
}
private readonly Queue<IEntitySpawnInfo> spawnQueue;
private readonly Queue<Entity> removeQueue;
@@ -136,6 +166,14 @@ namespace Barotrauma
public readonly bool Remove = false;
public override string ToString()
{
return
(Remove ? "Remove" : "Spawn") + "(" +
((Entity as MapEntity)?.Name ?? "[NULL]") +
$", {OriginalID}, {OriginalInventoryID})";
}
public SpawnOrRemove(Entity entity, bool remove)
{
Entity = entity;
@@ -163,7 +201,7 @@ namespace Barotrauma
}
public EntitySpawner()
: base(null)
: base(null, Entity.EntitySpawnerID)
{
spawnQueue = new Queue<IEntitySpawnInfo>();
removeQueue = new Queue<Entity>();
@@ -253,7 +291,7 @@ namespace Barotrauma
if (client != null) GameMain.Server.SetClientCharacter(client, null);
}
#endif
}
}
removeQueue.Enqueue(entity);
}
@@ -32,8 +32,10 @@ namespace Barotrauma
[Serialize(0.05f, true)]
public float StructureRepairKarmaIncrease { get; set; }
[Serialize(0.1f, true)]
public float StructureDamageKarmaDecrease { get; set; }
[Serialize(30.0f, true)]
public float MaxStructureDamageKarmaDecreasePerSecond { get; set; }
@@ -67,6 +69,9 @@ namespace Barotrauma
[Serialize(defaultValue: false, true)]
public bool DangerousItemStealBots { get; set; }
[Serialize(defaultValue: 0.05f, true)]
public float BallastFloraKarmaIncrease { get; set; }
private int allowedWireDisconnectionsPerMinute;
[Serialize(5, true)]
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma.Networking
{
@@ -46,7 +47,7 @@ namespace Barotrauma.Networking
//the length of the data is written as a byte, so the data needs to be less than 255 bytes long
if (tempEventBuffer.LengthBytes > 255)
{
DebugConsole.ThrowError("Too much data in network event for entity \"" + e.Entity.ToString() + "\" (" + tempEventBuffer.LengthBytes + " bytes, event ID " + e.ID + ")");
DebugConsole.ThrowError("Too much data in network event for entity \"" + e.Entity.ToString() + "\" (" + tempEventBuffer.LengthBytes + " bytes, event ID " + e.ID + $", {string.Join(' ',e.Data.Select(d => d.ToString()))})");
GameAnalyticsManager.AddErrorEventOnce("NetEntityEventManager.Write:TooLong" + e.Entity.ToString(),
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
"Too much data in network event for entity \"" + e.Entity.ToString() + "\" (" + tempEventBuffer.LengthBytes + " bytes, event ID " + e.ID + ")");
@@ -29,7 +29,8 @@ namespace Barotrauma.Networking
REQUEST_STARTGAMEFINALIZE, //tell the server you're ready to finalize round initialization
ERROR, //tell the server that an error occurred
CREW
CREW,
READY_CHECK
}
enum ClientNetObject
@@ -78,7 +79,8 @@ namespace Barotrauma.Networking
MISSION,
EVENTACTION,
RESET_UPGRADES, //inform the clients that the upgrades on the submarine have been reset
CREW //anything related to managing bots in multiplayer
CREW, //anything related to managing bots in multiplayer
READY_CHECK //start, end and update a ready check
}
enum ServerNetObject
{
@@ -113,6 +115,13 @@ namespace Barotrauma.Networking
SwitchSub
}
public enum ReadyCheckState
{
Start,
Update,
End
}
enum DisconnectReason
{
Unknown,
@@ -13,6 +13,11 @@
//additional instructions (power up, fire at will, etc)
public readonly string OrderOption;
/// <summary>
/// Used when the order targets a wall
/// </summary>
public int? WallSectionIndex { get; set; }
public OrderChatMessage(Order order, string orderOption, ISpatialEntity targetEntity, Character targetCharacter, Character sender)
: this(order, orderOption,
order?.GetChatMessage(targetCharacter?.Name, sender?.CurrentHull?.DisplayName, givingOrderToSelf: targetCharacter == sender, orderOption: orderOption),
@@ -62,7 +62,7 @@ namespace Barotrauma.Networking
public Submarine RespawnShuttle { get; private set; }
public RespawnManager(NetworkMember networkMember, SubmarineInfo shuttleInfo)
: base(null)
: base(null, Entity.RespawnManagerID)
{
this.networkMember = networkMember;
@@ -265,7 +265,7 @@ namespace Barotrauma.Networking
#endif
c.Kill(CauseOfDeathType.Unknown, null, true);
c.Enabled = false;
Spawner.AddToRemoveQueue(c);
if (c.Inventory != null)
{