5202af9...3ea33fb

This commit is contained in:
Joonas Rikkonen
2019-03-18 21:46:09 +02:00
parent 044fd3344b
commit 97f31d0c94
61 changed files with 2585 additions and 558 deletions
@@ -188,45 +188,6 @@ namespace Barotrauma
newOrder = new Order(orderPrefab, Character.CurrentHull, null);
}
if (Character.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.ConnectedDoor == null && g.Open > 0.0f))
{
var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbreach");
newOrder = new Order(orderPrefab, Character.CurrentHull, null);
}
foreach (Character c in Character.CharacterList)
{
if (c.CurrentHull == Character.CurrentHull && !c.IsDead &&
(c.AIController is EnemyAIController || c.TeamID != Character.TeamID))
{
var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportintruders");
newOrder = new Order(orderPrefab, Character.CurrentHull, null);
}
}
}
if (Character.CurrentHull != null && (Character.Bleeding > 1.0f || Character.Vitality < Character.MaxVitality * 0.1f))
{
var orderPrefab = Order.PrefabList.Find(o => o.AITag == "requestfirstaid");
newOrder = new Order(orderPrefab, Character.CurrentHull, null);
}
if (newOrder != null)
{
if (GameMain.GameSession?.CrewManager != null && GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime))
{
Character.Speak(
newOrder.GetChatMessage("", Character.CurrentHull?.RoomName), ChatMessageType.Order);
if (GameMain.Server != null)
{
OrderChatMessage msg = new OrderChatMessage(newOrder, "", Character.CurrentHull, null, Character);
GameMain.Server.SendOrderChatMessage(msg);
}
}
}
}
partial void ReportProblems();
private void UpdateSpeaking()
@@ -299,21 +260,5 @@ namespace Barotrauma
float minCeilingDist = Character.AnimController.Collider.height / 2 + Character.AnimController.Collider.radius + 0.1f;
shouldCrouch = Submarine.PickBody(startPos, startPos + Vector2.UnitY * minCeilingDist, null, Physics.CollisionWall) != null;
}
private void CheckCrouching(float deltaTime)
{
crouchRaycastTimer -= deltaTime;
if (crouchRaycastTimer > 0.0f) return;
crouchRaycastTimer = CrouchRaycastInterval;
//start the raycast in front of the character in the direction it's heading to
Vector2 startPos = Character.SimPosition;
startPos.X += MathHelper.Clamp(Character.AnimController.TargetMovement.X, -1.0f, 1.0f);
//do a raycast upwards to find any walls
float minCeilingDist = Character.AnimController.Collider.height / 2 + Character.AnimController.Collider.radius + 0.1f;
shouldCrouch = Submarine.PickBody(startPos, startPos + Vector2.UnitY * minCeilingDist, null, Physics.CollisionWall) != null;
}
}
}
@@ -697,6 +697,22 @@ namespace Barotrauma
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
}
private void SmoothRotateWithoutWrapping(Limb limb, float angle, Limb referenceLimb, float torque)
{
//make sure the angle "has the same number of revolutions" as the reference limb
//(e.g. we don't want to rotate the legs to 0 if the torso is at 360, because that'd blow up the hip joints)
while (referenceLimb.Rotation - angle > MathHelper.TwoPi)
{
angle += MathHelper.TwoPi;
}
while (referenceLimb.Rotation - angle < -MathHelper.TwoPi)
{
angle -= MathHelper.TwoPi;
}
limb?.body.SmoothRotate(angle, torque, wrapAngle: false);
}
public override void Flip()
{
base.Flip();
@@ -1297,6 +1297,7 @@ namespace Barotrauma
CheckValidity(Collider);
foreach (Limb limb in limbs)
{
if (limb.body == null || !limb.body.Enabled) { continue; }
CheckValidity(limb.body);
}
}
@@ -1323,7 +1324,11 @@ namespace Barotrauma
}
if (errorMsg != null)
{
#if DEBUG
DebugConsole.ThrowError(errorMsg);
#else
DebugConsole.NewMessage(errorMsg, Color.Red);
#endif
GameAnalyticsManager.AddErrorEventOnce("Ragdoll.CheckValidity:" + character.ID, GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
if (!MathUtils.IsValid(Collider.SimPosition) || Math.Abs(Collider.SimPosition.X) > 1e10f || Math.Abs(Collider.SimPosition.Y) > 1e10f)
@@ -10,6 +10,7 @@ using System.Xml.Linq;
using Barotrauma.Items.Components;
using FarseerPhysics.Dynamics;
using Barotrauma.Extensions;
using System.Text;
namespace Barotrauma
{
@@ -529,37 +530,6 @@ namespace Barotrauma
set { canInventoryBeAccessed = value; }
}
private bool canBeDragged = true;
public bool CanBeDragged
{
get
{
if (!canBeDragged) { return false; }
if (Removed || !AnimController.Draggable) { return false; }
return IsDead || Stun > 0.0f || LockHands || IsUnconscious;
}
set { canBeDragged = value; }
}
//can other characters access the inventory of this character
private bool canInventoryBeAccessed = true;
public bool CanInventoryBeAccessed
{
get
{
if (!canInventoryBeAccessed || Removed || Inventory == null) { return false; }
if (!Inventory.AccessibleWhenAlive)
{
return IsDead;
}
else
{
return (IsDead || Stun > 0.0f || LockHands || IsUnconscious);
}
}
set { canInventoryBeAccessed = value; }
}
public override Vector2 SimPosition
{
get
@@ -1017,10 +987,6 @@ namespace Barotrauma
public Vector2? OverrideMovement { get; set; }
public bool ForceRun { get; set; }
// TODO: reposition? there's also the overrideTargetMovement variable, but it's not in the same manner
public Vector2? OverrideMovement { get; set; }
public bool ForceRun { get; set; }
public Vector2 GetTargetMovement()
{
Vector2 targetMovement = Vector2.Zero;
@@ -1069,7 +1035,24 @@ namespace Barotrauma
ResetSpeedMultiplier(); // Reset, items will set the value before the next update
return targetMovement;
//?
//currMaxSpeed *= 1.5f;
var leftFoot = AnimController.GetLimb(LimbType.LeftFoot);
if (leftFoot != null)
{
float footAfflictionStrength = CharacterHealth.GetAfflictionStrength("damage", leftFoot, true);
currMaxSpeed *= MathHelper.Lerp(1.0f, 0.25f, MathHelper.Clamp(footAfflictionStrength / 100.0f, 0.0f, 1.0f));
}
var rightFoot = AnimController.GetLimb(LimbType.RightFoot);
if (rightFoot != null)
{
float footAfflictionStrength = CharacterHealth.GetAfflictionStrength("damage", rightFoot, true);
currMaxSpeed *= MathHelper.Lerp(1.0f, 0.25f, MathHelper.Clamp(footAfflictionStrength / 100.0f, 0.0f, 1.0f));
}
return currMaxSpeed;
}
/// <summary>
@@ -2202,16 +2185,17 @@ namespace Barotrauma
#if SERVER
if (attacker is Character attackingCharacter && attackingCharacter.AIController == null)
{
string logMsg = LogName + " attacked by " + attackingCharacter.LogName + ".";
StringBuilder sb = new StringBuilder();
sb.Append(LogName + " attacked by " + attackingCharacter.LogName + ".");
if (attackResult.Afflictions != null)
{
foreach (Affliction affliction in attackResult.Afflictions)
{
if (affliction.Strength == 0.0f) continue;
logMsg += affliction.Prefab.Name + ": " + affliction.Strength;
sb.Append($" {affliction.Prefab.Name}: {affliction.Strength}");
}
}
GameServer.Log(logMsg, ServerLog.MessageType.Attack);
GameServer.Log(sb.ToString(), ServerLog.MessageType.Attack);
}
#endif
@@ -980,68 +980,6 @@ namespace Barotrauma
NewMessage("Set packet duplication to " + (int)(duplicates * 100) + "%.", Color.White);
}));
commands.Add(new Command("simulatedlatency", "simulatedlatency [minimumlatencyseconds] [randomlatencyseconds]: applies a simulated latency to network messages. Useful for simulating real network conditions when testing the multiplayer locally.", (string[] args) =>
{
if (args.Count() < 2 || (GameMain.Client == null && GameMain.Server == null)) return;
if (!float.TryParse(args[0], NumberStyles.Any, CultureInfo.InvariantCulture, out float minimumLatency))
{
ThrowError(args[0] + " is not a valid latency value.");
return;
}
if (!float.TryParse(args[0], NumberStyles.Any, CultureInfo.InvariantCulture, out float randomLatency))
{
ThrowError(args[1] + " is not a valid latency value.");
return;
}
if (GameMain.Client != null)
{
GameMain.Client.NetPeerConfiguration.SimulatedMinimumLatency = minimumLatency;
GameMain.Client.NetPeerConfiguration.SimulatedRandomLatency = randomLatency;
}
else if (GameMain.Server != null)
{
GameMain.Server.NetPeerConfiguration.SimulatedMinimumLatency = minimumLatency;
GameMain.Server.NetPeerConfiguration.SimulatedRandomLatency = randomLatency;
}
NewMessage("Set simulated minimum latency to " + minimumLatency + " and random latency to " + randomLatency + ".", Color.White);
}));
commands.Add(new Command("simulatedloss", "simulatedloss [lossratio]: applies simulated packet loss to network messages. For example, a value of 0.1 would mean 10% of the packets are dropped. Useful for simulating real network conditions when testing the multiplayer locally.", (string[] args) =>
{
if (args.Count() < 1 || (GameMain.Client == null && GameMain.Server == null)) return;
if (!float.TryParse(args[0], NumberStyles.Any, CultureInfo.InvariantCulture, out float loss))
{
ThrowError(args[0] + " is not a valid loss ratio.");
return;
}
if (GameMain.Client != null)
{
GameMain.Client.NetPeerConfiguration.SimulatedLoss = loss;
}
else if (GameMain.Server != null)
{
GameMain.Server.NetPeerConfiguration.SimulatedLoss = loss;
}
NewMessage("Set simulated packet loss to " + (int)(loss * 100) + "%.", Color.White);
}));
commands.Add(new Command("simulatedduplicateschance", "simulatedduplicateschance [duplicateratio]: simulates packet duplication in network messages. For example, a value of 0.1 would mean there's a 10% chance a packet gets sent twice. Useful for simulating real network conditions when testing the multiplayer locally.", (string[] args) =>
{
if (args.Count() < 1 || (GameMain.Client == null && GameMain.Server == null)) return;
if (!float.TryParse(args[0], NumberStyles.Any, CultureInfo.InvariantCulture, out float duplicates))
{
ThrowError(args[0] + " is not a valid duplicate ratio.");
return;
}
if (GameMain.Client != null)
{
GameMain.Client.NetPeerConfiguration.SimulatedDuplicatesChance = duplicates;
}
else if (GameMain.Server != null)
{
GameMain.Server.NetPeerConfiguration.SimulatedDuplicatesChance = duplicates;
}
NewMessage("Set packet duplication to " + (int)(duplicates * 100) + "%.", Color.White);
}));
commands.Add(new Command("flipx", "flipx: mirror the main submarine horizontally", (string[] args) =>
{
Submarine.MainSub?.FlipX();
@@ -116,11 +116,6 @@ namespace Barotrauma
}
}
if (GameMain.Server.Character != null)
{
c.Inventory?.DeleteAllItems();
}
//remove all items that are in someone's inventory
foreach (Character c in Character.CharacterList)
{
@@ -45,6 +45,12 @@ namespace Barotrauma
public bool SpecularityEnabled { get; set; }
public bool ChromaticAberrationEnabled { get; set; }
public int ParticleLimit { get; set; }
public float LightMapScale { get; set; }
public bool SpecularityEnabled { get; set; }
public bool ChromaticAberrationEnabled { get; set; }
public bool MuteOnFocusLost { get; set; }
public enum VoiceMode
@@ -304,11 +310,6 @@ namespace Barotrauma
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false);
#if DEBUG
UseSteam = doc.Root.GetAttributeBool("usesteam", true);
#endif
QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", "");
#if DEBUG
UseSteam = doc.Root.GetAttributeBool("usesteam", true);
#endif
@@ -376,6 +377,8 @@ namespace Barotrauma
AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", 0.5f);
AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", 0.5f);
AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", 0.5f);
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
@@ -519,6 +522,34 @@ namespace Barotrauma
TextManager.LoadTextPacks(SelectedContentPackages);
//display error messages after all content packages have been loaded
//to make sure the package that contains text files has been loaded before we attempt to use TextManager
foreach (string missingPackagePath in missingPackagePaths)
{
DebugConsole.ThrowError(TextManager.Get("ContentPackageNotFound").Replace("[packagepath]", missingPackagePath));
}
foreach (ContentPackage incompatiblePackage in incompatiblePackages)
{
DebugConsole.ThrowError(TextManager.Get(incompatiblePackage.GameVersion <= new Version(0, 0, 0, 0) ? "IncompatibleContentPackageUnknownVersion" : "IncompatibleContentPackage")
.Replace("[packagename]", incompatiblePackage.Name)
.Replace("[packageversion]", incompatiblePackage.GameVersion.ToString())
.Replace("[gameversion]", GameMain.Version.ToString()));
}
foreach (ContentPackage contentPackage in SelectedContentPackages)
{
foreach (ContentFile file in contentPackage.Files)
{
if (!System.IO.File.Exists(file.Path))
{
DebugConsole.ThrowError("Error in content package \"" + contentPackage.Name + "\" - file \"" + file.Path + "\" not found.");
continue;
}
ToolBox.IsProperFilenameCase(file.Path);
}
}
TextManager.LoadTextPacks(SelectedContentPackages);
//display error messages after all content packages have been loaded
//to make sure the package that contains text files has been loaded before we attempt to use TextManager
foreach (string missingPackagePath in missingPackagePaths)
@@ -1071,6 +1102,32 @@ namespace Barotrauma
NewLineOnAttributes = true
};
#if CLIENT
if (Tutorial.Tutorials != null)
{
foreach (Tutorial tutorial in Tutorial.Tutorials)
{
if (tutorial.Completed && !CompletedTutorialNames.Contains(tutorial.Name))
{
CompletedTutorialNames.Add(tutorial.Name);
}
}
}
#endif
var tutorialElement = new XElement("tutorials");
foreach (string tutorialName in CompletedTutorialNames)
{
tutorialElement.Add(new XElement("Tutorial", new XAttribute("name", tutorialName)));
}
doc.Root.Add(tutorialElement);
XmlWriterSettings settings = new XmlWriterSettings
{
Indent = true,
OmitXmlDeclaration = true,
NewLineOnAttributes = true
};
#if CLIENT
if (Tutorial.Tutorials != null)
{
@@ -24,9 +24,6 @@ namespace Barotrauma.Items.Components
private bool createdNewGap;
private bool autoOrientGap;
private bool createdNewGap;
private bool autoOrientGap;
private bool isStuck;
private float resetPredictionTimer;
@@ -252,10 +252,6 @@ namespace Barotrauma.Items.Components
}
partial void FixStructureProjSpecific(Character user, float deltaTime, Structure targetStructure, int sectionIndex);
partial void FixCharacterProjSpecific(Character user, float deltaTime, Character targetCharacter);
partial void FixItemProjSpecific(Character user, float deltaTime, Item targetItem, float prevCondition);
partial void FixStructureProjSpecific(Character user, float deltaTime, Structure targetStructure, int sectionIndex);
partial void FixCharacterProjSpecific(Character user, float deltaTime, Character targetCharacter);
partial void FixItemProjSpecific(Character user, float deltaTime, Item targetItem, float prevCondition);
@@ -187,6 +187,24 @@ namespace Barotrauma.Items.Components
return base.Select(character);
}
public override bool Select(Character character)
{
if (item.Container != null) { return false; }
if (AutoInteractWithContained)
{
foreach (Item contained in Inventory.Items)
{
if (contained == null) continue;
if (contained.TryInteract(character))
{
return false;
}
}
}
return base.Select(character);
}
public override bool Pick(Character picker)
{
if (AutoInteractWithContained)
@@ -105,6 +105,8 @@ namespace Barotrauma.Items.Components
progressTimer = 0.0f;
}
}
voltage -= deltaTime * 10.0f;
}
private void PutItemsToLinkedContainer()
@@ -162,8 +164,6 @@ namespace Barotrauma.Items.Components
if (!IsActive) { progressState = 0.0f; }
if (!IsActive) { progressState = 0.0f; }
#if CLIENT
if (!IsActive)
{
@@ -493,7 +493,6 @@ namespace Barotrauma.Items.Components
AutoTemp = false;
unsentChanges = true;
UpdateAutoTemp(2.0f + degreeOfSuccess * 5.0f, 1.0f);
}
#if CLIENT
onOffSwitch.BarScroll = 0.0f;
@@ -505,6 +504,11 @@ namespace Barotrauma.Items.Components
#if CLIENT
onOffSwitch.BarScroll = 1.0f;
#endif
if (AutoTemp || !shutDown || targetFissionRate > 0.0f || targetTurbineOutput > 0.0f)
{
unsentChanges = true;
}
AutoTemp = false;
shutDown = true;
targetFissionRate = 0.0f;
@@ -32,11 +32,6 @@ namespace Barotrauma.Items.Components
//a list of powered devices connected directly to this item
private readonly List<Pair<Powered, Connection>> directlyConnected = new List<Pair<Powered, Connection>>(10);
//charge indicator description
protected Vector2 indicatorPosition, indicatorSize;
protected bool isHorizontal;
public float CurrPowerOutput
{
get;
@@ -178,9 +178,6 @@ namespace Barotrauma.Items.Components
//items in a bad condition are more sensitive to overvoltage
float maxOverVoltage = MathHelper.Lerp(Math.Min(OverloadVoltage, 1.0f), OverloadVoltage, item.Condition / item.Prefab.Health);
//items in a bad condition are more sensitive to overvoltage
float maxOverVoltage = MathHelper.Lerp(Math.Min(OverloadVoltage, 1.0f), OverloadVoltage, item.Condition / 100.0f);
//if the item can't be fixed, don't allow it to break
if (!item.Repairables.Any() || !CanBeOverloaded) continue;
@@ -54,7 +54,7 @@ namespace Barotrauma
private LocationType(XElement element)
{
Identifier = element.Name.ToString();
Identifier = element.GetAttributeString("identifier", element.Name.ToString());
Name = TextManager.Get("LocationName." + Identifier);
nameFormats = TextManager.GetAll("LocationNameFormat." + Identifier);
@@ -65,7 +65,7 @@ namespace Barotrauma
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to read name file for location type \""+Identifier+"\"!", e);
DebugConsole.ThrowError("Failed to read name file for location type \"" + Identifier + "\"!", e);
names = new List<string>() { "Name file not found" };
}
@@ -82,9 +82,7 @@ namespace Barotrauma
}
CommonnessPerZone[zoneIndex] = zoneCommonness;
}
string nameFile = element.GetAttributeString("namefile", "Content/Map/locationNames.txt");
try
catch (Exception e)
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -430,6 +430,13 @@ namespace Barotrauma
}
CurrentLocation.SelectedMissionIndex = missionIndex;
//the destination must be the same as the destination of the mission
if (CurrentLocation.SelectedMission != null &&
CurrentLocation.SelectedMission.Locations[1] != SelectedLocation)
{
SelectLocation(CurrentLocation.SelectedMission.Locations[1]);
}
SelectedLocation = location;
SelectedConnection = connections.Find(c => c.Locations.Contains(CurrentLocation) && c.Locations.Contains(SelectedLocation));
OnLocationSelected?.Invoke(SelectedLocation, SelectedConnection);
@@ -518,6 +518,10 @@ namespace Barotrauma
{
maxX = Math.Min(maxX, ruin.Area.X - 100.0f);
}
else
{
maxX = Math.Min(maxX, ruin.Area.X - 100.0f);
}
if (entity.IsVisible(worldView)) { visibleEntities.Add(entity); }
}
@@ -40,16 +40,19 @@ namespace Barotrauma.Networking
{
get
{
if (!Type.HasFlag(ChatMessageType.Server | ChatMessageType.Error))
if (Type.HasFlag(ChatMessageType.Server) || Type.HasFlag(ChatMessageType.Error) || Type.HasFlag(ChatMessageType.ServerLog))
{
if (translatedText == null || translatedText.Length == 0)
{
translatedText = TextManager.GetServerMessage(Text);
}
return translatedText;
}
else
{
return Text;
}
if (translatedText == null || translatedText.Length == 0)
{
translatedText = TextManager.GetServerMessage(Text);
}
return translatedText;
}
}
@@ -72,8 +72,6 @@ namespace Barotrauma.Networking
public HashSet<string> GivenAchievements = new HashSet<string>();
public HashSet<string> GivenAchievements = new HashSet<string>();
public ClientPermissions Permissions = ClientPermissions.None;
public List<DebugConsole.Command> PermittedConsoleCommands
{
@@ -15,7 +15,7 @@ namespace Barotrauma.Networking
public LogMessage(string text, MessageType type)
{
Text = "[" + DateTime.Now.ToString() + "] " + text;
Text = "[" + DateTime.Now.ToString() + "] " + TextManager.GetServerMessage(text);
Type = type;
}
}
@@ -145,6 +145,16 @@ namespace Barotrauma
get { return binding; }
}
public void SetState()
{
hit = binding.IsHit();
if (hit) hitQueue = true;
held = binding.IsDown();
if (held) heldQueue = true;
}
#endif
public void SetState()
{
hit = binding.IsHit();
@@ -82,33 +82,6 @@ namespace Barotrauma
#endif
}
public void SetBotCount(int botCount)
{
if (GameMain.Server != null)
{
if (botCount < 0) botCount = GameMain.Server.MaxBotCount;
if (botCount > GameMain.Server.MaxBotCount) botCount = 0;
GameMain.Server.BotCount = botCount;
lastUpdateID++;
}
#if CLIENT
(botCountText as GUITextBlock).Text = botCount.ToString();
#endif
}
public void SetBotSpawnMode(BotSpawnMode botSpawnMode)
{
if (GameMain.Server != null)
{
GameMain.Server.BotSpawnMode = botSpawnMode;
lastUpdateID++;
}
#if CLIENT
(botSpawnModeText as GUITextBlock).Text = botSpawnMode.ToString();
#endif
}
public void SetTraitorsEnabled(YesNoMaybe enabled)
{
#if SERVER
@@ -89,11 +89,6 @@ namespace Barotrauma
public readonly AttributeCollection Attributes;
public readonly Type PropertyType;
public object ParentObject
{
get { return obj; }
}
public SerializableProperty(PropertyDescriptor property, object obj)
{
Name = property.Name;
@@ -187,9 +182,6 @@ namespace Barotrauma
case "point":
propertyInfo.SetValue(parentObject, XMLExtensions.ParsePoint(value));
break;
case "point":
propertyInfo.SetValue(obj, XMLExtensions.ParsePoint(value));
break;
case "vector2":
propertyInfo.SetValue(parentObject, XMLExtensions.ParseVector2(value));
break;
@@ -262,9 +254,6 @@ namespace Barotrauma
case "point":
propertyInfo.SetValue(parentObject, XMLExtensions.ParsePoint((string)value));
return true;
case "point":
propertyInfo.SetValue(obj, XMLExtensions.ParsePoint((string)value));
return true;
case "vector2":
propertyInfo.SetValue(parentObject, XMLExtensions.ParseVector2((string)value));
return true;
@@ -486,38 +486,8 @@ namespace Barotrauma
protected bool IsValidTarget(ISerializableEntity entity)
{
if (entity is Item item)
{
if (item.HasTag(targetIdentifiers)) return true;
if (targetIdentifiers.Any(id => id == item.Prefab.Identifier)) return true;
}
else if (entity is ItemComponent itemComponent)
{
if (itemComponent.Item.HasTag(targetIdentifiers)) return true;
if (targetIdentifiers.Any(id => id == itemComponent.Item.Prefab.Identifier)) return true;
}
else if (entity is Structure structure)
{
if (targetIdentifiers.Any(id => id == structure.Prefab.Identifier)) return true;
}
else if (entity is Character character)
{
if (targetIdentifiers.Any(id => id == character.SpeciesName)) return true;
}
if (targetIdentifiers == null) { return true; }
return targetIdentifiers.Any(id => id == entity.Name);
}
public void SetUser(Character user)
{
foreach (Affliction affliction in Afflictions)
{
affliction.Source = user;
}
}
protected bool IsValidTarget(ISerializableEntity entity)
{
if (entity is Item item)
{
if (item.HasTag(targetIdentifiers)) return true;
@@ -744,6 +714,11 @@ namespace Barotrauma
}
}
}
bool isNotClient = true;
#if CLIENT
isNotClient = GameMain.Client == null;
#endif
if (FireSize > 0.0f && entity != null)
{
@@ -812,62 +787,6 @@ namespace Barotrauma
}
}
if (GameMain.Client == null && entity != null && Entity.Spawner != null) //clients are not allowed to spawn items
{
foreach (ItemSpawnInfo itemSpawnInfo in spawnItems)
{
switch (itemSpawnInfo.SpawnPosition)
{
case ItemSpawnInfo.SpawnPositionType.This:
Entity.Spawner.AddToSpawnQueue(itemSpawnInfo.ItemPrefab, entity.WorldPosition);
break;
case ItemSpawnInfo.SpawnPositionType.ThisInventory:
{
if (entity is Character character)
{
if (character.Inventory != null && character.Inventory.Items.Any(it => it == null))
{
Entity.Spawner.AddToSpawnQueue(itemSpawnInfo.ItemPrefab, character.Inventory);
}
}
else if (entity is Item item)
{
var inventory = item?.GetComponent<ItemContainer>()?.Inventory;
if (inventory != null && inventory.Items.Any(it => it == null))
{
Entity.Spawner.AddToSpawnQueue(itemSpawnInfo.ItemPrefab, inventory);
}
}
}
break;
case ItemSpawnInfo.SpawnPositionType.ContainedInventory:
{
Inventory thisInventory = null;
if (entity is Character character)
{
thisInventory = character.Inventory;
}
else if (entity is Item item)
{
thisInventory = item?.GetComponent<ItemContainer>()?.Inventory;
}
if (thisInventory != null)
{
foreach (Item item in thisInventory.Items)
{
if (item == null) continue;
Inventory containedInventory = item.GetComponent<ItemContainer>()?.Inventory;
if (containedInventory == null || !containedInventory.Items.Any(i => i == null)) continue;
Entity.Spawner.AddToSpawnQueue(itemSpawnInfo.ItemPrefab, containedInventory);
break;
}
}
}
break;
}
}
}
#if CLIENT
if (entity != null)
{
@@ -983,30 +902,6 @@ namespace Barotrauma
limb.character.CharacterHealth.ReduceAffliction(limb, reduceAffliction.First, reduceAffliction.Second * deltaTime);
}
}
foreach (Affliction affliction in element.Parent.Afflictions)
{
if (target is Character)
{
((Character)target).CharacterHealth.ApplyAffliction(null, affliction.CreateMultiplied(deltaTime));
}
else if (target is Limb limb)
{
limb.character.CharacterHealth.ApplyAffliction(limb, affliction.CreateMultiplied(deltaTime));
}
}
foreach (Pair<string, float> reduceAffliction in element.Parent.ReduceAffliction)
{
if (target is Character)
{
((Character)target).CharacterHealth.ReduceAffliction(null, reduceAffliction.First, reduceAffliction.Second * deltaTime);
}
else if (target is Limb limb)
{
limb.character.CharacterHealth.ReduceAffliction(limb, reduceAffliction.First, reduceAffliction.Second * deltaTime);
}
}
}
element.Timer -= deltaTime;
@@ -155,18 +155,29 @@ namespace Barotrauma
{
if (!messages[i].Contains("_")) // No variables, just translate
{
messages[i] = Get(messages[i]);
continue;
string msg = Get(messages[i], true);
if (msg != null) // If a translation was found, otherwise use the original
{
messages[i] = msg;
}
}
string[] messageWithVariables = messages[i].Split('_');
messages[i] = Get(messageWithVariables[0]);
// First index is always the message identifier -> start at 1
for (int j = 1; j < messageWithVariables.Length; j++)
else
{
string[] variableAndValue = messageWithVariables[j].Split('=');
messages[i] = messages[i].Replace(variableAndValue[0], variableAndValue[1]);
string[] messageWithVariables = messages[i].Split('_');
string msg = Get(messageWithVariables[0], true);
if (msg != null) // If a translation was found, otherwise use the original
{
messages[i] = msg;
}
// First index is always the message identifier -> start at 1
for (int j = 1; j < messageWithVariables.Length; j++)
{
string[] variableAndValue = messageWithVariables[j].Split('=');
messages[i] = messages[i].Replace(variableAndValue[0], variableAndValue[1]);
}
}
}
@@ -39,12 +39,6 @@ namespace Barotrauma
return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).NextDouble() * (maximum - minimum) + minimum;
}
public static double Range(double minimum, double maximum, RandSync sync = RandSync.Unsynced)
{
Assert(sync);
return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).NextDouble() * (maximum - minimum) + minimum;
}
public static int Range(int minimum, int maximum, RandSync sync = RandSync.Unsynced)
{
return (sync == RandSync.Unsynced ? localRandom : (syncedRandom[(int)sync])).Next(maximum - minimum) + minimum;