(eba811de) Unstable 0.9.703.0

This commit is contained in:
Juan Pablo Arce
2020-02-04 11:54:57 -03:00
parent 15499cb704
commit 08ab6185c4
100 changed files with 2162 additions and 1520 deletions
@@ -296,14 +296,14 @@ namespace Barotrauma
}
float multiplier = MathHelper.Lerp(1, 10, MathHelper.Clamp(collider.LinearVelocity.Length() / 10, 0, 1));
float targetDistance = collider.GetSize().X * multiplier;
float horizontalDistance = Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X);
float verticalDistance = Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y);
float horizontalDistance = Math.Abs(character.WorldPosition.X - currentPath.CurrentNode.WorldPosition.X);
float verticalDistance = Math.Abs(character.WorldPosition.Y - currentPath.CurrentNode.WorldPosition.Y);
if (character.CurrentHull != currentPath.CurrentNode.CurrentHull)
{
verticalDistance *= 2;
}
float distance = horizontalDistance + verticalDistance;
if (distance < targetDistance)
if (ConvertUnits.ToSimUnits(distance) < targetDistance)
{
currentPath.SkipToNextNode();
}
@@ -74,6 +74,8 @@ namespace Barotrauma
public readonly Dictionary<string, Sprite> OptionSprites;
public readonly float Weight;
static Order()
{
Prefabs = new Dictionary<string, Order>();
@@ -172,6 +174,9 @@ namespace Barotrauma
PrefabList = new List<Order>(Prefabs.Values);
}
/// <summary>
/// Constructor for order prefabs
/// </summary>
private Order(XElement orderElement)
{
Identifier = orderElement.GetAttributeString("identifier", "");
@@ -199,6 +204,7 @@ namespace Barotrauma
AppropriateJobs = orderElement.GetAttributeStringArray("appropriatejobs", new string[0]);
Options = orderElement.GetAttributeStringArray("options", new string[0]);
Category = (OrderCategory)Enum.Parse(typeof(OrderCategory), orderElement.GetAttributeString("category", "undefined"), true);
Weight = orderElement.GetAttributeFloat(0.0f, "weight");
string translatedOptionNames = TextManager.Get("OrderOptions." + Identifier, true);
if (translatedOptionNames == null)
@@ -243,6 +249,9 @@ namespace Barotrauma
}
}
/// <summary>
/// Constructor for order instances
/// </summary>
public Order(Order prefab, Entity targetEntity, ItemComponent targetItem, Character orderGiver = null)
{
Prefab = prefab;
@@ -257,6 +266,7 @@ namespace Barotrauma
TargetAllCharacters = prefab.TargetAllCharacters;
AppropriateJobs = prefab.AppropriateJobs;
FadeOutTime = prefab.FadeOutTime;
Weight = prefab.Weight;
OrderGiver = orderGiver;
TargetEntity = targetEntity;
@@ -1407,7 +1407,7 @@ namespace Barotrauma
target.CharacterHealth.CalculateVitality();
if (wasCritical && target.Vitality > 0.0f && Timing.TotalTime > lastReviveTime + 10.0f)
{
character.Info.IncreaseSkillLevel("medical", 0.5f, character.WorldPosition + Vector2.UnitY * 150.0f);
character.Info.IncreaseSkillLevel("medical", SkillSettings.Current.SkillIncreasePerCprRevive, character.WorldPosition + Vector2.UnitY * 150.0f);
SteamAchievementManager.OnCharacterRevived(target, character);
lastReviveTime = (float)Timing.TotalTime;
#if SERVER
@@ -138,6 +138,8 @@ namespace Barotrauma
private readonly List<StatusEffect> statusEffects = new List<StatusEffect>();
private readonly List<float> speedMultipliers = new List<float>();
private float greatestNegativeSpeedMultiplier = 1f;
private float greatestPositiveSpeedMultiplier = 1f;
public Entity ViewTarget
{
@@ -1069,42 +1071,32 @@ namespace Barotrauma
{
get
{
if (speedMultipliers.Count == 0) return 1f;
float greatestPositive = 1f;
float greatestNegative = 1f;
for (int i = 0; i < speedMultipliers.Count; i++)
{
float val = speedMultipliers[i];
if (val < 1f)
{
if (val < greatestNegative)
{
greatestNegative = val;
}
}
else
{
if (val > greatestPositive)
{
greatestPositive = val;
}
}
}
return greatestPositive - (1f - greatestNegative);
return greatestPositiveSpeedMultiplier - (1f - greatestNegativeSpeedMultiplier);
}
set
}
public void StackSpeedMultiplier(float val)
{
if (val < 1f)
{
if (value == 1f) return;
speedMultipliers.Add(value);
if (val < greatestNegativeSpeedMultiplier)
{
greatestNegativeSpeedMultiplier = val;
}
}
else
{
if (val > greatestPositiveSpeedMultiplier)
{
greatestPositiveSpeedMultiplier = val;
}
}
}
public void ResetSpeedMultiplier()
{
speedMultipliers.Clear();
greatestPositiveSpeedMultiplier = 1f;
greatestNegativeSpeedMultiplier = 1f;
}
public float ApplyTemporarySpeedLimits(float speed)
@@ -1440,6 +1432,7 @@ namespace Barotrauma
public bool HasEquippedItem(Item item)
{
if (Inventory == null) { return false; }
for (int i = 0; i < Inventory.Capacity; i++)
{
if (Inventory.Items[i] == item && Inventory.SlotTypes[i] != InvSlotType.Any) return true;
@@ -2339,15 +2332,16 @@ namespace Barotrauma
}
private readonly List<AIChatMessage> aiChatMessageQueue = new List<AIChatMessage>();
private readonly List<AIChatMessage> prevAiChatMessages = new List<AIChatMessage>();
//key = identifier, value = time the message was sent
private readonly Dictionary<string, float> prevAiChatMessages = new Dictionary<string, float>();
public void DisableLine(string identifier)
{
var dummyMsg = new AIChatMessage("", ChatMessageType.Default, identifier)
if (!string.IsNullOrEmpty(identifier))
{
SendTime = Timing.TotalTime
};
prevAiChatMessages.Add(dummyMsg);
prevAiChatMessages[identifier] = (float)Timing.TotalTime;
}
}
public void Speak(string message, ChatMessageType? messageType = null, float delay = 0.0f, string identifier = "", float minDurationBetweenSimilar = 0.0f)
@@ -2355,10 +2349,15 @@ namespace Barotrauma
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
if (string.IsNullOrEmpty(message)) { return; }
if (prevAiChatMessages.ContainsKey(identifier) &&
prevAiChatMessages[identifier] < Timing.TotalTime - minDurationBetweenSimilar)
{
prevAiChatMessages.Remove(identifier);
}
//already sent a similar message a moment ago
if (!string.IsNullOrEmpty(identifier) && minDurationBetweenSimilar > 0.0f &&
(aiChatMessageQueue.Any(m => m.Identifier == identifier) ||
prevAiChatMessages.Any(m => m.Identifier == identifier && m.SendTime > Timing.TotalTime - minDurationBetweenSimilar)))
(aiChatMessageQueue.Any(m => m.Identifier == identifier) || prevAiChatMessages.ContainsKey(identifier)))
{
return;
}
@@ -2403,15 +2402,25 @@ namespace Barotrauma
{
sent.SendTime = Timing.TotalTime;
aiChatMessageQueue.Remove(sent);
prevAiChatMessages.Add(sent);
if (!string.IsNullOrEmpty(sent.Identifier))
{
prevAiChatMessages[sent.Identifier] = (float)sent.SendTime;
}
}
for (int i = prevAiChatMessages.Count - 1; i >= 0; i--)
if (prevAiChatMessages.Count > 100)
{
if (prevAiChatMessages[i].SendTime < Timing.TotalTime - 60.0f)
List<string> toRemove = new List<string>();
foreach (KeyValuePair<string,float> prevMessage in prevAiChatMessages)
{
prevAiChatMessages.RemoveRange(0, i + 1);
break;
if (prevMessage.Value < Timing.TotalTime - 60.0f)
{
toRemove.Add(prevMessage.Key);
}
}
foreach (string identifier in toRemove)
{
prevAiChatMessages.Remove(identifier);
}
}
}
@@ -619,7 +619,7 @@ namespace Barotrauma
{
UpdateBleedingProjSpecific((AfflictionBleeding)affliction, targetLimb, deltaTime);
}
Character.SpeedMultiplier = affliction.GetSpeedMultiplier();
Character.StackSpeedMultiplier(affliction.GetSpeedMultiplier());
}
}
@@ -638,7 +638,7 @@ namespace Barotrauma
var affliction = afflictions[i];
affliction.Update(this, null, deltaTime);
affliction.DamagePerSecondTimer += deltaTime;
Character.SpeedMultiplier = affliction.GetSpeedMultiplier();
Character.StackSpeedMultiplier(affliction.GetSpeedMultiplier());
}
UpdateLimbAfflictionOverlays();
@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Barotrauma
{
class SkillSettings : ISerializableEntity
{
public static SkillSettings Current
{
get;
private set;
}
[Serialize(4.0f, true)]
public float SingleRoundSkillGainMultiplier { get; set; }
private float skillIncreasePerRepair;
[Serialize(5.0f, true)]
public float SkillIncreasePerRepair
{
get { return skillIncreasePerRepair * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerRepair = value; }
}
private float skillIncreasePerSabotage;
[Serialize(3.0f, true)]
public float SkillIncreasePerSabotage
{
get { return skillIncreasePerSabotage * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerSabotage = value; }
}
private float skillIncreasePerCprRevive;
[Serialize(0.5f, true)]
public float SkillIncreasePerCprRevive
{
get { return skillIncreasePerCprRevive * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerCprRevive = value; }
}
private float skillIncreasePerRepairedStructureDamage;
[Serialize(0.005f, true)]
public float SkillIncreasePerRepairedStructureDamage
{
get { return skillIncreasePerRepairedStructureDamage * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerRepairedStructureDamage = value; }
}
private float skillIncreasePerSecondWhenSteering;
[Serialize(0.005f, true)]
public float SkillIncreasePerSecondWhenSteering
{
get { return skillIncreasePerSecondWhenSteering * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerSecondWhenSteering = value; }
}
private float skillIncreasePerFabricatorRequiredSkill;
[Serialize(0.5f, true)]
public float SkillIncreasePerFabricatorRequiredSkill
{
get { return skillIncreasePerFabricatorRequiredSkill * GetCurrentSkillGainMultiplier(); }
set { skillIncreasePerFabricatorRequiredSkill = value; }
}
private SkillSettings(XElement element)
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
}
public string Name => "SkillSettings";
public Dictionary<string, SerializableProperty> SerializableProperties
{
get;
set;
}
public static void Load(IEnumerable<ContentFile> files)
{
//reverse order to respect content package load order (last file overrides others)
foreach (ContentFile file in files.Reverse())
{
if (file.Type != ContentType.SkillSettings)
{
throw new ArgumentException();
}
XDocument doc = XMLExtensions.TryLoadXml(file.Path);
if (doc == null) { continue; }
Current = new SkillSettings(doc.Root);
break;
}
if (Current == null)
{
DebugConsole.NewMessage("Now skill settings found in the selected content packages. Using default values.");
Current = new SkillSettings(null);
}
}
private float GetCurrentSkillGainMultiplier()
{
if (GameMain.GameSession?.GameMode is CampaignMode)
{
return 1.0f;
}
else
{
return SingleRoundSkillGainMultiplier;
}
}
}
}
@@ -38,7 +38,8 @@ namespace Barotrauma
UIStyle,
TraitorMissions,
EventManagerSettings,
Orders
Orders,
SkillSettings
}
public class ContentPackage
@@ -290,11 +290,41 @@ namespace Barotrauma
commands.Add(new Command("startwhenclientsready", "startwhenclientsready [true/false]: Enable or disable automatically starting the round when clients are ready to start.", null));
commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", null));
commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", null,
() =>
{
if (GameMain.NetworkMember == null) return null;
commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", null));
return new string[][]
{
GameMain.NetworkMember.ConnectedClients.Select(c => c.Name).ToArray(),
Enum.GetValues(typeof(ClientPermissions)).Cast<ClientPermissions>().Select(v => v.ToString()).ToArray()
};
}));
commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", null,
() =>
{
if (GameMain.NetworkMember == null) return null;
return new string[][]
{
GameMain.NetworkMember.ConnectedClients.Select(c => c.Name).ToArray(),
Enum.GetValues(typeof(ClientPermissions)).Cast<ClientPermissions>().Select(v => v.ToString()).ToArray()
};
}));
commands.Add(new Command("giverank", "giverank [id]: Assigns a specific rank (= a set of administrative permissions) to the player with the specified client ID.", null));
commands.Add(new Command("giverank", "giverank [id]: Assigns a specific rank (= a set of administrative permissions) to the player with the specified client ID.", null,
() =>
{
if (GameMain.NetworkMember == null) return null;
return new string[][]
{
GameMain.NetworkMember.ConnectedClients.Select(c => c.Name).ToArray(),
PermissionPreset.List.Select(pp => pp.Name).ToArray()
};
}));
commands.Add(new Command("givecommandperm", "givecommandperm [id]: Gives the player with the specified client ID the permission to use the specified console commands.", null));
@@ -823,6 +853,7 @@ namespace Barotrauma
var reactor = reactorItem.GetComponent<Reactor>();
reactor.TurbineOutput = power / reactor.MaxPowerOutput * 100.0f;
reactor.FissionRate = power / reactor.MaxPowerOutput * 100.0f;
reactor.PowerOn = true;
reactor.AutoTemp = true;
#if SERVER
@@ -1514,8 +1545,13 @@ namespace Barotrauma
}
}
public static void ShowQuestionPrompt(string question, QuestionCallback onAnswered)
public static void ShowQuestionPrompt(string question, QuestionCallback onAnswered, string[] args = null, int argCount = -1)
{
if (args != null && args.Length > argCount)
{
onAnswered(args[argCount]);
}
#if CLIENT
activeQuestionText = new GUITextBlock(new RectTransform(new Point(listBox.Content.Rect.Width, 0), listBox.Content.RectTransform),
" >>" + question, font: GUI.SmallFont, wrap: true)
@@ -77,6 +77,12 @@ namespace Barotrauma
Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out Vector2 spawnPos);
bool isClient = IsClient;
if (monsters.Count > 0)
{
throw new Exception($"monsters.Count > 0 ({monsters.Count})");
}
if (!string.IsNullOrEmpty(monsterFile))
{
for (int i = 0; i < monsterCount; i++)
@@ -92,12 +98,22 @@ namespace Barotrauma
}
}
if (tempSonarPositions.Count > 0)
{
throw new Exception($"tempSonarPositions.Count > 0 ({tempSonarPositions.Count})");
}
monsters.ForEach(m => m.Enabled = false);
SwarmBehavior.CreateSwarm(monsters.Cast<AICharacter>());
for (int i = 0; i < monsters.Count; i++)
{
tempSonarPositions.Add(spawnPos + Rand.Vector(maxSonarMarkerDistance));
}
if (monsters.Count != tempSonarPositions.Count)
{
throw new Exception($"monsters.Count != tempSonarPositions.Count ({monsters.Count} != {tempSonarPositions.Count})");
}
}
public override void Update(float deltaTime)
@@ -108,6 +124,16 @@ namespace Barotrauma
//keep sonar markers within maxSonarMarkerDistance from the monster(s)
for (int i = 0; i < tempSonarPositions.Count; i++)
{
if (monsters.Count != tempSonarPositions.Count)
{
throw new Exception($"monsters.Count != tempSonarPositions.Count ({monsters.Count} != {tempSonarPositions.Count})");
}
if (i < 0 || i >= monsters.Count)
{
throw new Exception($"Index {i} outside of bounds 0-{monsters.Count} ({tempSonarPositions.Count})");
}
if (monsters[i].Removed || monsters[i].IsDead) { continue; }
Vector2 diff = tempSonarPositions[i] - monsters[i].Position;
@@ -148,8 +174,10 @@ namespace Barotrauma
public override void End()
{
tempSonarPositions.Clear();
monsters.Clear();
if (State < 1) { return; }
GiveReward();
completed = true;
}
@@ -39,7 +39,7 @@ namespace Barotrauma
private ScriptedEventSet(XElement element, string debugIdentifier)
{
DebugIdentifier = debugIdentifier;
DebugIdentifier = element.GetAttributeString("identifier", null) ?? debugIdentifier;
Commonness = new Dictionary<string, float>();
EventPrefabs = new List<ScriptedEventPrefab>();
ChildSets = new List<ScriptedEventSet>();
@@ -72,7 +72,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
if (powerConsumption <= 0.0f) { Voltage = 1.0f; }
progressTimer += deltaTime * Voltage;
progressTimer += deltaTime * Math.Min(Voltage, 1.0f);
var targetItem = inputContainer.Inventory.Items.LastOrDefault(i => i != null);
if (targetItem == null) { return; }
@@ -10,8 +10,6 @@ namespace Barotrauma.Items.Components
partial class Fabricator : Powered, IServerSerializable, IClientSerializable
{
public const float SkillIncreaseMultiplier = 0.5f;
private readonly List<FabricationRecipe> fabricationRecipes = new List<FabricationRecipe>();
private FabricationRecipe fabricatedItem;
@@ -130,13 +128,6 @@ namespace Barotrauma.Items.Components
if (selectedItem == null) return;
if (!outputContainer.Inventory.IsEmpty()) return;
#if SERVER
if (user != null)
{
GameServer.Log(user.LogName + " started fabricating " + selectedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
#endif
#if CLIENT
itemList.Enabled = false;
activateButton.Text = TextManager.Get("FabricatorCancel");
@@ -155,20 +146,19 @@ namespace Barotrauma.Items.Components
currPowerConsumption = powerConsumption;
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
#if SERVER
if (user != null)
{
GameServer.Log(user.LogName + " started fabricating " + selectedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
item.CreateServerEvent(this);
#endif
}
private void CancelFabricating(Character user = null)
{
#if SERVER
if (fabricatedItem != null)
{
if (user != null)
{
GameServer.Log(user.LogName + " cancelled the fabrication of " + fabricatedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
item.CreateServerEvent(this);
}
#endif
if (fabricatedItem == null) { return; }
IsActive = false;
fabricatedItem = null;
@@ -190,6 +180,13 @@ namespace Barotrauma.Items.Components
inputContainer.Inventory.Locked = false;
outputContainer.Inventory.Locked = false;
#if SERVER
if (user != null)
{
GameServer.Log(user.LogName + " cancelled the fabrication of " + fabricatedItem.DisplayName + " in " + item.Name, ServerLog.MessageType.ItemInteraction);
}
item.CreateServerEvent(this);
#endif
}
public override void Update(float deltaTime, Camera cam)
@@ -215,7 +212,7 @@ namespace Barotrauma.Items.Components
if (powerConsumption <= 0) { Voltage = 1.0f; }
timeUntilReady -= deltaTime * Voltage;
timeUntilReady -= deltaTime * Math.Min(Voltage, 1.0f);
if (timeUntilReady > 0.0f) { return; }
@@ -254,14 +251,15 @@ namespace Barotrauma.Items.Components
{
foreach (Skill skill in fabricatedItem.RequiredSkills)
{
user.Info.IncreaseSkillLevel(skill.Identifier, skill.Level / 100.0f * SkillIncreaseMultiplier, user.WorldPosition + Vector2.UnitY * 150.0f);
float userSkill = user.GetSkillLevel(skill.Identifier);
user.Info.IncreaseSkillLevel(
skill.Identifier,
skill.Level * SkillSettings.Current.SkillIncreasePerFabricatorRequiredSkill / Math.Max(userSkill, 1.0f),
user.WorldPosition + Vector2.UnitY * 150.0f);
}
}
CancelFabricating(null);
#if SERVER
item.CreateServerEvent(this);
#endif
CancelFabricating();
}
}
@@ -43,13 +43,14 @@ namespace Barotrauma.Items.Components
private float sendUpdateTimer;
private float degreeOfSuccess;
private Vector2 optimalTemperature, allowedTemperature;
private Vector2 optimalFissionRate, allowedFissionRate;
private Vector2 optimalTurbineOutput, allowedTurbineOutput;
private bool _powerOn;
[Serialize(defaultValue: false, isSaveable: true)]
public bool PowerOn
{
get { return _powerOn; }
@@ -106,16 +106,18 @@ namespace Barotrauma.Items.Components
get => currentMode;
set
{
bool changed = currentMode != value;
currentMode = value;
if (value == Mode.Passive)
{
currentPingIndex = -1;
if (item.AiTarget != null)
{
item.AiTarget.SectorDegrees = 360.0f;
}
}
#if CLIENT
if (changed) { prevPassivePingRadius = float.MaxValue; }
UpdateGUIElements();
#endif
}
@@ -263,7 +265,7 @@ namespace Barotrauma.Items.Components
character.Speak(TextManager.GetWithVariables(dialogTag, new string[2] { "[direction]", "[count]" },
new string[2] { targetGroup.Key.ToString(), targetGroup.Value.Count.ToString() },
new bool[2] { true, false }), null, 0, "sonartarget" + targetGroup.Value[0].ID, 30);
new bool[2] { true, false }), null, 0, "sonartarget" + targetGroup.Value[0].ID, 60);
//prevent the character from reporting other targets in the group
for (int i = 1; i < targetGroup.Value.Count; i++)
@@ -277,21 +277,25 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
float userSkill = 0.0f;
if (user != null && (user.SelectedConstruction == item || item.linkedTo.Contains(user.SelectedConstruction)))
{
userSkill = user.GetSkillLevel("helm") / 100.0f;
}
if (AutoPilot)
{
UpdateAutoPilot(deltaTime);
float userSkill = 0.0f;
if (user != null && (user.SelectedConstruction == item || item.linkedTo.Contains(user.SelectedConstruction)))
{
userSkill = user.GetSkillLevel("helm") / 100.0f;
}
targetVelocity = targetVelocity.ClampLength(MathHelper.Lerp(AutoPilotMaxSpeed, AIPilotMaxSpeed, userSkill) * 100.0f);
}
else
{
if (user != null && user.Info != null && user.SelectedConstruction == item)
{
user.Info.IncreaseSkillLevel("helm", 0.005f * deltaTime, user.WorldPosition + Vector2.UnitY * 150.0f);
user.Info.IncreaseSkillLevel(
"helm",
SkillSettings.Current.SkillIncreasePerSecondWhenSteering / Math.Max(userSkill, 1.0f) * deltaTime,
user.WorldPosition + Vector2.UnitY * 150.0f);
}
Vector2 velocityDiff = steeringInput - targetVelocity;
@@ -9,9 +9,6 @@ namespace Barotrauma.Items.Components
{
partial class Repairable : ItemComponent, IServerSerializable, IClientSerializable
{
public static float SkillIncreasePerRepair = 5.0f;
public static float SkillIncreasePerSabotage = 3.0f;
private string header;
private float deteriorationTimer;
@@ -282,7 +279,7 @@ namespace Barotrauma.Items.Components
{
float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier);
CurrentFixer.Info.IncreaseSkillLevel(skill.Identifier,
SkillIncreasePerRepair / Math.Max(characterSkillLevel, 1.0f),
SkillSettings.Current.SkillIncreasePerRepair / Math.Max(characterSkillLevel, 1.0f),
CurrentFixer.WorldPosition + Vector2.UnitY * 100.0f);
}
@@ -313,7 +310,7 @@ namespace Barotrauma.Items.Components
{
float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier);
CurrentFixer.Info.IncreaseSkillLevel(skill.Identifier,
SkillIncreasePerSabotage / Math.Max(characterSkillLevel, 1.0f),
SkillSettings.Current.SkillIncreasePerSabotage / Math.Max(characterSkillLevel, 1.0f),
CurrentFixer.WorldPosition + Vector2.UnitY * 100.0f);
}
@@ -83,8 +83,14 @@ namespace Barotrauma.Items.Components
public bool CanReceive(WifiComponent sender)
{
if (sender == null || sender.channel != channel) { return false; }
if (sender.TeamID == Character.TeamType.Team1 && TeamID == Character.TeamType.Team2) { return false; }
if (sender.TeamID == Character.TeamType.Team2 && TeamID == Character.TeamType.Team1) { return false; }
if (sender.TeamID != Character.TeamType.None && TeamID != Character.TeamType.None)
{
if (sender.TeamID != TeamID)
{
return false;
}
}
if (Vector2.DistanceSquared(item.WorldPosition, sender.item.WorldPosition) > sender.range * sender.range) { return false; }
@@ -671,21 +671,33 @@ namespace Barotrauma.Items.Components
return closestIndex;
}
public override void FlipX(bool relativeToSub)
{
{
Vector2 refPos = item.Submarine == null ?
Vector2.Zero :
item.Position - item.Submarine.HiddenSubPosition;
for (int i = 0; i < nodes.Count; i++)
{
nodes[i] = new Vector2(-nodes[i].X, nodes[i].Y);
nodes[i] = relativeToSub ?
new Vector2(-nodes[i].X, nodes[i].Y) :
new Vector2(refPos.X - (nodes[i].X - refPos.X), nodes[i].Y);
}
UpdateSections();
}
public override void FlipY(bool relativeToSub)
{
Vector2 refPos = item.Submarine == null ?
Vector2.Zero :
item.Position - item.Submarine.HiddenSubPosition;
for (int i = 0; i < nodes.Count; i++)
{
nodes[i] = new Vector2(nodes[i].X, -nodes[i].Y);
nodes[i] = relativeToSub ?
new Vector2(nodes[i].X, -nodes[i].Y) :
new Vector2(nodes[i].X, refPos.Y - (nodes[i].Y - refPos.Y));
}
UpdateSections();
}
@@ -44,15 +44,9 @@ namespace Barotrauma
// Adjustment to match the old size of 75,71
SlotSpriteSmall.size = new Vector2(SlotSpriteSmall.SourceRect.Width * 0.5859375f, SlotSpriteSmall.SourceRect.Height * 0.5546875f);
slotSpriteVertical = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(672, 218, 75, 144), null, 0);
slotSpriteHorizontal = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(476, 186, 160, 75), null, 0);
slotSpriteRound = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(681, 373, 58, 64), null, 0);
slotHotkeySprite = new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(128, 0, 128, 128), null, 0);
EquipIndicator = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(673, 182, 73, 27), new Vector2(0.5f, 0.5f), 0);
EquipIndicatorHighlight = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(679, 108, 67, 21), new Vector2(0.5f, 0.5f), 0);
DropIndicator = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(870, 55, 73, 66), new Vector2(0.5f, 0.75f), 0);
DropIndicatorHighlight = new Sprite("Content/UI/inventoryAtlas.png", new Rectangle(946, 54, 73, 66), new Vector2(0.5f, 0.75f), 0);
}
#endif
}
@@ -107,19 +107,16 @@ namespace Barotrauma
: this (rectangle, Submarine.MainSub)
{ }
public Gap(Rectangle newRect, Submarine submarine)
: this(newRect, newRect.Width < newRect.Height, submarine)
public Gap(Rectangle rect, Submarine submarine)
: this(rect, rect.Width < rect.Height, submarine)
{ }
public Gap(Rectangle newRect, bool isHorizontal, Submarine submarine)
public Gap(Rectangle rect, bool isHorizontal, Submarine submarine)
: base(MapEntityPrefab.Find(null, "gap"), submarine)
{
rect = newRect;
this.rect = rect;
flowForce = Vector2.Zero;
this.IsHorizontal = isHorizontal;
IsHorizontal = isHorizontal;
open = 1.0f;
FindHulls();
@@ -131,6 +128,7 @@ namespace Barotrauma
outsideCollisionBlocker.CollisionCategories = Physics.CollisionWall;
outsideCollisionBlocker.CollidesWith = Physics.CollisionCharacter;
outsideCollisionBlocker.Enabled = false;
Resized += newRect => IsHorizontal = newRect.Width < newRect.Height;
DebugConsole.Log("Created gap (" + ID + ")");
}
@@ -36,6 +36,8 @@ namespace Barotrauma
//is the mouse inside the rect
private bool isHighlighted;
public event Action<Rectangle> Resized;
public bool IsHighlighted
{
get { return isHighlighted || ExternalHighlight; }
@@ -578,6 +580,7 @@ namespace Barotrauma
if (!float.IsNaN(value))
{
_spriteOverrideDepth = MathHelper.Clamp(value, 0.001f, 0.999f);
if (this is Item) { _spriteOverrideDepth = Math.Min(_spriteOverrideDepth, 0.9f); }
SpriteDepthOverrideIsSet = true;
}
}
@@ -42,9 +42,6 @@ namespace Barotrauma
public const int WallSectionSize = 96;
public static List<Structure> WallList = new List<Structure>();
//how much mechanic skill increases per damage removed from the wall by welding
public const float SkillIncreaseMultiplier = 0.005f;
const float LeakThreshold = 0.1f;
#if CLIENT
@@ -1008,7 +1005,7 @@ namespace Barotrauma
if (damageDiff < 0.0f)
{
attacker.Info.IncreaseSkillLevel("mechanical",
-damageDiff * SkillIncreaseMultiplier / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f),
-damageDiff * SkillSettings.Current.SkillIncreasePerRepairedStructureDamage / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f),
SectionPosition(sectionIndex, true));
}
}
@@ -949,6 +949,7 @@ namespace Barotrauma
&& !fixture.CollisionCategories.HasFlag(Physics.CollisionWall)
&& !fixture.CollisionCategories.HasFlag(Physics.CollisionRepair)) { return -1; }
if (ignoreSubs && fixture.Body.UserData is Submarine) { return -1; }
if (fixture.Body.UserData as string == "ruinroom") { return -1; }
if (fixture.Body.UserData is Structure structure)
{
if (structure.IsPlatform || structure.StairDirection != Direction.None) { return -1; }
@@ -176,8 +176,16 @@ namespace Barotrauma.Networking
byte[] lengthBytes = new byte[2];
lengthBytes[0] = (byte)(msg.Length & 0xFF);
lengthBytes[1] = (byte)((msg.Length >> 8) & 0xFF);
writeStream?.Write(lengthBytes, 0, 2);
writeStream?.Write(msg, 0, msg.Length);
try
{
writeStream?.Write(lengthBytes, 0, 2);
writeStream?.Write(msg, 0, msg.Length);
}
catch (IOException e)
{
shutDown = true;
break;
}
if (shutDown) { break; }
@@ -74,6 +74,17 @@ namespace Barotrauma.Networking
RespawnShuttle.Load(false);
RespawnShuttle.PhysicsBody.FarseerBody.OnCollision += OnShuttleCollision;
//prevent wifi components from communicating between the respawn shuttle and other subs
List<WifiComponent> wifiComponents = new List<WifiComponent>();
foreach (Item item in Item.ItemList)
{
if (item.Submarine == RespawnShuttle) { wifiComponents.AddRange(item.GetComponents<WifiComponent>()); }
}
foreach (WifiComponent wifiComponent in wifiComponents)
{
wifiComponent.TeamID = Character.TeamType.FriendlyNPC;
}
ResetShuttle();
shuttleDoors = new List<Door>();
@@ -148,10 +148,26 @@ namespace Barotrauma
sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("LevelUpdate", sw.ElapsedTicks);
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
if (Character.Controlled != null)
{
Character.Controlled.SelectedConstruction.UpdateHUD(cam, Character.Controlled, (float)deltaTime);
if (Character.Controlled.SelectedConstruction != null && Character.Controlled.CanInteractWith(Character.Controlled.SelectedConstruction))
{
Character.Controlled.SelectedConstruction.UpdateHUD(cam, Character.Controlled, (float)deltaTime);
}
if (Character.Controlled.Inventory != null)
{
foreach (Item item in Character.Controlled.Inventory.Items)
{
if (item == null) { continue; }
if (Character.Controlled.HasEquippedItem(item))
{
item.UpdateHUD(cam, Character.Controlled, (float)deltaTime);
}
}
}
}
sw.Restart();
Character.UpdateAll((float)deltaTime, cam);
@@ -520,7 +520,7 @@ namespace Barotrauma
{ if (parentObject is Character character && value is float) { character.LowPassMultiplier = (float)value; return true; } }
break;
case "SpeedMultiplier":
{ if (parentObject is Character character && value is float) { character.SpeedMultiplier = (float)value; return true; } }
{ if (parentObject is Character character && value is float) { character.StackSpeedMultiplier((float)value); return true; } }
break;
case "IsOn":
{ if (parentObject is LightComponent lightComponent && value is bool) { lightComponent.IsOn = (bool)value; return true; } }
@@ -35,6 +35,8 @@ public static class AssemblyInfo
#if DEBUG
retVal = "Debug" + retVal;
#elif UNSTABLE
retVal = "Unstable" + retVal;
#else
retVal = "Release" + retVal;
#endif