(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;
}
}
}
}