Unstable 0.1500.7.0 (No edition)

This commit is contained in:
Markus Isberg
2021-10-14 00:42:06 +09:00
parent c8943ef9c4
commit de917c5d74
105 changed files with 871 additions and 443 deletions
@@ -49,13 +49,13 @@ namespace Barotrauma.Items.Components
[Editable(MaxValueFloat = int.MaxValue, MinValueFloat = int.MinValue, ValueStep = 10f), Serialize("0,0", true, "Offset of the spawn area from the center of the item")]
public Vector2 SpawnAreaOffset { get; set; }
[Editable(MaxValueFloat = int.MaxValue, MinValueFloat = int.MinValue, ValueStep = 1f), Serialize("10,40", true, "Time range between spawn attempts in seconds")]
[Editable(MaxValueFloat = int.MaxValue, MinValueFloat = int.MinValue, ValueStep = 1f), Serialize("10,40", true, "Time range between spawn attempts in seconds. Set both to a negative value to disable automatic spawning.")]
public Vector2 SpawnTimerRange { get; set; }
[Editable(MaxValueFloat = int.MaxValue, MinValueFloat = 1f, ValueStep = 1f, DecimalCount = 0), Serialize("1,3", true, "Minumum and maximum amount of items or creatures to spawn in one attempt")]
public Vector2 SpawnAmountRange { get; set; }
[Editable(MinValueInt = 0), Serialize(8, true, "Amount of items or creatures in the spawn area that will prevent further items or creatures from being spawned")]
[Editable(MinValueInt = int.MinValue, MaxValueInt = int.MaxValue), Serialize(8, true, "Amount of items or creatures in the spawn area that will prevent further items or creatures from being spawned")]
public int MaximumAmount { get; set; }
[Editable(MaxValueFloat = int.MaxValue, MinValueFloat = int.MinValue, ValueStep = 10f), Serialize(500f, true, "Inflate the circle of rectangle by this value to extend the area that counts towards the maximum amount of items or enemies to be spawned")]
@@ -110,7 +110,12 @@ namespace Barotrauma.Items.Components
if (GameMain.NetworkMember is { IsClient: true }) { return; }
SpawnTimerGoal ??= Rand.Range(Math.Min(SpawnTimerRange.X, SpawnTimerRange.Y), Math.Max(SpawnTimerRange.X, SpawnTimerRange.Y), Rand.RandSync.Unsynced);
float minTime = Math.Min(SpawnTimerRange.X, SpawnTimerRange.Y),
maxTime = Math.Max(SpawnTimerRange.X, SpawnTimerRange.Y);
if (minTime < 0 && maxTime < 0) { return; }
SpawnTimerGoal ??= Rand.Range(minTime, maxTime, Rand.RandSync.Unsynced);
SpawnTimer += deltaTime;
@@ -120,12 +125,12 @@ namespace Barotrauma.Items.Components
SpawnTimerGoal = null;
SpawnTimer = 0;
}
}
public override void ReceiveSignal(Signal signal, Connection connection)
{
bool isNonZero = signal.value != "0";
bool isClient = GameMain.NetworkMember is { IsClient: true };
switch (connection.Name)
{
@@ -135,6 +140,9 @@ namespace Barotrauma.Items.Components
case "toggle" when isNonZero:
CanSpawn = !CanSpawn;
break;
case "trigger_in" when isNonZero && !isClient:
Spawn();
break;
}
}
@@ -163,6 +171,8 @@ namespace Barotrauma.Items.Components
}
}
if (MaximumAmount < 0) { return true; }
int amount;
if (!string.IsNullOrWhiteSpace(SpeciesName))
@@ -59,6 +59,7 @@ namespace Barotrauma.Items.Components
[Editable, Serialize("3.0, -1.0", false)]
public Vector2 SwingForce { get; set; }
public bool Hitting { get { return hitting; } }
/// <summary>
/// Defines items that boost the weapon functionality, like battery cell for stun batons.
@@ -66,18 +66,18 @@ namespace Barotrauma.Items.Components
foreach (Limb limb in character.AnimController.Limbs)
{
if (limb.WearingItems.Find(w => w.WearableComponent.Item == item) == null) { continue; }
limb.body.ApplyForce(propulsion, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
limb.body.ApplyForce(propulsion);
}
character.AnimController.Collider.ApplyForce(propulsion, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
character.AnimController.Collider.ApplyForce(propulsion);
if (character.Inventory.IsInLimbSlot(item, InvSlotType.RightHand))
{
character.AnimController.GetLimb(LimbType.RightHand)?.body.ApplyForce(propulsion, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
character.AnimController.GetLimb(LimbType.RightHand)?.body.ApplyForce(propulsion);
}
if (character.Inventory.IsInLimbSlot(item, InvSlotType.LeftHand))
{
character.AnimController.GetLimb(LimbType.LeftHand)?.body.ApplyForce(propulsion, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
character.AnimController.GetLimb(LimbType.LeftHand)?.body.ApplyForce(propulsion);
}
#if CLIENT
@@ -200,7 +200,8 @@ namespace Barotrauma.Items.Components
void CreateDeconstructProduct(DeconstructItem deconstructProduct, IEnumerable<Item> inputItems)
{
float percentageHealth = targetItem.Condition / targetItem.Prefab.Health;
float percentageHealth = targetItem.Condition / targetItem.MaxCondition;
if (percentageHealth <= deconstructProduct.MinCondition || percentageHealth > deconstructProduct.MaxCondition) { return; }
if (!(MapEntityPrefab.Find(null, deconstructProduct.ItemIdentifier) is ItemPrefab itemPrefab))
@@ -391,8 +391,7 @@ namespace Barotrauma.Items.Components
user.Info.IncreaseSkillLevel(
skill.Identifier,
addedSkill,
user.Position + Vector2.UnitY * 150.0f);
addedSkill);
}
}
@@ -11,9 +11,12 @@ namespace Barotrauma.Items.Components
private float generatedAmount;
//key = vent, float = total volume of the hull the vent is in and the hulls connected to it
private Dictionary<Vent, float> ventList;
private List<(Vent vent, float hullVolume)> ventList;
private float totalHullVolume;
private float ventUpdateTimer;
const float VentUpdateInterval = 5.0f;
public float CurrFlow
{
@@ -64,7 +67,7 @@ namespace Barotrauma.Items.Components
//20% condition = 4%
CurrFlow *= conditionMult * conditionMult;
UpdateVents(CurrFlow);
UpdateVents(CurrFlow, deltaTime);
}
public override void UpdateBroken(float deltaTime, Camera cam)
@@ -75,7 +78,8 @@ namespace Barotrauma.Items.Components
private void GetVents()
{
ventList = new Dictionary<Vent, float>();
ventList ??= new List<(Vent vent, float hullVolume)>();
ventList.Clear();
foreach (MapEntity entity in item.linkedTo)
{
if (!(entity is Item linkedItem)) { continue; }
@@ -83,30 +87,39 @@ namespace Barotrauma.Items.Components
Vent vent = linkedItem.GetComponent<Vent>();
if (vent?.Item.CurrentHull == null) { continue; }
ventList.Add(vent, 0.0f);
foreach (Hull connectedHull in vent.Item.CurrentHull.GetConnectedHulls(includingThis: true, searchDepth: 10, ignoreClosedGaps: true))
{
ventList.Add((vent, vent.Item.CurrentHull.Volume));
}
for (int i = 0; i < ventList.Count; i++)
{
Vent vent = ventList[i].vent;
foreach (Hull connectedHull in vent.Item.CurrentHull.GetConnectedHulls(includingThis: false, searchDepth: 5, ignoreClosedGaps: true))
{
//another vent in the connected hull -> don't add it to this vent's total hull volume
if (ventList.Any(v => v.vent != vent && v.vent.Item.CurrentHull == connectedHull)) { continue; }
totalHullVolume += connectedHull.Volume;
ventList[vent] += connectedHull.Volume;
ventList[i] = (ventList[i].vent, ventList[i].hullVolume + connectedHull.Volume);
}
}
}
private void UpdateVents(float deltaOxygen)
private void UpdateVents(float deltaOxygen, float deltaTime)
{
if (ventList == null)
if (ventList == null || ventUpdateTimer < 0.0f)
{
GetVents();
ventUpdateTimer = VentUpdateInterval;
}
ventUpdateTimer -= deltaTime;
if (!ventList.Any() || totalHullVolume <= 0.0f) { return; }
foreach (KeyValuePair<Vent, float> v in ventList)
foreach ((Vent vent, float hullVolume) in ventList)
{
if (v.Key?.Item.CurrentHull == null) { continue; }
if (vent.Item.CurrentHull == null) { continue; }
v.Key.OxygenFlow = deltaOxygen * (v.Value / totalHullVolume);
v.Key.IsActive = true;
vent.OxygenFlow = deltaOxygen * (hullVolume / totalHullVolume);
vent.IsActive = true;
}
}
}
@@ -392,8 +392,7 @@ namespace Barotrauma.Items.Components
float userSkill = Math.Max(user.GetSkillLevel("helm"), 1.0f) / 100.0f;
user.Info.IncreaseSkillLevel(
"helm",
SkillSettings.Current.SkillIncreasePerSecondWhenSteering / userSkill * deltaTime,
user.Position + Vector2.UnitY * 150.0f);
SkillSettings.Current.SkillIncreasePerSecondWhenSteering / userSkill * deltaTime);
}
private void UpdateAutoPilot(float deltaTime)
@@ -340,7 +340,7 @@ namespace Barotrauma.Items.Components
item.AiTarget.SoundRange = item.AiTarget.MaxSoundRange;
}
item.Drop(null);
item.Drop(null, createNetworkEvent: false);
launchPos = item.SimPosition;
@@ -35,7 +35,6 @@ namespace Barotrauma.Items.Components
public RemoteController(Item item, XElement element)
: base(item, element)
{
DrawHudWhenEquipped = false;
}
public override bool Select(Character character)
@@ -440,8 +440,7 @@ namespace Barotrauma.Items.Components
{
float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier);
CurrentFixer.Info?.IncreaseSkillLevel(skill.Identifier,
SkillSettings.Current.SkillIncreasePerRepair / Math.Max(characterSkillLevel, 1.0f),
CurrentFixer.Position + Vector2.UnitY * 100.0f);
SkillSettings.Current.SkillIncreasePerRepair / Math.Max(characterSkillLevel, 1.0f));
}
SteamAchievementManager.OnItemRepaired(item, CurrentFixer);
CurrentFixer.CheckTalents(AbilityEffectType.OnRepairComplete);
@@ -472,8 +471,7 @@ namespace Barotrauma.Items.Components
{
float characterSkillLevel = CurrentFixer.GetSkillLevel(skill.Identifier);
CurrentFixer.Info?.IncreaseSkillLevel(skill.Identifier,
SkillSettings.Current.SkillIncreasePerSabotage / Math.Max(characterSkillLevel, 1.0f),
CurrentFixer.Position + Vector2.UnitY * 100.0f);
SkillSettings.Current.SkillIncreasePerSabotage / Math.Max(characterSkillLevel, 1.0f));
}
deteriorationTimer = 0.0f;
@@ -159,6 +159,8 @@ namespace Barotrauma.Items.Components
ApplyForce(i.body);
}
}
item.SendSignal(IsActive ? "1" : "0", "state_out");
}
private void ApplyForce(PhysicsBody body)
@@ -438,8 +438,7 @@ namespace Barotrauma.Items.Components
if (user?.Info != null && (GameMain.GameSession?.Campaign == null || !Level.IsLoadedOutpost))
{
user.Info.IncreaseSkillLevel("weapons",
SkillSettings.Current.SkillIncreasePerSecondWhenOperatingTurret * deltaTime / Math.Max(user.GetSkillLevel("weapons"), 1.0f),
user.Position + Vector2.UnitY * 150.0f);
SkillSettings.Current.SkillIncreasePerSecondWhenOperatingTurret * deltaTime / Math.Max(user.GetSkillLevel("weapons"), 1.0f));
}
float rotMidDiff = MathHelper.WrapAngle(rotation - (minRotation + maxRotation) / 2.0f);
@@ -46,6 +46,7 @@ namespace Barotrauma
public LimbType Limb { get; private set; }
public bool HideLimb { get; private set; }
public bool HideOtherWearables { get; private set; }
public bool CanBeHiddenByOtherWearables { get; private set; }
public List<WearableType> HideWearablesOfType { get; private set; }
public bool InheritLimbDepth { get; private set; }
/// <summary>
@@ -176,6 +177,7 @@ namespace Barotrauma
Limb = (LimbType)Enum.Parse(typeof(LimbType), SourceElement.GetAttributeString("limb", "Head"), true);
HideLimb = SourceElement.GetAttributeBool("hidelimb", false);
HideOtherWearables = SourceElement.GetAttributeBool("hideotherwearables", false);
CanBeHiddenByOtherWearables = SourceElement.GetAttributeBool("canbehiddenbyotherwearables", true);
InheritLimbDepth = SourceElement.GetAttributeBool("inheritlimbdepth", true);
var scale = SourceElement.GetAttribute("inheritscale");
if (scale != null)