Merge branch 'master' into new-netcode
Conflicts: Subsurface/Properties/AssemblyInfo.cs Subsurface/Source/Items/Components/Signal/Wire.cs Subsurface/Source/Items/Item.cs Subsurface/Source/Items/ItemInventory.cs Subsurface/Source/Networking/GameServer.cs
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
<!-- lower yaw -->
|
<!-- lower yaw -->
|
||||||
<limb id = "1" radius="70" height="100">
|
<limb id = "1" radius="70" height="100">
|
||||||
<sprite texture="Content/Characters/Charybdis/charybdis.png" sourcerect="416,0,192,256" depth="0.025" origin="0.65,0.5"/>
|
<sprite texture="Content/Characters/Charybdis/charybdis.png" sourcerect="416,0,192,256" depth="0.025" origin="0.65,0.5"/>
|
||||||
<attack range="300" duration="0.5" damage="5.00" bleedingdamage="50" structuredamage="500" damagetype="slash" torque="200" targetforce="-50"/>
|
<attack range="500" duration="0.5" damage="5.00" bleedingdamage="50" structuredamage="500" damagetype="slash" torque="200" targetforce="-50"/>
|
||||||
</limb>
|
</limb>
|
||||||
|
|
||||||
<!-- front fins -->
|
<!-- front fins -->
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ragdoll waveamplitude="50.0" wavelength="2500" swimspeed="5.0" walkspeed="3.5" canentersubmarine="false">
|
<ragdoll waveamplitude="50.0" wavelength="2500" swimspeed="5.0" walkspeed="3.5" canentersubmarine="false">
|
||||||
|
|
||||||
<collider radius ="50"/>
|
<collider radius="50" height="250"/>
|
||||||
|
|
||||||
<!-- head -->
|
<!-- head -->
|
||||||
<limb id = "0" radius="50" height="270" type="Head" steerforce="1.0">
|
<limb id = "0" radius="50" height="270" type="Head" steerforce="1.0">
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
movementlerp="0.4"
|
movementlerp="0.4"
|
||||||
legtorque="15.0"
|
legtorque="15.0"
|
||||||
thightorque="-5.0"
|
thightorque="-5.0"
|
||||||
walkspeed="2.0"
|
walkspeed="1.5"
|
||||||
swimspeed="2.0">
|
swimspeed="2.5"
|
||||||
|
impacttolerance="7.5">
|
||||||
|
|
||||||
|
<collider height="100" radius="15"/>
|
||||||
|
|
||||||
<!-- head -->
|
<!-- head -->
|
||||||
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2">
|
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2">
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
<Character file="Content/Characters/Mantis/mantis.xml" />
|
<Character file="Content/Characters/Mantis/mantis.xml" />
|
||||||
<Character file="Content/Characters/Moloch/moloch.xml" />
|
<Character file="Content/Characters/Moloch/moloch.xml" />
|
||||||
<Character file="Content/Characters/Scorpion/scorpion.xml" />
|
<Character file="Content/Characters/Scorpion/scorpion.xml" />
|
||||||
<Character file="Content/Characters/TigerThresher/tigerthresher.xml" />
|
<Character file="Content/Characters/Tigerthresher/tigerthresher.xml" />
|
||||||
<Character file="Content/Characters/Watcher/watcher.xml" />
|
<Character file="Content/Characters/Watcher/watcher.xml" />
|
||||||
<Structure file="Content/Map/StructurePrefabs.xml" />
|
<Structure file="Content/Map/StructurePrefabs.xml" />
|
||||||
<BackgroundCreaturePrefabs file="Content/BackgroundSprites/BackgroundCreaturePrefabs.xml"/>
|
<BackgroundCreaturePrefabs file="Content/BackgroundSprites/BackgroundCreaturePrefabs.xml"/>
|
||||||
|
|||||||
@@ -51,10 +51,20 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
|
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
|
||||||
{
|
{
|
||||||
collider.PhysEnabled = false;
|
collider.FarseerBody.FixedRotation = false;
|
||||||
collider.SetTransform(MainLimb.SimPosition, 0.0f);
|
|
||||||
|
|
||||||
if (stunTimer > 0.0f)
|
if (character.IsRemotePlayer)
|
||||||
|
{
|
||||||
|
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
|
||||||
|
MainLimb.pullJoint.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
collider.LinearVelocity = (MainLimb.SimPosition - collider.SimPosition) * 60.0f;
|
||||||
|
collider.SmoothRotate(MainLimb.Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stunTimer > 0)
|
||||||
{
|
{
|
||||||
stunTimer -= deltaTime;
|
stunTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
|
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
|
||||||
{
|
{
|
||||||
collider.PhysEnabled = false;
|
collider.FarseerBody.FixedRotation = false;
|
||||||
collider.SetTransform(GetLimb(LimbType.Torso).SimPosition, 0.0f);
|
|
||||||
|
if (character.IsRemotePlayer)
|
||||||
|
{
|
||||||
|
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
|
||||||
|
MainLimb.pullJoint.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - collider.SimPosition) * 20.0f;
|
||||||
|
collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
if (stunTimer > 0)
|
if (stunTimer > 0)
|
||||||
{
|
{
|
||||||
@@ -87,21 +97,21 @@ namespace Barotrauma
|
|||||||
collider.SetTransform(new Vector2(
|
collider.SetTransform(new Vector2(
|
||||||
collider.SimPosition.X,
|
collider.SimPosition.X,
|
||||||
Math.Max(lowestLimb.SimPosition.Y + (collider.radius + collider.height / 2), collider.SimPosition.Y)),
|
Math.Max(lowestLimb.SimPosition.Y + (collider.radius + collider.height / 2), collider.SimPosition.Y)),
|
||||||
0.0f);
|
collider.Rotation);
|
||||||
|
|
||||||
collider.FarseerBody.Enabled = true;
|
collider.FarseerBody.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swimming)
|
if (swimming)
|
||||||
{
|
{
|
||||||
collider.FarseerBody.FixedRotation = false;
|
collider.FarseerBody.FixedRotation = false;
|
||||||
}
|
}
|
||||||
else if (!collider.FarseerBody.FixedRotation)
|
else if (!collider.FarseerBody.FixedRotation)
|
||||||
{
|
{
|
||||||
if (Math.Abs(MathUtils.GetShortestAngle(collider.Rotation, 0.0f)) > 0.001f)
|
if (Math.Abs(MathUtils.GetShortestAngle(collider.Rotation, 0.0f)) > 0.001f)
|
||||||
{
|
{
|
||||||
//rotate collider back upright
|
//rotate collider back upright
|
||||||
collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 60.0f;
|
collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 10.0f;
|
||||||
collider.FarseerBody.FixedRotation = false;
|
collider.FarseerBody.FixedRotation = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -297,8 +307,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
|
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
|
||||||
{
|
{
|
||||||
|
//move slower if collider isn't upright
|
||||||
|
float rotationFactor = (float)Math.Abs(Math.Cos(collider.Rotation));
|
||||||
|
|
||||||
collider.LinearVelocity = new Vector2(
|
collider.LinearVelocity = new Vector2(
|
||||||
movement.X,
|
movement.X * rotationFactor,
|
||||||
collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y);
|
collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +515,8 @@ namespace Barotrauma
|
|||||||
float colliderBottomY = GetColliderBottom().Y;
|
float colliderBottomY = GetColliderBottom().Y;
|
||||||
|
|
||||||
//the contact point should be higher than the bottom of the collider
|
//the contact point should be higher than the bottom of the collider
|
||||||
if (((Vector2)handle).Y < colliderBottomY + 0.01f) return;
|
if (((Vector2)handle).Y < colliderBottomY + 0.01f ||
|
||||||
|
((Vector2)handle).Y > collider.SimPosition.Y) return;
|
||||||
|
|
||||||
//find the height of the floor below the torso
|
//find the height of the floor below the torso
|
||||||
//(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it)
|
//(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it)
|
||||||
@@ -511,7 +525,7 @@ namespace Barotrauma
|
|||||||
if (obstacleY > colliderBottomY)
|
if (obstacleY > colliderBottomY)
|
||||||
{
|
{
|
||||||
//higher vertical velocity for taller obstacles
|
//higher vertical velocity for taller obstacles
|
||||||
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 10;
|
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 50;
|
||||||
onGround = true;
|
onGround = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,13 +902,22 @@ namespace Barotrauma
|
|||||||
targetLimb.pullJoint.Enabled = true;
|
targetLimb.pullJoint.Enabled = true;
|
||||||
targetLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition - diff;
|
targetLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition - diff;
|
||||||
targetLimb.pullJoint.MaxForce = 10000.0f;
|
targetLimb.pullJoint.MaxForce = 10000.0f;
|
||||||
|
|
||||||
|
target.AnimController.movement -= diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float dist = Vector2.Distance(target.SimPosition, collider.SimPosition);
|
||||||
|
|
||||||
|
//limit movement if moving away from the target
|
||||||
|
if (Vector2.Dot(target.SimPosition - collider.SimPosition, targetMovement)<0)
|
||||||
|
{
|
||||||
|
targetMovement *= MathHelper.Clamp(2.0f - dist, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
target.AnimController.IgnorePlatforms = IgnorePlatforms;
|
target.AnimController.IgnorePlatforms = IgnorePlatforms;
|
||||||
|
|
||||||
if (target.Stun > 0.0f || target.IsDead)
|
if (target.Stun > 0.0f || target.IsUnconscious || target.IsDead)
|
||||||
{
|
{
|
||||||
target.AnimController.TargetMovement = TargetMovement;
|
target.AnimController.TargetMovement = TargetMovement;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1140,7 +1140,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Vector2 GetColliderBottom()
|
public Vector2 GetColliderBottom()
|
||||||
{
|
{
|
||||||
return collider.SimPosition - Vector2.UnitY * (collider.height / 2 + collider.radius);
|
float halfHeight = collider.height / 2 + collider.radius;
|
||||||
|
|
||||||
|
return collider.SimPosition +
|
||||||
|
new Vector2((float)Math.Sin(collider.Rotation), -(float)Math.Cos(collider.Rotation)) * halfHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Limb FindLowestLimb()
|
public Limb FindLowestLimb()
|
||||||
|
|||||||
@@ -1123,17 +1123,18 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveCam)
|
if (moveCam && needsAir)
|
||||||
{
|
{
|
||||||
float pressureEffect = 0.0f;
|
if (pressureProtection < 80.0f &&
|
||||||
|
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 50.0f))
|
||||||
if (pressureProtection < 80.0f && AnimController.CurrentHull != null && AnimController.CurrentHull.LethalPressure > 50.0f)
|
|
||||||
{
|
{
|
||||||
|
float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure;
|
||||||
|
|
||||||
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
||||||
(AnimController.CurrentHull.LethalPressure / 50.0f) * Rand.Range(1.0f, 1.05f),
|
(pressure / 50.0f) * Rand.Range(1.0f, 1.05f),
|
||||||
(AnimController.CurrentHull.LethalPressure - 50.0f) / 50.0f);
|
(pressure - 50.0f) / 50.0f);
|
||||||
}
|
}
|
||||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (Submarine == null ? 400.0f : 250.0f)+pressureEffect, 0.05f);
|
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TargetType targetTypes;
|
private TargetType targetTypes;
|
||||||
private string[] targetNames;
|
private HashSet<string> targetNames;
|
||||||
|
|
||||||
private List<RelatedItem> requiredItems;
|
private List<RelatedItem> requiredItems;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool disableDeltaTime;
|
private bool disableDeltaTime;
|
||||||
|
|
||||||
private string[] onContainingNames;
|
private HashSet<string> onContainingNames;
|
||||||
|
|
||||||
private readonly float duration;
|
private readonly float duration;
|
||||||
|
|
||||||
@@ -48,12 +48,12 @@ namespace Barotrauma
|
|||||||
get { return targetTypes; }
|
get { return targetTypes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] TargetNames
|
public HashSet<string> TargetNames
|
||||||
{
|
{
|
||||||
get { return targetNames; }
|
get { return targetNames; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] OnContainingNames
|
public HashSet<string> OnContainingNames
|
||||||
{
|
{
|
||||||
get { return onContainingNames; }
|
get { return onContainingNames; }
|
||||||
}
|
}
|
||||||
@@ -92,10 +92,10 @@ namespace Barotrauma
|
|||||||
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
|
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
|
||||||
|
|
||||||
string[] containingNames = split[1].Split(',');
|
string[] containingNames = split[1].Split(',');
|
||||||
onContainingNames = new string[containingNames.Length];
|
onContainingNames = new HashSet<string>();
|
||||||
for (int i =0; i < containingNames.Length; i++)
|
for (int i = 0; i < containingNames.Length; i++)
|
||||||
{
|
{
|
||||||
onContainingNames[i] = containingNames[i].Trim();
|
onContainingNames.Add(containingNames[i].Trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +116,10 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
case "targetnames":
|
case "targetnames":
|
||||||
string[] names = attribute.Value.Split(',');
|
string[] names = attribute.Value.Split(',');
|
||||||
targetNames = new string[names.Length];
|
targetNames = new HashSet<string>();
|
||||||
for (int i=0; i < names.Length; i++ )
|
for (int i=0; i < names.Length; i++ )
|
||||||
{
|
{
|
||||||
targetNames[i] = names[i].Trim();
|
targetNames.Add(names[i].Trim());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "sound":
|
case "sound":
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
static class DebugConsole
|
static class DebugConsole
|
||||||
{
|
{
|
||||||
const int MaxMessages = 100;
|
const int MaxMessages = 200;
|
||||||
|
|
||||||
public static List<ColoredText> Messages = new List<ColoredText>();
|
public static List<ColoredText> Messages = new List<ColoredText>();
|
||||||
|
|
||||||
@@ -757,6 +757,11 @@ namespace Barotrauma
|
|||||||
//listbox not created yet, don't attempt to add
|
//listbox not created yet, don't attempt to add
|
||||||
if (listBox == null) return;
|
if (listBox == null) return;
|
||||||
|
|
||||||
|
if (listBox.children.Count > MaxMessages)
|
||||||
|
{
|
||||||
|
listBox.children.RemoveRange(0, listBox.children.Count - MaxMessages);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
|
var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, GUI.Style, Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
|
||||||
|
|||||||
@@ -17,7 +17,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private string[] descriptions;
|
private string[] descriptions;
|
||||||
|
|
||||||
private static string[] teamNames;
|
private static string[] teamNames = { "Team A", "Team B" };
|
||||||
|
|
||||||
|
public override bool AllowRespawn
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
public override string Description
|
public override string Description
|
||||||
{
|
{
|
||||||
@@ -126,11 +131,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Start(Level level)
|
public override void Start(Level level)
|
||||||
{
|
{
|
||||||
if (GameMain.Server != null)
|
|
||||||
{
|
|
||||||
GameMain.Server.AllowRespawn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GameMain.NetworkMember == null)
|
if (GameMain.NetworkMember == null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Combat missions cannot be played in the single player mode.");
|
DebugConsole.ThrowError("Combat missions cannot be played in the single player mode.");
|
||||||
@@ -154,11 +154,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (crews[0].Count == 0 && crews[1].Count == 0)
|
if (crews[0].Count == 0 && crews[1].Count == 0)
|
||||||
{
|
{
|
||||||
if (GameMain.Server != null)
|
|
||||||
{
|
|
||||||
GameMain.Server.AllowRespawn = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Character character in Character.CharacterList)
|
foreach (Character character in Character.CharacterList)
|
||||||
{
|
{
|
||||||
if (character.TeamID == 1)
|
if (character.TeamID == 1)
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ namespace Barotrauma
|
|||||||
set { completed = value; }
|
set { completed = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool AllowRespawn
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string RadarLabel
|
public virtual string RadarLabel
|
||||||
{
|
{
|
||||||
get { return radarLabel; }
|
get { return radarLabel; }
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ namespace Barotrauma.Items.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ItemSound> matchingSounds = null;
|
List<ItemSound> matchingSounds;
|
||||||
if (!sounds.TryGetValue(type, out matchingSounds)) return;
|
if (!sounds.TryGetValue(type, out matchingSounds)) return;
|
||||||
|
|
||||||
ItemSound itemSound = null;
|
ItemSound itemSound = null;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
@@ -14,7 +15,7 @@ namespace Barotrauma.Items.Components
|
|||||||
List<RelatedItem> containableItems;
|
List<RelatedItem> containableItems;
|
||||||
public ItemInventory Inventory;
|
public ItemInventory Inventory;
|
||||||
|
|
||||||
private bool hasStatusEffects;
|
private List<Pair<Item, StatusEffect>> itemsWithStatusEffects;
|
||||||
|
|
||||||
//how many items can be contained
|
//how many items can be contained
|
||||||
[HasDefaultValue(5, false)]
|
[HasDefaultValue(5, false)]
|
||||||
@@ -111,23 +112,38 @@ namespace Barotrauma.Items.Components
|
|||||||
RelatedItem containable = RelatedItem.Load(subElement);
|
RelatedItem containable = RelatedItem.Load(subElement);
|
||||||
if (containable == null) continue;
|
if (containable == null) continue;
|
||||||
|
|
||||||
foreach (StatusEffect effect in containable.statusEffects)
|
|
||||||
{
|
|
||||||
if (effect.type == ActionType.OnContaining) hasStatusEffects = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
containableItems.Add(containable);
|
containableItems.Add(containable);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsActive = true;
|
itemsWithStatusEffects = new List<Pair<Item, StatusEffect>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveContained(Item item)
|
public void OnItemContained(Item item)
|
||||||
{
|
{
|
||||||
Inventory.RemoveItem(item);
|
item.SetContainedItemPositions();
|
||||||
|
|
||||||
|
RelatedItem ri = containableItems.Find(x => x.MatchesItem(item));
|
||||||
|
if (ri != null)
|
||||||
|
{
|
||||||
|
foreach (StatusEffect effect in ri.statusEffects)
|
||||||
|
{
|
||||||
|
itemsWithStatusEffects.Add(Pair<Item, StatusEffect>.Create(item, effect));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//no need to Update() if this item has no statuseffects and no physics body
|
||||||
|
IsActive = itemsWithStatusEffects.Count > 0 || item.body != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnItemRemoved(Item item)
|
||||||
|
{
|
||||||
|
itemsWithStatusEffects.RemoveAll(i => i.First == item);
|
||||||
|
|
||||||
|
//deactivate if the inventory is empty
|
||||||
|
IsActive = itemsWithStatusEffects.Count > 0 || item.body != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanBeContained(Item item)
|
public bool CanBeContained(Item item)
|
||||||
@@ -138,31 +154,24 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
if (item.body != null && item.body.FarseerBody.Awake)
|
if (item.body != null &&
|
||||||
|
item.body.Enabled &&
|
||||||
|
item.body.FarseerBody.Awake)
|
||||||
{
|
{
|
||||||
foreach (Item contained in Inventory.Items)
|
item.SetContainedItemPositions();
|
||||||
{
|
|
||||||
if (contained == null) continue;
|
|
||||||
contained.SetTransform(item.SimPosition, 0.0f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasStatusEffects) return;
|
foreach (Pair<Item, StatusEffect> itemAndEffect in itemsWithStatusEffects)
|
||||||
|
|
||||||
foreach (Item contained in Inventory.Items)
|
|
||||||
{
|
{
|
||||||
if (contained == null || contained.Condition <= 0.0f) continue;
|
Item contained = itemAndEffect.First;
|
||||||
|
if (contained.Condition < 0.0f) continue;
|
||||||
|
|
||||||
RelatedItem ri = containableItems.Find(x => x.MatchesItem(contained));
|
StatusEffect effect = itemAndEffect.Second;
|
||||||
if (ri == null) continue;
|
|
||||||
|
|
||||||
foreach (StatusEffect effect in ri.statusEffects)
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
||||||
{
|
effect.Apply(ActionType.OnContaining, deltaTime, item, item.AllPropertyObjects);
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.This)) effect.Apply(ActionType.OnContaining, deltaTime, item, item.AllPropertyObjects);
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained)) effect.Apply(ActionType.OnContaining, deltaTime, item, contained.AllPropertyObjects);
|
effect.Apply(ActionType.OnContaining, deltaTime, item, contained.AllPropertyObjects);
|
||||||
}
|
|
||||||
|
|
||||||
//contained.ApplyStatusEffects(ActionType.OnContained, deltaTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,14 +241,12 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override bool Combine(Item item)
|
public override bool Combine(Item item)
|
||||||
{
|
{
|
||||||
if (containableItems.Find(x => x.MatchesItem(item)) == null) return false;
|
if (!containableItems.Any(x => x.MatchesItem(item))) return false;
|
||||||
|
|
||||||
if (Inventory.TryPutItem(item))
|
if (Inventory.TryPutItem(item))
|
||||||
{
|
{
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
if (hideItems || (item.body!=null && !item.body.Enabled)) item.body.Enabled = false;
|
if (hideItems && item.body != null) item.body.Enabled = false;
|
||||||
|
|
||||||
//item.Container = this.item;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ namespace Barotrauma.Items.Components
|
|||||||
//affects how fast changes in power/load are carried over the grid
|
//affects how fast changes in power/load are carried over the grid
|
||||||
static float inertia = 5.0f;
|
static float inertia = 5.0f;
|
||||||
|
|
||||||
static List<Powered> connectedList = new List<Powered>();
|
static HashSet<Powered> connectedList = new HashSet<Powered>();
|
||||||
|
|
||||||
|
private List<Connection> powerConnections;
|
||||||
|
|
||||||
private float powerLoad;
|
private float powerLoad;
|
||||||
|
|
||||||
@@ -35,24 +37,27 @@ namespace Barotrauma.Items.Components
|
|||||||
: base(item, element)
|
: base(item, element)
|
||||||
{
|
{
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
|
|
||||||
|
powerConnections = new List<Connection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
//reset and recalculate the power generated/consumed
|
|
||||||
//by the constructions connected to the grid
|
|
||||||
fullPower = 0.0f;
|
|
||||||
fullLoad = 0.0f;
|
|
||||||
connectedList.Clear();
|
|
||||||
|
|
||||||
if (updateTimer > 0)
|
if (updateTimer > 0)
|
||||||
{
|
{
|
||||||
|
//this junction box has already been updated this frame
|
||||||
updateTimer--;
|
updateTimer--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckJunctions(deltaTime);
|
//reset and recalculate the power generated/consumed
|
||||||
|
//by the constructions connected to the grid
|
||||||
|
fullPower = 0.0f;
|
||||||
|
fullLoad = 0.0f;
|
||||||
updateTimer = 0;
|
updateTimer = 0;
|
||||||
|
connectedList.Clear();
|
||||||
|
|
||||||
|
CheckJunctions(deltaTime);
|
||||||
|
|
||||||
foreach (Powered p in connectedList)
|
foreach (Powered p in connectedList)
|
||||||
{
|
{
|
||||||
@@ -69,7 +74,6 @@ namespace Barotrauma.Items.Components
|
|||||||
if (GameMain.Client != null) continue;
|
if (GameMain.Client != null) continue;
|
||||||
if (-pt.currPowerConsumption < Math.Max(pt.powerLoad * Rand.Range(1.9f,2.1f), 200.0f)) continue;
|
if (-pt.currPowerConsumption < Math.Max(pt.powerLoad * Rand.Range(1.9f,2.1f), 200.0f)) continue;
|
||||||
|
|
||||||
|
|
||||||
float prevCondition = pt.item.Condition;
|
float prevCondition = pt.item.Condition;
|
||||||
pt.item.Condition -= deltaTime * 10.0f;
|
pt.item.Condition -= deltaTime * 10.0f;
|
||||||
|
|
||||||
@@ -109,37 +113,31 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||||
|
|
||||||
List<Connection> connections = item.Connections;
|
foreach (Connection c in powerConnections)
|
||||||
if (connections == null) return;
|
|
||||||
|
|
||||||
foreach (Connection c in connections)
|
|
||||||
{
|
{
|
||||||
if (!c.IsPower) continue;
|
|
||||||
|
|
||||||
var recipients = c.Recipients;
|
var recipients = c.Recipients;
|
||||||
|
|
||||||
foreach (Connection recipient in recipients)
|
foreach (Connection recipient in recipients)
|
||||||
{
|
{
|
||||||
if (recipient == null || !c.IsPower) continue;
|
if (recipient == null) continue;
|
||||||
|
|
||||||
Item it = recipient.Item;
|
Item it = recipient.Item;
|
||||||
if (it == null) continue;
|
if (it == null) continue;
|
||||||
|
|
||||||
//if (it.Updated) continue;
|
|
||||||
|
|
||||||
Powered powered = it.GetComponent<Powered>();
|
Powered powered = it.GetComponent<Powered>();
|
||||||
if (powered == null || !powered.IsActive) continue;
|
if (powered == null || !powered.IsActive) continue;
|
||||||
|
|
||||||
if (connectedList.Contains(powered)) continue;
|
if (connectedList.Contains(powered)) continue;
|
||||||
|
|
||||||
PowerTransfer powerTransfer = powered as PowerTransfer;
|
PowerTransfer powerTransfer = powered as PowerTransfer;
|
||||||
PowerContainer powerContainer = powered as PowerContainer;
|
|
||||||
if (powerTransfer != null)
|
if (powerTransfer != null)
|
||||||
{
|
{
|
||||||
//if (powerTransfer.updateTimer>0) continue;
|
|
||||||
powerTransfer.CheckJunctions(deltaTime);
|
powerTransfer.CheckJunctions(deltaTime);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (powerContainer != null)
|
|
||||||
|
PowerContainer powerContainer = powered as PowerContainer;
|
||||||
|
if (powerContainer != null)
|
||||||
{
|
{
|
||||||
if (recipient.Name == "power_in")
|
if (recipient.Name == "power_in")
|
||||||
{
|
{
|
||||||
@@ -187,6 +185,19 @@ namespace Barotrauma.Items.Components
|
|||||||
GuiFrame.Update(1.0f / 60.0f);
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnMapLoaded()
|
||||||
|
{
|
||||||
|
var connections = item.Connections;
|
||||||
|
if (connections == null)
|
||||||
|
{
|
||||||
|
IsActive = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
powerConnections = connections.FindAll(c => c.IsPower);
|
||||||
|
if (powerConnections.Count == 0) IsActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power)
|
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power)
|
||||||
{
|
{
|
||||||
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
||||||
|
|||||||
@@ -10,6 +10,47 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
class Wire : ItemComponent, IDrawableComponent
|
class Wire : ItemComponent, IDrawableComponent
|
||||||
{
|
{
|
||||||
|
class WireSection
|
||||||
|
{
|
||||||
|
private Vector2 start;
|
||||||
|
|
||||||
|
private float angle;
|
||||||
|
private float length;
|
||||||
|
|
||||||
|
public WireSection(Vector2 start, Vector2 end)
|
||||||
|
{
|
||||||
|
this.start = start;
|
||||||
|
|
||||||
|
angle = MathUtils.VectorToAngle(end - start);
|
||||||
|
length = Vector2.Distance(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(SpriteBatch spriteBatch, Color color, Vector2 offset, float depth, float width = 0.3f)
|
||||||
|
{
|
||||||
|
spriteBatch.Draw(wireSprite.Texture,
|
||||||
|
new Vector2(start.X+offset.X, -(start.Y+offset.Y)), null, color,
|
||||||
|
-angle,
|
||||||
|
new Vector2(0.0f, wireSprite.size.Y / 2.0f),
|
||||||
|
new Vector2(length / wireSprite.Texture.Width, width),
|
||||||
|
SpriteEffects.None,
|
||||||
|
depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Draw(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color, float depth, float width = 0.3f)
|
||||||
|
{
|
||||||
|
start.Y = -start.Y;
|
||||||
|
end.Y = -end.Y;
|
||||||
|
|
||||||
|
spriteBatch.Draw(wireSprite.Texture,
|
||||||
|
start, null, color,
|
||||||
|
MathUtils.VectorToAngle(end - start),
|
||||||
|
new Vector2(0.0f, wireSprite.size.Y / 2.0f),
|
||||||
|
new Vector2((Vector2.Distance(start, end)) / wireSprite.Texture.Width, width),
|
||||||
|
SpriteEffects.None,
|
||||||
|
depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const float nodeDistance = 32.0f;
|
const float nodeDistance = 32.0f;
|
||||||
const float heightFromFloor = 128.0f;
|
const float heightFromFloor = 128.0f;
|
||||||
|
|
||||||
@@ -17,6 +58,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public List<Vector2> Nodes;
|
public List<Vector2> Nodes;
|
||||||
|
|
||||||
|
private List<WireSection> sections;
|
||||||
|
|
||||||
Connection[] connections;
|
Connection[] connections;
|
||||||
|
|
||||||
private Vector2 newNodePos;
|
private Vector2 newNodePos;
|
||||||
@@ -41,20 +84,13 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
Nodes = new List<Vector2>();
|
Nodes = new List<Vector2>();
|
||||||
|
sections = new List<WireSection>();
|
||||||
|
|
||||||
connections = new Connection[2];
|
connections = new Connection[2];
|
||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(Vector2 amount)
|
|
||||||
{
|
|
||||||
//for (int i = 0; i < Nodes.Count; i++)
|
|
||||||
//{
|
|
||||||
// Nodes[i] += amount;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection OtherConnection(Connection connection)
|
public Connection OtherConnection(Connection connection)
|
||||||
{
|
{
|
||||||
if (connection == null) return null;
|
if (connection == null) return null;
|
||||||
@@ -127,7 +163,6 @@ namespace Barotrauma.Items.Components
|
|||||||
if (Nodes.Count > 1 && Nodes[Nodes.Count-1] == newConnection.Item.Position - newConnection.Item.Submarine.HiddenSubPosition) break;
|
if (Nodes.Count > 1 && Nodes[Nodes.Count-1] == newConnection.Item.Position - newConnection.Item.Submarine.HiddenSubPosition) break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
Nodes.Insert(0, newConnection.Item.Position - newConnection.Item.Submarine.HiddenSubPosition);
|
Nodes.Insert(0, newConnection.Item.Position - newConnection.Item.Submarine.HiddenSubPosition);
|
||||||
@@ -143,7 +178,6 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (connections[0] != null && connections[1] != null)
|
if (connections[0] != null && connections[1] != null)
|
||||||
{
|
{
|
||||||
//List<Vector2> prevNodes = new List<Vector2>(Nodes);
|
|
||||||
foreach (ItemComponent ic in item.components)
|
foreach (ItemComponent ic in item.components)
|
||||||
{
|
{
|
||||||
if (ic == this) continue;
|
if (ic == this) continue;
|
||||||
@@ -155,12 +189,12 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
|
|
||||||
//Nodes = prevNodes;
|
|
||||||
CleanNodes();
|
CleanNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable = Nodes.Any();
|
Drawable = Nodes.Any();
|
||||||
|
|
||||||
|
UpdateSections();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,28 +224,11 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (Nodes.Count == 0) return;
|
if (Nodes.Count == 0) return;
|
||||||
|
|
||||||
//item.FindHull();
|
|
||||||
|
|
||||||
//Vector2 position = item.Position;
|
|
||||||
|
|
||||||
//position.X = MathUtils.Round(item.Position.X, nodeDistance);
|
|
||||||
//if (item.CurrentHull == null)
|
|
||||||
//{
|
|
||||||
// position.Y = MathUtils.Round(item.Position.Y, nodeDistance);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// position.Y -= item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
|
|
||||||
// position.Y = Math.Max(MathUtils.Round(position.Y, nodeDistance), heightFromFloor);
|
|
||||||
// position.Y += item.CurrentHull.Rect.Y - item.CurrentHull.Rect.Height;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
Submarine sub = null;
|
Submarine sub = null;
|
||||||
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
|
if (connections[0] != null && connections[0].Item.Submarine != null) sub = connections[0].Item.Submarine;
|
||||||
if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
|
if (connections[1] != null && connections[1].Item.Submarine != null) sub = connections[1].Item.Submarine;
|
||||||
|
|
||||||
if (item.Submarine != sub)
|
if (item.Submarine != sub && Screen.Selected != GameMain.EditMapScreen)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
ClearConnections();
|
||||||
Nodes.Clear();
|
Nodes.Clear();
|
||||||
@@ -219,20 +236,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
newNodePos = RoundNode(item.Position, item.CurrentHull) - sub.HiddenSubPosition;
|
||||||
|
|
||||||
//if (Vector2.Distance(position, nodes[nodes.Count - 1]) > nodeDistance*10)
|
|
||||||
//{
|
|
||||||
// nodes.Add(position);
|
|
||||||
|
|
||||||
// item.NewComponentEvent(this, true);
|
|
||||||
//}
|
|
||||||
//else if (Math.Abs(position.Y - nodes[nodes.Count - 1].Y) > nodeDistance)
|
|
||||||
//{
|
|
||||||
// nodes.Add(new Vector2(nodes[nodes.Count - 1].X,
|
|
||||||
// position.Y));
|
|
||||||
|
|
||||||
// item.NewComponentEvent(this, true);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Use(float deltaTime, Character character = null)
|
public override bool Use(float deltaTime, Character character = null)
|
||||||
@@ -242,6 +245,8 @@ namespace Barotrauma.Items.Components
|
|||||||
if (newNodePos!= Vector2.Zero && Nodes.Count>0 && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
|
if (newNodePos!= Vector2.Zero && Nodes.Count>0 && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
|
||||||
{
|
{
|
||||||
Nodes.Add(newNodePos);
|
Nodes.Add(newNodePos);
|
||||||
|
UpdateSections();
|
||||||
|
|
||||||
Drawable = true;
|
Drawable = true;
|
||||||
|
|
||||||
newNodePos = Vector2.Zero;
|
newNodePos = Vector2.Zero;
|
||||||
@@ -254,6 +259,7 @@ namespace Barotrauma.Items.Components
|
|||||||
if (Nodes.Count > 1)
|
if (Nodes.Count > 1)
|
||||||
{
|
{
|
||||||
Nodes.RemoveAt(Nodes.Count - 1);
|
Nodes.RemoveAt(Nodes.Count - 1);
|
||||||
|
UpdateSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable = Nodes.Any();
|
Drawable = Nodes.Any();
|
||||||
@@ -266,9 +272,20 @@ namespace Barotrauma.Items.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateSections()
|
||||||
|
{
|
||||||
|
sections.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < Nodes.Count-1; i++)
|
||||||
|
{
|
||||||
|
sections.Add(new WireSection(Nodes[i], Nodes[i + 1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ClearConnections()
|
private void ClearConnections()
|
||||||
{
|
{
|
||||||
Nodes.Clear();
|
Nodes.Clear();
|
||||||
|
sections.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
@@ -288,8 +305,6 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (Screen.Selected == GameMain.EditMapScreen)
|
if (Screen.Selected == GameMain.EditMapScreen)
|
||||||
{
|
{
|
||||||
//position = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition) - Submarine.Loaded.Position;// Nodes[(int)selectedNodeIndex];
|
|
||||||
|
|
||||||
position.X = MathUtils.Round(position.X, Submarine.GridSize.X / 2.0f);
|
position.X = MathUtils.Round(position.X, Submarine.GridSize.X / 2.0f);
|
||||||
position.Y = MathUtils.Round(position.Y, Submarine.GridSize.Y / 2.0f);
|
position.Y = MathUtils.Round(position.Y, Submarine.GridSize.Y / 2.0f);
|
||||||
}
|
}
|
||||||
@@ -345,35 +360,42 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||||
{
|
{
|
||||||
//for (int i = 0; i < nodes.Count; i++)
|
|
||||||
//{
|
|
||||||
// GUI.DrawRectangle(spriteBatch, new Rectangle((int)nodes[i].X, (int)-nodes[i].Y, 5, 5), Color.DarkGray, true, wireSprite.Depth - 0.01f);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (!Nodes.Any())
|
if (!Nodes.Any())
|
||||||
{
|
{
|
||||||
Drawable = false;
|
Drawable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 drawOffset = Vector2.Zero;
|
||||||
|
if (item.Submarine != null)
|
||||||
|
{
|
||||||
|
drawOffset = item.Submarine.DrawPosition + item.Submarine.HiddenSubPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
float depth = wireSprite.Depth + ((item.ID % 100) * 0.00001f);
|
||||||
|
|
||||||
if (item.IsHighlighted)
|
if (item.IsHighlighted)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < Nodes.Count; i++)
|
foreach (WireSection section in sections)
|
||||||
{
|
{
|
||||||
DrawSection(spriteBatch, Nodes[i], Nodes[i - 1], Color.Gold, 0.5f);
|
section.Draw(spriteBatch, Color.Gold, drawOffset, depth, 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < Nodes.Count; i++)
|
foreach (WireSection section in sections)
|
||||||
{
|
{
|
||||||
DrawSection(spriteBatch, Nodes[i], Nodes[i - 1], item.Color);
|
section.Draw(spriteBatch, item.Color, drawOffset, depth, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsActive && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
|
if (IsActive && Vector2.Distance(newNodePos, Nodes[Nodes.Count - 1]) > nodeDistance)
|
||||||
{
|
{
|
||||||
DrawSection(spriteBatch, Nodes[Nodes.Count - 1], newNodePos, item.Color * 0.5f);
|
WireSection.Draw(
|
||||||
//nodes.Add(newNodePos);
|
spriteBatch,
|
||||||
|
new Vector2(Nodes[Nodes.Count - 1].X, Nodes[Nodes.Count - 1].Y) + drawOffset,
|
||||||
|
new Vector2(newNodePos.X, newNodePos.Y) + drawOffset,
|
||||||
|
item.Color * 0.5f,
|
||||||
|
depth,
|
||||||
|
0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!editing || !PlayerInput.MouseInsideWindow || !GameMain.EditMapScreen.WiringMode) return;
|
if (!editing || !PlayerInput.MouseInsideWindow || !GameMain.EditMapScreen.WiringMode) return;
|
||||||
@@ -395,7 +417,6 @@ namespace Barotrauma.Items.Components
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f);
|
GUI.DrawRectangle(spriteBatch, worldPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f);
|
||||||
|
|
||||||
if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny)
|
if (selectedNodeIndex == null && draggingWire == null)// && !MapEntity.SelectedAny)
|
||||||
@@ -447,26 +468,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color, float width = 0.3f)
|
|
||||||
{
|
|
||||||
if (item.Submarine != null)
|
|
||||||
{
|
|
||||||
start += item.Submarine.DrawPosition + item.Submarine.HiddenSubPosition;
|
|
||||||
end += item.Submarine.DrawPosition + item.Submarine.HiddenSubPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
start.Y = -start.Y;
|
|
||||||
end.Y = -end.Y;
|
|
||||||
|
|
||||||
spriteBatch.Draw(wireSprite.Texture,
|
|
||||||
start, null, color,
|
|
||||||
MathUtils.VectorToAngle(end - start),
|
|
||||||
new Vector2(0.0f, wireSprite.size.Y / 2.0f),
|
|
||||||
new Vector2((Vector2.Distance(start, end)) / wireSprite.Texture.Width, width),
|
|
||||||
SpriteEffects.None,
|
|
||||||
wireSprite.Depth + ((item.ID % 100) * 0.00001f));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FlipX()
|
public override void FlipX()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Nodes.Count; i++)
|
for (int i = 0; i < Nodes.Count; i++)
|
||||||
|
|||||||
@@ -168,9 +168,8 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
base.Update(deltaTime, cam);
|
|
||||||
|
|
||||||
item.SetTransform(picker.SimPosition, 0.0f);
|
item.SetTransform(picker.SimPosition, 0.0f);
|
||||||
|
item.SetContainedItemPositions();
|
||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static bool ShowLinks = true;
|
public static bool ShowLinks = true;
|
||||||
|
|
||||||
private List<string> tags;
|
private HashSet<string> tags;
|
||||||
|
|
||||||
public Hull CurrentHull;
|
public Hull CurrentHull;
|
||||||
|
|
||||||
@@ -52,6 +52,9 @@ namespace Barotrauma
|
|||||||
private bool inWater;
|
private bool inWater;
|
||||||
|
|
||||||
private Inventory parentInventory;
|
private Inventory parentInventory;
|
||||||
|
private Inventory ownInventory;
|
||||||
|
|
||||||
|
private Dictionary<string, Connection> connections;
|
||||||
|
|
||||||
//a dictionary containing lists of the status effects in all the components of the item
|
//a dictionary containing lists of the status effects in all the components of the item
|
||||||
private Dictionary<ActionType, List<StatusEffect>> statusEffectLists;
|
private Dictionary<ActionType, List<StatusEffect>> statusEffectLists;
|
||||||
@@ -276,8 +279,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
ItemContainer c = GetComponent<ItemContainer>();
|
return (ownInventory == null) ? null : Array.FindAll(ownInventory.Items, i => i != null);
|
||||||
return (c == null) ? null : Array.FindAll(c.Inventory.Items, i=>i!=null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +329,7 @@ namespace Barotrauma
|
|||||||
components = new List<ItemComponent>();
|
components = new List<ItemComponent>();
|
||||||
drawableComponents = new List<IDrawableComponent>();
|
drawableComponents = new List<IDrawableComponent>();
|
||||||
FixRequirements = new List<FixRequirement>();
|
FixRequirements = new List<FixRequirement>();
|
||||||
tags = new List<string>();
|
tags = new HashSet<string>();
|
||||||
|
|
||||||
rect = newRect;
|
rect = newRect;
|
||||||
|
|
||||||
@@ -402,6 +404,12 @@ namespace Barotrauma
|
|||||||
if (body != null) body.FarseerBody.OnCollision += OnCollision;
|
if (body != null) body.FarseerBody.OnCollision += OnCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var itemContainer = GetComponent<ItemContainer>();
|
||||||
|
if (itemContainer!=null)
|
||||||
|
{
|
||||||
|
ownInventory = itemContainer.Inventory;
|
||||||
|
}
|
||||||
|
|
||||||
InsertToList();
|
InsertToList();
|
||||||
ItemList.Add(this);
|
ItemList.Add(this);
|
||||||
}
|
}
|
||||||
@@ -429,15 +437,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void RemoveContained(Item contained)
|
public void RemoveContained(Item contained)
|
||||||
{
|
{
|
||||||
ItemContainer c = GetComponent<ItemContainer>();
|
if (ownInventory != null)
|
||||||
if (c == null) return;
|
{
|
||||||
|
ownInventory.RemoveItem(contained);
|
||||||
|
}
|
||||||
|
|
||||||
c.RemoveContained(contained);
|
|
||||||
contained.Container = null;
|
contained.Container = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetTransform(Vector2 simPosition, float rotation)
|
public void SetTransform(Vector2 simPosition, float rotation, bool findNewHull = true)
|
||||||
{
|
{
|
||||||
if (body != null)
|
if (body != null)
|
||||||
{
|
{
|
||||||
@@ -458,7 +467,7 @@ namespace Barotrauma
|
|||||||
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
||||||
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
|
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
|
||||||
|
|
||||||
FindHull();
|
if (findNewHull) FindHull();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(Vector2 amount)
|
public override void Move(Vector2 amount)
|
||||||
@@ -546,6 +555,33 @@ namespace Barotrauma
|
|||||||
return rootContainer;
|
return rootContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetContainedItemPositions()
|
||||||
|
{
|
||||||
|
if (ownInventory == null) return;
|
||||||
|
|
||||||
|
Vector2 simPos = SimPosition;
|
||||||
|
Vector2 displayPos = Position;
|
||||||
|
|
||||||
|
foreach (Item contained in ownInventory.Items)
|
||||||
|
{
|
||||||
|
if (contained == null) continue;
|
||||||
|
|
||||||
|
if (contained.body != null)
|
||||||
|
{
|
||||||
|
contained.body.FarseerBody.SetTransformIgnoreContacts(ref simPos, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
contained.Rect =
|
||||||
|
new Rectangle(
|
||||||
|
(int)(displayPos.X - contained.Rect.Width / 2.0f),
|
||||||
|
(int)(displayPos.Y + contained.Rect.Height / 2.0f),
|
||||||
|
contained.Rect.Width, contained.Rect.Height);
|
||||||
|
|
||||||
|
contained.Submarine = Submarine;
|
||||||
|
contained.CurrentHull = CurrentHull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AddTag(string tag)
|
public void AddTag(string tag)
|
||||||
{
|
{
|
||||||
if (tags.Contains(tag)) return;
|
if (tags.Contains(tag)) return;
|
||||||
@@ -581,16 +617,15 @@ namespace Barotrauma
|
|||||||
bool hasTargets = (effect.TargetNames == null);
|
bool hasTargets = (effect.TargetNames == null);
|
||||||
|
|
||||||
Item[] containedItems = ContainedItems;
|
Item[] containedItems = ContainedItems;
|
||||||
if (effect.OnContainingNames!=null)
|
if (effect.OnContainingNames != null)
|
||||||
{
|
{
|
||||||
foreach (string s in effect.OnContainingNames)
|
foreach (string s in effect.OnContainingNames)
|
||||||
{
|
{
|
||||||
if (containedItems.FirstOrDefault(x => x!=null && x.Name==s && x.Condition>0.0f) == null) return;
|
if (!containedItems.Any(x => x!=null && x.Name==s && x.Condition > 0.0f)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IPropertyObject> targets = new List<IPropertyObject>();
|
List<IPropertyObject> targets = new List<IPropertyObject>();
|
||||||
|
|
||||||
if (containedItems != null)
|
if (containedItems != null)
|
||||||
{
|
{
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Contained))
|
||||||
@@ -693,7 +728,6 @@ namespace Barotrauma
|
|||||||
ic.Update(deltaTime, cam);
|
ic.Update(deltaTime, cam);
|
||||||
|
|
||||||
if (ic.IsActive) ic.PlaySound(ActionType.OnActive, WorldPosition);
|
if (ic.IsActive) ic.PlaySound(ActionType.OnActive, WorldPosition);
|
||||||
//ic.ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -704,7 +738,7 @@ namespace Barotrauma
|
|||||||
inWater = IsInWater();
|
inWater = IsInWater();
|
||||||
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
|
if (inWater) ApplyStatusEffects(ActionType.InWater, deltaTime);
|
||||||
|
|
||||||
isHighlighted = false;
|
isHighlighted = false;
|
||||||
|
|
||||||
if (body == null || !body.Enabled) return;
|
if (body == null || !body.Enabled) return;
|
||||||
|
|
||||||
@@ -723,11 +757,11 @@ namespace Barotrauma
|
|||||||
body.SetTransform(body.SimPosition - Submarine.SimPosition, body.Rotation);
|
body.SetTransform(body.SimPosition - Submarine.SimPosition, body.Rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 moveAmount = body.SimPosition - body.LastSentPosition;
|
//Vector2 moveAmount = body.SimPosition - body.LastSentPosition;
|
||||||
if (parentInventory == null && moveAmount != Vector2.Zero && moveAmount.Length() > NetConfig.ItemPosUpdateDistance)
|
//if (parentInventory == null && moveAmount != Vector2.Zero && moveAmount.Length() > NetConfig.ItemPosUpdateDistance)
|
||||||
{
|
//{
|
||||||
|
// new NetworkEvent(NetworkEventType.PhysicsBodyPosition, ID, false);
|
||||||
}
|
//}
|
||||||
|
|
||||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
||||||
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
||||||
@@ -1152,24 +1186,22 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void SendSignal(int stepsTaken, string signal, string connectionName, float power = 0.0f)
|
public void SendSignal(int stepsTaken, string signal, string connectionName, float power = 0.0f)
|
||||||
{
|
{
|
||||||
|
if (connections == null) return;
|
||||||
|
|
||||||
stepsTaken++;
|
stepsTaken++;
|
||||||
|
|
||||||
ConnectionPanel panel = GetComponent<ConnectionPanel>();
|
Connection c = null;
|
||||||
if (panel == null) return;
|
if (!connections.TryGetValue(connectionName, out c)) return;
|
||||||
foreach (Connection c in panel.Connections)
|
|
||||||
{
|
|
||||||
if (c.Name != connectionName) continue;
|
|
||||||
|
|
||||||
if (stepsTaken > 10)
|
if (stepsTaken > 10)
|
||||||
{
|
{
|
||||||
//use a coroutine to prevent infinite loops by creating a one
|
//use a coroutine to prevent infinite loops by creating a one
|
||||||
//frame delay if the "signal chain" gets too long
|
//frame delay if the "signal chain" gets too long
|
||||||
CoroutineManager.StartCoroutine(SendSignal(signal, c, power));
|
CoroutineManager.StartCoroutine(SendSignal(signal, c, power));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c.SendSignal(stepsTaken, signal, this, power);
|
c.SendSignal(stepsTaken, signal, this, power);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1178,9 +1210,6 @@ namespace Barotrauma
|
|||||||
//wait one frame
|
//wait one frame
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
ConnectionPanel panel = GetComponent<ConnectionPanel>();
|
|
||||||
if (panel == null) yield return CoroutineStatus.Success;
|
|
||||||
|
|
||||||
connection.SendSignal(0, signal, this, power);
|
connection.SendSignal(0, signal, this, power);
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
@@ -1761,6 +1790,17 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
ic.OnMapLoaded();
|
ic.OnMapLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//cache connections into a dictionary for faster lookups
|
||||||
|
var connectionPanel = GetComponent<ConnectionPanel>();
|
||||||
|
connections = new Dictionary<string, Connection>();
|
||||||
|
|
||||||
|
if (connectionPanel == null) return;
|
||||||
|
foreach (Connection c in connectionPanel.Connections)
|
||||||
|
{
|
||||||
|
if (!connections.ContainsKey(c.Name))
|
||||||
|
connections.Add(c.Name, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,28 @@ namespace Barotrauma
|
|||||||
return (item!=null && Items[i]==null && container.CanBeContained(item));
|
return (item!=null && Items[i]==null && container.CanBeContained(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool TryPutItem(Item item, System.Collections.Generic.List<InvSlotType> allowedSlots = null)
|
||||||
|
{
|
||||||
|
bool wasPut = base.TryPutItem(item, allowedSlots);
|
||||||
|
|
||||||
|
if (wasPut)
|
||||||
|
{
|
||||||
|
foreach (Character c in Character.CharacterList)
|
||||||
|
{
|
||||||
|
if (!c.HasSelectedItem(item)) continue;
|
||||||
|
|
||||||
|
item.Unequip(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.IsActive = true;
|
||||||
|
container.OnItemContained(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wasPut;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool TryPutItem(Item item, int i, bool allowSwapping)
|
public override bool TryPutItem(Item item, int i, bool allowSwapping)
|
||||||
{
|
{
|
||||||
bool wasPut = base.TryPutItem(item, i, allowSwapping);
|
bool wasPut = base.TryPutItem(item, i, allowSwapping);
|
||||||
@@ -57,11 +79,18 @@ namespace Barotrauma
|
|||||||
item.Unequip(c);
|
item.Unequip(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//item.Container = container.Item;
|
|
||||||
container.IsActive = true;
|
container.IsActive = true;
|
||||||
|
container.OnItemContained(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wasPut;
|
return wasPut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void RemoveItem(Item item)
|
||||||
|
{
|
||||||
|
base.RemoveItem(item);
|
||||||
|
container.OnItemRemoved(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
private static List<Submarine> loaded = new List<Submarine>();
|
private static List<Submarine> loaded = new List<Submarine>();
|
||||||
|
|
||||||
|
private static List<MapEntity> visibleEntities;
|
||||||
|
|
||||||
private SubmarineBody subBody;
|
private SubmarineBody subBody;
|
||||||
|
|
||||||
public readonly List<Submarine> DockedTo;
|
public readonly List<Submarine> DockedTo;
|
||||||
@@ -298,33 +300,70 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//drawing ----------------------------------------------------
|
//drawing ----------------------------------------------------
|
||||||
|
|
||||||
|
public static void CullEntities(Camera cam)
|
||||||
|
{
|
||||||
|
List<Submarine> visibleSubs = new List<Submarine>();
|
||||||
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
|
{
|
||||||
|
Rectangle worldBorders = new Rectangle(
|
||||||
|
sub.Borders.X + (int)sub.WorldPosition.X - 500,
|
||||||
|
sub.Borders.Y + (int)sub.WorldPosition.Y + 500,
|
||||||
|
sub.Borders.Width + 1000,
|
||||||
|
sub.Borders.Height + 1000);
|
||||||
|
|
||||||
|
|
||||||
|
if (Submarine.RectsOverlap(worldBorders, cam.WorldView))
|
||||||
|
{
|
||||||
|
visibleSubs.Add(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
visibleEntities = new List<MapEntity>();
|
||||||
|
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||||
|
{
|
||||||
|
if (me.Submarine == null || visibleSubs.Contains(me.Submarine))
|
||||||
|
{
|
||||||
|
visibleEntities.Add(me);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Draw(SpriteBatch spriteBatch, bool editing = false)
|
public static void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++ )
|
var entitiesToRender = !editing && visibleEntities != null ? visibleEntities : MapEntity.mapEntityList;
|
||||||
|
|
||||||
|
foreach (MapEntity e in entitiesToRender)
|
||||||
{
|
{
|
||||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
e.Draw(spriteBatch, editing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
|
public static void DrawFront(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
var entitiesToRender = !editing && visibleEntities != null ? visibleEntities : MapEntity.mapEntityList;
|
||||||
{
|
|
||||||
if (!MapEntity.mapEntityList[i].DrawOverWater) continue;
|
|
||||||
|
|
||||||
|
foreach (MapEntity e in entitiesToRender)
|
||||||
|
{
|
||||||
|
if (!e.DrawOverWater) continue;
|
||||||
|
|
||||||
if (predicate != null)
|
if (predicate != null)
|
||||||
{
|
{
|
||||||
if (!predicate(MapEntity.mapEntityList[i])) continue;
|
if (!predicate(e)) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
|
e.Draw(spriteBatch, editing, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMain.DebugDraw)
|
if (GameMain.DebugDraw)
|
||||||
{
|
{
|
||||||
foreach (Submarine sub in Submarine.Loaded)
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
{
|
{
|
||||||
|
Rectangle worldBorders = sub.Borders;
|
||||||
|
worldBorders.Location += sub.WorldPosition.ToPoint();
|
||||||
|
worldBorders.Y = -worldBorders.Y;
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch, worldBorders, Color.White, 5);
|
||||||
|
|
||||||
if (sub.subBody.MemPos.Count < 2) continue;
|
if (sub.subBody.MemPos.Count < 2) continue;
|
||||||
|
|
||||||
Vector2 prevPos = ConvertUnits.ToDisplayUnits(sub.subBody.MemPos[0].Position);
|
Vector2 prevPos = ConvertUnits.ToDisplayUnits(sub.subBody.MemPos[0].Position);
|
||||||
@@ -346,10 +385,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
var entitiesToRender = !editing && visibleEntities != null ? visibleEntities : MapEntity.mapEntityList;
|
||||||
|
|
||||||
|
foreach (MapEntity e in entitiesToRender)
|
||||||
{
|
{
|
||||||
if (MapEntity.mapEntityList[i].DrawDamageEffect)
|
if (e.DrawDamageEffect)
|
||||||
MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
|
e.DrawDamage(spriteBatch, damageEffect);
|
||||||
}
|
}
|
||||||
if (damageEffect != null)
|
if (damageEffect != null)
|
||||||
{
|
{
|
||||||
@@ -361,16 +402,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
|
public static void DrawBack(SpriteBatch spriteBatch, bool editing = false, Predicate<MapEntity> predicate = null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
var entitiesToRender = !editing && visibleEntities != null ? visibleEntities : MapEntity.mapEntityList;
|
||||||
|
|
||||||
|
foreach (MapEntity e in entitiesToRender)
|
||||||
{
|
{
|
||||||
if (!MapEntity.mapEntityList[i].DrawBelowWater) continue;
|
if (!e.DrawBelowWater) continue;
|
||||||
|
|
||||||
if (predicate != null)
|
if (predicate != null)
|
||||||
{
|
{
|
||||||
if (!predicate(MapEntity.mapEntityList[i])) continue;
|
if (!predicate(e)) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
|
e.Draw(spriteBatch, editing, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,7 +665,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
subBody.Update(deltaTime);
|
subBody.Update(deltaTime);
|
||||||
|
|
||||||
if (this != MainSub && MainSub.DockedTo.Contains(this)) return;
|
for (int i = 0; i < 2; i++ )
|
||||||
|
{
|
||||||
|
if (Submarine.MainSubs[i] == null) continue;
|
||||||
|
if (this != Submarine.MainSubs[i] && Submarine.MainSubs[i].DockedTo.Contains(this)) return;
|
||||||
|
}
|
||||||
|
|
||||||
//send updates more frequently if moving fast
|
//send updates more frequently if moving fast
|
||||||
networkUpdateTimer -= MathHelper.Clamp(Velocity.Length()*10.0f, 0.1f, 5.0f) * deltaTime;
|
networkUpdateTimer -= MathHelper.Clamp(Velocity.Length()*10.0f, 0.1f, 5.0f) * deltaTime;
|
||||||
@@ -994,6 +1041,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
wire.Nodes[i] -= center;
|
wire.Nodes[i] -= center;
|
||||||
}
|
}
|
||||||
|
wire.UpdateSections();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
@@ -1086,6 +1134,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
loaded.Clear();
|
loaded.Clear();
|
||||||
|
|
||||||
|
visibleEntities = null;
|
||||||
|
|
||||||
if (GameMain.GameScreen.Cam != null) GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
if (GameMain.GameScreen.Cam != null) GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||||
|
|
||||||
Entity.RemoveAll();
|
Entity.RemoveAll();
|
||||||
@@ -1105,6 +1155,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
subBody = null;
|
subBody = null;
|
||||||
|
|
||||||
|
visibleEntities = null;
|
||||||
|
|
||||||
if (MainSub == this) MainSub = null;
|
if (MainSub == this) MainSub = null;
|
||||||
if (MainSubs[1] == this) MainSubs[1] = null;
|
if (MainSubs[1] == this) MainSubs[1] = null;
|
||||||
|
|
||||||
|
|||||||
@@ -871,7 +871,11 @@ namespace Barotrauma.Networking
|
|||||||
GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
|
GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
|
||||||
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
|
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
|
||||||
|
|
||||||
if (AllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle);
|
bool missionAllowRespawn =
|
||||||
|
!(GameMain.GameSession.gameMode is MissionMode) ||
|
||||||
|
((MissionMode)GameMain.GameSession.gameMode).Mission.AllowRespawn;
|
||||||
|
|
||||||
|
if (AllowRespawn && missionAllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle);
|
||||||
|
|
||||||
AssignJobs(connectedClients, characterInfo != null);
|
AssignJobs(connectedClients, characterInfo != null);
|
||||||
|
|
||||||
@@ -971,7 +975,11 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
msg.Write(selectedMode.Name);
|
msg.Write(selectedMode.Name);
|
||||||
|
|
||||||
msg.Write(AllowRespawn);
|
bool missionAllowRespawn =
|
||||||
|
!(GameMain.GameSession.gameMode is MissionMode) ||
|
||||||
|
((MissionMode)GameMain.GameSession.gameMode).Mission.AllowRespawn;
|
||||||
|
|
||||||
|
msg.Write(AllowRespawn && missionAllowRespawn);
|
||||||
msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub
|
msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub
|
||||||
|
|
||||||
msg.Write(client.Character.ID);
|
msg.Write(client.Character.ID);
|
||||||
|
|||||||
@@ -333,6 +333,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void SetTransform(Vector2 position, float rotation)
|
public void SetTransform(Vector2 position, float rotation)
|
||||||
{
|
{
|
||||||
|
System.Diagnostics.Debug.Assert(MathUtils.IsValid(position));
|
||||||
|
System.Diagnostics.Debug.Assert(Math.Abs(position.X) < 1000000.0f);
|
||||||
|
System.Diagnostics.Debug.Assert(Math.Abs(position.Y) < 1000000.0f);
|
||||||
|
|
||||||
|
|
||||||
body.SetTransform(position, rotation);
|
body.SetTransform(position, rotation);
|
||||||
SetPrevTransform(position, rotation);
|
SetPrevTransform(position, rotation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,8 +117,6 @@ namespace Barotrauma
|
|||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
MessageBox.Show(message, "Oops! Barotrauma just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(message, "Oops! Barotrauma just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Sounds.SoundManager.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CrashDump(GameMain game, string filePath, Exception exception)
|
static void CrashDump(GameMain game, string filePath, Exception exception)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Input;
|
|||||||
using Barotrauma.Lights;
|
using Barotrauma.Lights;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -115,6 +116,7 @@ namespace Barotrauma
|
|||||||
closestSub.ApplyForce(targetMovement * closestSub.SubBody.Body.Mass * 100.0f);
|
closestSub.ApplyForce(targetMovement * closestSub.SubBody.Body.Mass * 100.0f);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GameMain.GameSession != null) GameMain.GameSession.Update((float)deltaTime);
|
if (GameMain.GameSession != null) GameMain.GameSession.Update((float)deltaTime);
|
||||||
|
|
||||||
if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime);
|
if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime);
|
||||||
@@ -165,18 +167,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GameMain.World.Step((float)deltaTime);
|
GameMain.World.Step((float)deltaTime);
|
||||||
|
|
||||||
|
|
||||||
if (!PlayerInput.LeftButtonHeld())
|
if (!PlayerInput.LeftButtonHeld())
|
||||||
{
|
{
|
||||||
Inventory.draggingSlot = null;
|
Inventory.draggingSlot = null;
|
||||||
Inventory.draggingItem = null;
|
Inventory.draggingItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
cam.UpdateTransform(true);
|
cam.UpdateTransform(true);
|
||||||
|
Submarine.CullEntities(cam);
|
||||||
|
|
||||||
DrawMap(graphics, spriteBatch);
|
DrawMap(graphics, spriteBatch);
|
||||||
|
|
||||||
@@ -223,6 +224,21 @@ namespace Barotrauma
|
|||||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Submarine> visibleSubs = new List<Submarine>();
|
||||||
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
|
{
|
||||||
|
Rectangle worldBorders = new Rectangle(
|
||||||
|
sub.Borders.X + (int)sub.WorldPosition.X - 500,
|
||||||
|
sub.Borders.Y + (int)sub.WorldPosition.Y + 500,
|
||||||
|
sub.Borders.Width + 1000,
|
||||||
|
sub.Borders.Height + 1000);
|
||||||
|
|
||||||
|
|
||||||
|
if (Submarine.RectsOverlap(worldBorders, cam.WorldView))
|
||||||
|
{
|
||||||
|
visibleSubs.Add(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
//1. draw the background, characters and the parts of the submarine that are behind them
|
//1. draw the background, characters and the parts of the submarine that are behind them
|
||||||
@@ -341,7 +357,7 @@ namespace Barotrauma
|
|||||||
null, null, null,
|
null, null, null,
|
||||||
cam.Transform);
|
cam.Transform);
|
||||||
|
|
||||||
Submarine.DrawDamageable(spriteBatch, null);
|
Submarine.DrawDamageable(spriteBatch, null, false);
|
||||||
Submarine.DrawFront(spriteBatch, false, s => s is Structure);
|
Submarine.DrawFront(spriteBatch, false, s => s is Structure);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
@@ -375,7 +391,7 @@ namespace Barotrauma
|
|||||||
null, null, null,
|
null, null, null,
|
||||||
cam.Transform);
|
cam.Transform);
|
||||||
|
|
||||||
Submarine.DrawFront(spriteBatch);
|
Submarine.DrawFront(spriteBatch, false, null);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
@@ -385,7 +401,7 @@ namespace Barotrauma
|
|||||||
damageEffect,
|
damageEffect,
|
||||||
cam.Transform);
|
cam.Transform);
|
||||||
|
|
||||||
Submarine.DrawDamageable(spriteBatch, damageEffect);
|
Submarine.DrawDamageable(spriteBatch, damageEffect, false);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
v0.5.3.2
|
||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- fixed character colliders occasionally getting stuck inside walls when switching from swimming to
|
||||||
|
walking or standing up after being unconscious
|
||||||
|
- wires can be dragged outside the sub in the editor without disconnecting them
|
||||||
|
- easier to climb over small obstacles
|
||||||
|
- combat missions don't reset the "allow respawn" setting
|
||||||
|
- submarines outside the camera view aren't rendered
|
||||||
|
- coelanth collider fix
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
v0.5.3.1
|
v0.5.3.1
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
- fixed monster movement!
|
- fixed monster movement!
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user