Unstable 1.1.14.0
This commit is contained in:
@@ -282,12 +282,12 @@ namespace Barotrauma.Networking
|
||||
return length;
|
||||
}
|
||||
|
||||
public static bool CanUseRadio(Character sender)
|
||||
public static bool CanUseRadio(Character sender, bool ignoreJamming = false)
|
||||
{
|
||||
return CanUseRadio(sender, out _);
|
||||
return CanUseRadio(sender, out _, ignoreJamming);
|
||||
}
|
||||
|
||||
public static bool CanUseRadio(Character sender, out WifiComponent radio)
|
||||
public static bool CanUseRadio(Character sender, out WifiComponent radio, bool ignoreJamming = false)
|
||||
{
|
||||
radio = null;
|
||||
if (sender?.Inventory == null || sender.Removed) { return false; }
|
||||
@@ -295,7 +295,7 @@ namespace Barotrauma.Networking
|
||||
foreach (Item item in sender.Inventory.AllItems)
|
||||
{
|
||||
var wifiComponent = item.GetComponent<WifiComponent>();
|
||||
if (wifiComponent == null || !wifiComponent.LinkToChat || !wifiComponent.CanTransmit() || !sender.HasEquippedItem(item)) { continue; }
|
||||
if (wifiComponent == null || !wifiComponent.LinkToChat || !wifiComponent.CanTransmit(ignoreJamming) || !sender.HasEquippedItem(item)) { continue; }
|
||||
if (radio == null || wifiComponent.Range > radio.Range)
|
||||
{
|
||||
radio = wifiComponent;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
DebugConsole.NewMessage(value.Name, Microsoft.Xna.Framework.Color.Yellow);
|
||||
DebugConsole.NewMessage(value.Name, Color.Yellow);
|
||||
}
|
||||
}
|
||||
character = value;
|
||||
@@ -90,12 +90,6 @@ namespace Barotrauma.Networking
|
||||
UsingFreeCam = false;
|
||||
#if CLIENT
|
||||
GameMain.GameSession?.CrewManager?.SetPlayerVoiceIconState(this, muted, mutedLocally);
|
||||
|
||||
if (character == GameMain.Client.Character && GameMain.Client.SpawnAsTraitor)
|
||||
{
|
||||
character.IsTraitor = true;
|
||||
character.TraitorCurrentObjective = GameMain.Client.TraitorFirstObjective;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +194,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Queue<IEntitySpawnInfo> spawnQueue;
|
||||
private readonly Queue<Entity> removeQueue;
|
||||
private readonly Queue<Either<IEntitySpawnInfo, Entity>> spawnOrRemoveQueue;
|
||||
|
||||
public abstract class SpawnOrRemove : NetEntityEvent.IData
|
||||
{
|
||||
@@ -255,8 +254,7 @@ namespace Barotrauma
|
||||
public EntitySpawner()
|
||||
: base(null, Entity.EntitySpawnerID)
|
||||
{
|
||||
spawnQueue = new Queue<IEntitySpawnInfo>();
|
||||
removeQueue = new Queue<Entity>();
|
||||
spawnOrRemoveQueue = new Queue<Either<IEntitySpawnInfo, Entity>>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -274,7 +272,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue1:ItemPrefabNull", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new ItemSpawnInfo(itemPrefab, worldPosition, onSpawned, condition, quality));
|
||||
spawnOrRemoveQueue.Enqueue(new ItemSpawnInfo(itemPrefab, worldPosition, onSpawned, condition, quality));
|
||||
}
|
||||
|
||||
public void AddItemToSpawnQueue(ItemPrefab itemPrefab, Vector2 position, Submarine sub, float? condition = null, int? quality = null, Action<Item> onSpawned = null)
|
||||
@@ -287,7 +285,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue2:ItemPrefabNull", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new ItemSpawnInfo(itemPrefab, position, sub, onSpawned, condition, quality));
|
||||
spawnOrRemoveQueue.Enqueue(new ItemSpawnInfo(itemPrefab, position, sub, onSpawned, condition, quality));
|
||||
}
|
||||
|
||||
public void AddItemToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, float? condition = null, int? quality = null, Action<Item> onSpawned = null, bool spawnIfInventoryFull = true, bool ignoreLimbSlots = false, InvSlotType slot = InvSlotType.None)
|
||||
@@ -300,7 +298,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue3:ItemPrefabNull", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new ItemSpawnInfo(itemPrefab, inventory, onSpawned, condition, quality)
|
||||
spawnOrRemoveQueue.Enqueue(new ItemSpawnInfo(itemPrefab, inventory, onSpawned, condition, quality)
|
||||
{
|
||||
SpawnIfInventoryFull = spawnIfInventoryFull,
|
||||
IgnoreLimbSlots = ignoreLimbSlots,
|
||||
@@ -318,7 +316,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue4:SpeciesNameNullOrEmpty", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new CharacterSpawnInfo(speciesName, worldPosition, onSpawn));
|
||||
spawnOrRemoveQueue.Enqueue(new CharacterSpawnInfo(speciesName, worldPosition, onSpawn));
|
||||
}
|
||||
|
||||
public void AddCharacterToSpawnQueue(Identifier speciesName, Vector2 position, Submarine sub, Action<Character> onSpawn = null)
|
||||
@@ -331,7 +329,7 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue5:SpeciesNameNullOrEmpty", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new CharacterSpawnInfo(speciesName, position, sub, onSpawn));
|
||||
spawnOrRemoveQueue.Enqueue(new CharacterSpawnInfo(speciesName, position, sub, onSpawn));
|
||||
}
|
||||
|
||||
public void AddCharacterToSpawnQueue(Identifier speciesName, Vector2 worldPosition, CharacterInfo characterInfo, Action<Character> onSpawn = null)
|
||||
@@ -344,13 +342,13 @@ namespace Barotrauma
|
||||
GameAnalyticsManager.AddErrorEventOnce("EntitySpawner.AddToSpawnQueue4:SpeciesNameNullOrEmpty", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
spawnQueue.Enqueue(new CharacterSpawnInfo(speciesName, worldPosition, characterInfo, onSpawn));
|
||||
spawnOrRemoveQueue.Enqueue(new CharacterSpawnInfo(speciesName, worldPosition, characterInfo, onSpawn));
|
||||
}
|
||||
|
||||
public void AddEntityToRemoveQueue(Entity entity)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
if (removeQueue.Contains(entity) || entity.Removed || entity == null || entity.IdFreed) { return; }
|
||||
if (entity == null || IsInRemoveQueue(entity) || entity.Removed || entity.IdFreed) { return; }
|
||||
if (entity is Item item) { AddItemToRemoveQueue(item); return; }
|
||||
if (entity is Character)
|
||||
{
|
||||
@@ -364,15 +362,15 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
|
||||
removeQueue.Enqueue(entity);
|
||||
spawnOrRemoveQueue.Enqueue(entity);
|
||||
}
|
||||
|
||||
public void AddItemToRemoveQueue(Item item)
|
||||
{
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
|
||||
if (removeQueue.Contains(item) || item.Removed) { return; }
|
||||
if (IsInRemoveQueue(item) || item.Removed) { return; }
|
||||
|
||||
removeQueue.Enqueue(item);
|
||||
spawnOrRemoveQueue.Enqueue(item);
|
||||
var containedItems = item.OwnInventory?.AllItems;
|
||||
if (containedItems == null) { return; }
|
||||
foreach (Item containedItem in containedItems)
|
||||
@@ -389,7 +387,11 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public bool IsInSpawnQueue(Predicate<IEntitySpawnInfo> predicate)
|
||||
{
|
||||
return spawnQueue.Any(s => predicate(s));
|
||||
foreach (var spawnOrRemove in spawnOrRemoveQueue)
|
||||
{
|
||||
if (spawnOrRemove.TryGet(out IEntitySpawnInfo spawnInfo) && predicate(spawnInfo)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -397,43 +399,51 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public int CountSpawnQueue(Predicate<IEntitySpawnInfo> predicate)
|
||||
{
|
||||
return spawnQueue.Count(s => predicate(s));
|
||||
int count = 0;
|
||||
foreach (var spawnOrRemove in spawnOrRemoveQueue)
|
||||
{
|
||||
if (spawnOrRemove.TryGet(out IEntitySpawnInfo spawnInfo) && predicate(spawnInfo)) { count++; }
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public bool IsInRemoveQueue(Entity entity)
|
||||
{
|
||||
return removeQueue.Contains(entity);
|
||||
foreach (var spawnOrRemove in spawnOrRemoveQueue)
|
||||
{
|
||||
if (spawnOrRemove.TryGet(out Entity entityToRemove) && entityToRemove == entity) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Update(bool createNetworkEvents = true)
|
||||
{
|
||||
if (GameMain.NetworkMember is { IsClient: true }) { return; }
|
||||
while (spawnQueue.Count > 0)
|
||||
while (spawnOrRemoveQueue.Count > 0)
|
||||
{
|
||||
var entitySpawnInfo = spawnQueue.Dequeue();
|
||||
|
||||
var spawnedEntity = entitySpawnInfo.Spawn();
|
||||
if (spawnedEntity == null) { continue; }
|
||||
|
||||
if (createNetworkEvents)
|
||||
var spawnOrRemove = spawnOrRemoveQueue.Dequeue();
|
||||
if (spawnOrRemove.TryGet(out Entity entityToRemove))
|
||||
{
|
||||
if (entityToRemove is Item item)
|
||||
{
|
||||
item.SendPendingNetworkUpdates();
|
||||
}
|
||||
if (createNetworkEvents)
|
||||
{
|
||||
CreateNetworkEventProjSpecific(new RemoveEntity(entityToRemove));
|
||||
}
|
||||
entityToRemove.Remove();
|
||||
}
|
||||
else if (spawnOrRemove.TryGet(out IEntitySpawnInfo spawnInfo))
|
||||
{
|
||||
CreateNetworkEventProjSpecific(new SpawnEntity(spawnedEntity));
|
||||
var spawnedEntity = spawnInfo.Spawn();
|
||||
if (spawnedEntity == null) { continue; }
|
||||
if (createNetworkEvents)
|
||||
{
|
||||
CreateNetworkEventProjSpecific(new SpawnEntity(spawnedEntity));
|
||||
}
|
||||
spawnInfo.OnSpawned(spawnedEntity);
|
||||
}
|
||||
entitySpawnInfo.OnSpawned(spawnedEntity);
|
||||
}
|
||||
|
||||
while (removeQueue.Count > 0)
|
||||
{
|
||||
var removedEntity = removeQueue.Dequeue();
|
||||
if (removedEntity is Item item)
|
||||
{
|
||||
item.SendPendingNetworkUpdates();
|
||||
}
|
||||
if (createNetworkEvents)
|
||||
{
|
||||
CreateNetworkEventProjSpecific(new RemoveEntity(removedEntity));
|
||||
}
|
||||
removedEntity.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,8 +451,7 @@ namespace Barotrauma
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
removeQueue.Clear();
|
||||
spawnQueue.Clear();
|
||||
spawnOrRemoveQueue.Clear();
|
||||
#if CLIENT
|
||||
receivedEvents.Clear();
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Barotrauma.Networking
|
||||
MEDICAL, //medical clinic
|
||||
TRANSFER_MONEY, // wallet transfers
|
||||
REWARD_DISTRIBUTION, // wallet reward distribution
|
||||
CIRCUITBOX,
|
||||
READY_CHECK,
|
||||
READY_TO_SPAWN
|
||||
}
|
||||
@@ -80,11 +81,12 @@ namespace Barotrauma.Networking
|
||||
STARTGAMEFINALIZE, //finalize round initialization
|
||||
ENDGAME,
|
||||
|
||||
TRAITOR_MESSAGE,
|
||||
MISSION,
|
||||
EVENTACTION,
|
||||
TRAITOR_MESSAGE,
|
||||
CREW, //anything related to managing bots in multiplayer
|
||||
MEDICAL, //medical clinic
|
||||
CIRCUITBOX,
|
||||
MONEY,
|
||||
READY_CHECK //start, end and update a ready check
|
||||
}
|
||||
@@ -112,14 +114,6 @@ namespace Barotrauma.Networking
|
||||
EntityId: entity.ID);
|
||||
}
|
||||
|
||||
enum TraitorMessageType
|
||||
{
|
||||
Server,
|
||||
ServerMessageBox,
|
||||
Objective,
|
||||
Console
|
||||
}
|
||||
|
||||
enum VoteType
|
||||
{
|
||||
Unknown,
|
||||
@@ -131,7 +125,8 @@ namespace Barotrauma.Networking
|
||||
PurchaseAndSwitchSub,
|
||||
PurchaseSub,
|
||||
SwitchSub,
|
||||
TransferMoney
|
||||
TransferMoney,
|
||||
Traitor,
|
||||
}
|
||||
|
||||
public enum ReadyCheckState
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Barotrauma.Networking
|
||||
deliveryMethod switch
|
||||
{
|
||||
DeliveryMethod.Reliable => Steamworks.P2PSend.Reliable,
|
||||
DeliveryMethod.ReliableOrdered => Steamworks.P2PSend.Unreliable,
|
||||
DeliveryMethod.ReliableOrdered => Steamworks.P2PSend.Reliable,
|
||||
_ => Steamworks.P2PSend.Unreliable
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma.Networking
|
||||
/// <summary>
|
||||
/// How much skills drop towards the job's default skill levels when dying
|
||||
/// </summary>
|
||||
const float SkillReductionOnDeath = 0.75f;
|
||||
public static float SkillLossPercentageOnDeath => GameMain.NetworkMember?.ServerSettings?.SkillLossPercentageOnDeath ?? 50.0f;
|
||||
|
||||
public enum State
|
||||
{
|
||||
@@ -26,7 +26,6 @@ namespace Barotrauma.Networking
|
||||
private readonly NetworkMember networkMember;
|
||||
private readonly Steering shuttleSteering;
|
||||
private readonly List<Door> shuttleDoors;
|
||||
private const string RespawnContainerTag = "respawncontainer";
|
||||
private readonly ItemContainer respawnContainer;
|
||||
|
||||
//items created during respawn
|
||||
@@ -109,7 +108,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (item.Submarine != RespawnShuttle) { continue; }
|
||||
|
||||
if (item.HasTag(RespawnContainerTag))
|
||||
if (item.HasTag(Tags.RespawnContainer))
|
||||
{
|
||||
respawnContainer = item.GetComponent<ItemContainer>();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Barotrauma.Networking
|
||||
DoSProtection,
|
||||
Karma,
|
||||
Talent,
|
||||
Traitors,
|
||||
Error,
|
||||
}
|
||||
|
||||
@@ -59,6 +60,7 @@ namespace Barotrauma.Networking
|
||||
{ MessageType.DoSProtection, Color.OrangeRed },
|
||||
{ MessageType.Karma, new Color(75, 88, 255) },
|
||||
{ MessageType.Talent, new Color(125, 125, 255) },
|
||||
{ MessageType.Traitors, new Color(107, 69, 158) },
|
||||
{ MessageType.Error, Color.Red }
|
||||
};
|
||||
|
||||
@@ -76,6 +78,7 @@ namespace Barotrauma.Networking
|
||||
{ MessageType.DoSProtection, "DoSProtection" },
|
||||
{ MessageType.Karma, "Karma" },
|
||||
{ MessageType.Talent, "Talent" },
|
||||
{ MessageType.Traitors, "Traitors" },
|
||||
{ MessageType.Error, "Error" }
|
||||
};
|
||||
|
||||
|
||||
@@ -15,11 +15,6 @@ namespace Barotrauma.Networking
|
||||
Manual = 0, Random = 1, Vote = 2
|
||||
}
|
||||
|
||||
public enum YesNoMaybe
|
||||
{
|
||||
No = 0, Maybe = 1, Yes = 2
|
||||
}
|
||||
|
||||
public enum BotSpawnMode
|
||||
{
|
||||
Normal, Fill
|
||||
@@ -437,6 +432,16 @@ namespace Barotrauma.Networking
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(50f, IsPropertySaveable.Yes)]
|
||||
/// <summary>
|
||||
/// How much skills drop towards the job's default skill levels when dying
|
||||
/// </summary>
|
||||
public float SkillLossPercentageOnDeath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(60.0f, IsPropertySaveable.Yes)]
|
||||
public float AutoRestartInterval
|
||||
{
|
||||
@@ -485,13 +490,6 @@ namespace Barotrauma.Networking
|
||||
private set;
|
||||
} = true;
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
public bool AllowRagdollButton
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
public bool AllowFileTransfers
|
||||
{
|
||||
@@ -722,19 +720,33 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
private YesNoMaybe traitorsEnabled;
|
||||
[Serialize(YesNoMaybe.No, IsPropertySaveable.Yes)]
|
||||
public YesNoMaybe TraitorsEnabled
|
||||
private float traitorProbability;
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float TraitorProbability
|
||||
{
|
||||
get { return traitorsEnabled; }
|
||||
get { return traitorProbability; }
|
||||
set
|
||||
{
|
||||
if (traitorsEnabled == value) { return; }
|
||||
traitorsEnabled = value;
|
||||
if (MathUtils.NearlyEqual(traitorProbability, value)) { return; }
|
||||
traitorProbability = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
ServerDetailsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int traitorDangerLevel;
|
||||
[Serialize(TraitorEventPrefab.MinDangerLevel, IsPropertySaveable.Yes)]
|
||||
public int TraitorDangerLevel
|
||||
{
|
||||
get { return traitorDangerLevel; }
|
||||
set
|
||||
{
|
||||
int clampedValue = MathHelper.Clamp(value, TraitorEventPrefab.MinDangerLevel, TraitorEventPrefab.MaxDangerLevel);
|
||||
if (traitorDangerLevel == clampedValue) { return; }
|
||||
traitorDangerLevel = clampedValue;
|
||||
ServerDetailsChanged = true;
|
||||
}
|
||||
}
|
||||
[Serialize(defaultValue: 1, isSaveable: IsPropertySaveable.Yes)]
|
||||
public int TraitorsMinPlayerCount
|
||||
{
|
||||
@@ -742,34 +754,13 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 90.0f, isSaveable: IsPropertySaveable.Yes)]
|
||||
public float TraitorsMinStartDelay
|
||||
[Serialize(defaultValue: 50.0f, isSaveable: IsPropertySaveable.Yes)]
|
||||
public float MinPercentageOfPlayersForTraitorAccusation
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 180.0f, isSaveable: IsPropertySaveable.Yes)]
|
||||
public float TraitorsMaxStartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 30.0f, isSaveable: IsPropertySaveable.Yes)]
|
||||
public float TraitorsMinRestartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: 90.0f, isSaveable: IsPropertySaveable.Yes)]
|
||||
public float TraitorsMaxRestartDelay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(defaultValue: "", IsPropertySaveable.Yes)]
|
||||
public LanguageIdentifier Language { get; set; }
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@ namespace Barotrauma
|
||||
|
||||
public static T HighestVoted<T>(VoteType voteType, IEnumerable<Client> voters)
|
||||
{
|
||||
return HighestVoted<T>(voteType, voters, out _);
|
||||
}
|
||||
|
||||
public static T HighestVoted<T>(VoteType voteType, IEnumerable<Client> voters, out int voteCount)
|
||||
{
|
||||
voteCount = 0;
|
||||
if (voteType == VoteType.Sub && !GameMain.NetworkMember.ServerSettings.AllowSubVoting) { return default; }
|
||||
if (voteType == VoteType.Mode && !GameMain.NetworkMember.ServerSettings.AllowModeVoting) { return default; }
|
||||
|
||||
@@ -52,7 +58,7 @@ namespace Barotrauma
|
||||
selected = votable.Key;
|
||||
}
|
||||
}
|
||||
|
||||
voteCount = highestVotes;
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user