(b0f5305f2) Unstable v0.9.10.0

This commit is contained in:
Juan Pablo Arce
2020-05-22 08:21:34 -03:00
parent 3d2b7bcf63
commit 4f8bd39789
75 changed files with 1023 additions and 407 deletions
@@ -205,18 +205,6 @@ namespace Barotrauma.Items.Components
DockingDir = GetDir(DockingTarget);
DockingTarget.DockingDir = -DockingDir;
if (door != null && DockingTarget.door != null)
{
WayPoint myWayPoint = WayPoint.WayPointList.Find(wp => door.LinkedGap == wp.ConnectedGap);
WayPoint targetWayPoint = WayPoint.WayPointList.Find(wp => DockingTarget.door.LinkedGap == wp.ConnectedGap);
if (myWayPoint != null && targetWayPoint != null)
{
myWayPoint.linkedTo.Add(targetWayPoint);
targetWayPoint.linkedTo.Add(myWayPoint);
}
}
CreateJoint(false);
#if SERVER
@@ -283,6 +271,20 @@ namespace Barotrauma.Items.Components
{
CreateHulls();
}
if (door != null && DockingTarget.door != null)
{
WayPoint myWayPoint = WayPoint.WayPointList.Find(wp => door.LinkedGap == wp.ConnectedGap);
WayPoint targetWayPoint = WayPoint.WayPointList.Find(wp => DockingTarget.door.LinkedGap == wp.ConnectedGap);
if (myWayPoint != null && targetWayPoint != null)
{
myWayPoint.FindHull();
myWayPoint.linkedTo.Add(targetWayPoint);
targetWayPoint.FindHull();
targetWayPoint.linkedTo.Add(myWayPoint);
}
}
}
@@ -778,7 +780,9 @@ namespace Barotrauma.Items.Components
if (myWayPoint != null && targetWayPoint != null)
{
myWayPoint.FindHull();
myWayPoint.linkedTo.Remove(targetWayPoint);
targetWayPoint.FindHull();
targetWayPoint.linkedTo.Remove(myWayPoint);
}
}
@@ -331,8 +331,8 @@ namespace Barotrauma.Items.Components
if (!item.body.Enabled)
{
Limb rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
item.SetTransform(rightHand.SimPosition, 0.0f);
Limb hand = picker.AnimController.GetLimb(LimbType.RightHand) ?? picker.AnimController.GetLimb(LimbType.LeftHand);
item.SetTransform(hand != null ? hand.SimPosition : character.SimPosition, 0.0f);
}
bool alreadyEquipped = character.HasEquippedItem(item);
@@ -369,17 +369,19 @@ namespace Barotrauma.Items.Components
IsActive = false;
}
public bool CanBeAttached()
public bool CanBeAttached(Character user)
{
if (!attachable || !Reattachable) { return false; }
//can be attached anywhere in sub editor
if (Screen.Selected == GameMain.SubEditorScreen) { return true; }
//can be attached anywhere inside hulls
if (item.CurrentHull != null) { return true; }
Vector2 attachPos = user == null ? item.WorldPosition : GetAttachPosition(user, useWorldCoordinates: true);
return Structure.GetAttachTarget(item.WorldPosition) != null;
//can be attached anywhere inside hulls
if (item.CurrentHull != null && Submarine.RectContains(item.CurrentHull.WorldRect, attachPos)) { return true; }
return Structure.GetAttachTarget(attachPos) != null;
}
public bool CanBeDeattached()
@@ -396,8 +398,14 @@ namespace Barotrauma.Items.Components
return false;
}
//don't allow deattaching if part of a sub and outside hulls
return item.Submarine == null || item.CurrentHull != null;
if (item.CurrentHull == null)
{
return Structure.GetAttachTarget(item.WorldPosition) != null;
}
else
{
return true;
}
}
public override bool Pick(Character picker)
@@ -505,7 +513,7 @@ namespace Barotrauma.Items.Components
if (character != null)
{
if (!character.IsKeyDown(InputType.Aim)) { return false; }
if (!CanBeAttached()) { return false; }
if (!CanBeAttached(character)) { return false; }
if (GameMain.NetworkMember != null)
{
@@ -534,7 +542,7 @@ namespace Barotrauma.Items.Components
else
{
item.Drop(character);
item.SetTransform(ConvertUnits.ToSimUnits(GetAttachPosition(character)), 0.0f);
item.SetTransform(ConvertUnits.ToSimUnits(GetAttachPosition(character)), 0.0f, findNewHull: false);
}
}
@@ -543,16 +551,18 @@ namespace Barotrauma.Items.Components
return true;
}
private Vector2 GetAttachPosition(Character user)
private Vector2 GetAttachPosition(Character user, bool useWorldCoordinates = false)
{
if (user == null) { return item.Position; }
if (user == null) { return useWorldCoordinates ? item.WorldPosition : item.Position; }
Vector2 mouseDiff = user.CursorWorldPosition - user.WorldPosition;
mouseDiff = mouseDiff.ClampLength(MaxAttachDistance);
Vector2 userPos = useWorldCoordinates ? user.WorldPosition : user.Position;
return new Vector2(
MathUtils.RoundTowardsClosest(user.Position.X + mouseDiff.X, Submarine.GridSize.X),
MathUtils.RoundTowardsClosest(user.Position.Y + mouseDiff.Y, Submarine.GridSize.Y));
MathUtils.RoundTowardsClosest(userPos.X + mouseDiff.X, Submarine.GridSize.X),
MathUtils.RoundTowardsClosest(userPos.Y + mouseDiff.Y, Submarine.GridSize.Y));
}
public override void UpdateBroken(float deltaTime, Camera cam)
@@ -114,10 +114,6 @@ namespace Barotrauma.Items.Components
{
activePicker = picker;
picker.PickingItem = item;
var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand);
var rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
pickTimer = 0.0f;
while (pickTimer < requiredTime && Screen.Selected != GameMain.SubEditorScreen)
{
@@ -326,6 +326,18 @@ namespace Barotrauma.Items.Components
{
if (RepairThroughHoles && f.IsSensor && f.Body?.UserData is Structure) { return false; }
if (f.Body?.UserData as string == "ruinroom") { return false; }
if (f.Body?.UserData is Item targetItem)
{
if (!HitItems) { return false; }
if (HitBrokenDoors)
{
if (targetItem.GetComponent<Door>() == null && targetItem.Condition <= 0) { return false; }
}
else
{
if (targetItem.Condition <= 0) { return false; }
}
}
return f.Body?.UserData != null;
},
allowInsideFixture: true));
@@ -93,8 +93,8 @@ namespace Barotrauma.Items.Components
controlLockTimer -= deltaTime;
currPowerConsumption = Math.Abs(targetForce) / 100.0f * powerConsumption;
//pumps consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
//engines consume more power when in a bad condition
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
if (powerConsumption == 0.0f) { Voltage = 1.0f; }
@@ -171,7 +171,7 @@ namespace Barotrauma.Items.Components
outputContainer.Inventory.Locked = true;
currPowerConsumption = powerConsumption;
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
if (GameMain.NetworkMember?.IsServer ?? true)
{
@@ -42,7 +42,7 @@ namespace Barotrauma.Items.Components
CurrFlow = 0.0f;
currPowerConsumption = powerConsumption;
//consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
if (powerConsumption <= 0.0f)
{
@@ -69,7 +69,7 @@ namespace Barotrauma.Items.Components
currPowerConsumption = powerConsumption * Math.Abs(flowPercentage / 100.0f);
//pumps consume more power when in a bad condition
currPowerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
item.GetComponent<Repairable>()?.AdjustPowerConsumption(ref currPowerConsumption);
if (!HasPower) { return; }
@@ -298,10 +298,7 @@ namespace Barotrauma.Items.Components
{
if (user != null && user.Info != null && user.SelectedConstruction == item)
{
user.Info.IncreaseSkillLevel(
"helm",
SkillSettings.Current.SkillIncreasePerSecondWhenSteering / Math.Max(userSkill, 1.0f) * deltaTime,
user.WorldPosition + Vector2.UnitY * 150.0f);
IncreaseSkillLevel(user, deltaTime);
}
Vector2 velocityDiff = steeringInput - targetVelocity;
@@ -330,6 +327,18 @@ namespace Barotrauma.Items.Components
item.SendSignal(0, targetLevel.ToString(CultureInfo.InvariantCulture), "velocity_y_out", null);
}
private void IncreaseSkillLevel(Character user, float deltaTime)
{
if (user?.Info == null) { return; }
float userSkill = user.GetSkillLevel("helm") / 100.0f;
user.Info.IncreaseSkillLevel(
"helm",
SkillSettings.Current.SkillIncreasePerSecondWhenSteering / Math.Max(userSkill, 1.0f) * deltaTime,
user.WorldPosition + Vector2.UnitY * 150.0f);
}
private void UpdateAutoPilot(float deltaTime)
{
if (controlledSub == null) { return; }
@@ -565,6 +574,7 @@ namespace Barotrauma.Items.Components
unsentChanges = true;
AutoPilot = true;
}
IncreaseSkillLevel(user, deltaTime);
switch (objective.Option.ToLowerInvariant())
{
case "maintainposition":
@@ -55,8 +55,8 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize(80.0f, true, description: "The condition of the item has to be below this for AI characters to repair it. Percentages of max condition."), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
public float AIRepairThreshold
[Serialize(80.0f, true, description: "The condition of the item has to be below this for it to become repairable. Percentages of max condition."), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
public float RepairThreshold
{
get;
set;
@@ -112,13 +112,14 @@ namespace Barotrauma.Items.Components
element.GetAttributeString("name", "");
//backwards compatibility
var showRepairUIAttribute = element.Attributes().FirstOrDefault(a => a.Name.ToString().Equals("showrepairuithreshold", StringComparison.OrdinalIgnoreCase));
if (showRepairUIAttribute != null)
var repairThresholdAttribute =
element.Attributes().FirstOrDefault(a => a.Name.ToString().Equals("showrepairuithreshold", StringComparison.OrdinalIgnoreCase)) ??
element.Attributes().FirstOrDefault(a => a.Name.ToString().Equals("airepairth44reshold", StringComparison.OrdinalIgnoreCase));
if (repairThresholdAttribute != null)
{
float repairThreshold;
if (Single.TryParse(showRepairUIAttribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out repairThreshold))
if (float.TryParse(repairThresholdAttribute.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out float repairThreshold))
{
AIRepairThreshold = repairThreshold;
RepairThreshold = repairThreshold;
}
}
@@ -273,7 +274,7 @@ namespace Barotrauma.Items.Components
float successFactor = requiredSkills.Count == 0 ? 1.0f : DegreeOfSuccess(CurrentFixer, requiredSkills);
//item must have been below the repair threshold for the player to get an achievement or XP for repairing it
if (item.ConditionPercentage < AIRepairThreshold)
if (item.ConditionPercentage < RepairThreshold)
{
wasBroken = true;
}
@@ -357,6 +358,14 @@ namespace Barotrauma.Items.Components
partial void UpdateProjSpecific(float deltaTime);
public void AdjustPowerConsumption(ref float powerConsumption)
{
if (item.ConditionPercentage < RepairThreshold)
{
powerConsumption *= MathHelper.Lerp(1.5f, 1.0f, item.Condition / item.MaxCondition);
}
}
private bool ShouldDeteriorate()
{
if (LastActiveTime > Timing.TotalTime) { return true; }
@@ -182,8 +182,6 @@ namespace Barotrauma.Items.Components
newConnection.Item.Position :
newConnection.Item.Position - refSub.HiddenSubPosition;
nodePos = RoundNode(nodePos);
if (nodes.Count > 0 && nodes[0] == nodePos) { break; }
if (nodes.Count > 1 && nodes[nodes.Count - 1] == nodePos) { break; }