Vertical docking port, docking sounds, water flows properly between horizontally docked hulls, falseoutput of signal check components can be changed, lighting and FOW works between hulls (todo: some logic for determining when to update light.HullsInRange when two subs are moving relative to each other)
This commit is contained in:
@@ -497,6 +497,9 @@
|
||||
<Content Include="Content\Items\Door\dockingport.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Door\dockingport2.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Jobgear\captainLegs.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -1092,6 +1095,12 @@
|
||||
<None Include="Content\Items\Diving\scooter.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Items\Door\dockingport1.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Items\Door\dockingport2.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Items\Door\door.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 32 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -88,11 +88,12 @@
|
||||
linkable="true"
|
||||
pickdistance="150.0">
|
||||
|
||||
<Sprite texture ="dockingport.png" sourcerect="0,0,112,208" depth="0.95" origin="0.5,0.5"/>
|
||||
<Sprite texture ="dockingport.png" sourcerect="0,0,112,208" depth="0.94" origin="0.5,0.5"/>
|
||||
|
||||
<DockingPort IsHorizontal="true" DistanceTolerance="128,64" DockedDistance="64">
|
||||
<Sprite texture ="dockingport.png" sourcerect="112,0,112,208" depth="0.05" origin="0.5,0.5"/>
|
||||
<sound file="door.ogg" type="OnUse" range="500.0"/>
|
||||
<Sprite texture ="dockingport.png" sourcerect="127,0,112,144" depth="0.05" origin="0.5,0.5"/>
|
||||
<sound file="dockingport1.ogg" type="OnUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
@@ -105,6 +106,34 @@
|
||||
<input name="toggle"/>
|
||||
<input name="set_state"/>
|
||||
<output name="state_out"/>
|
||||
<output name="proximity_sensor"/>
|
||||
</ConnectionPanel>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Docking Hatch"
|
||||
linkable="true"
|
||||
pickdistance="150.0">
|
||||
|
||||
<Sprite texture ="dockingport2.png" sourcerect="0,0,128,112" depth="0.94" origin="0.5,0.5"/>
|
||||
|
||||
<DockingPort IsHorizontal="false" DistanceTolerance="64,128" DockedDistance="64">
|
||||
<Sprite texture ="dockingport.png" sourcerect="127,144,48,112" depth="0.05" origin="0.5,0.5"/>
|
||||
<sound file="dockingport1.ogg" type="OnUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
<skill name="Construction" level="60"/>
|
||||
<item name="Welding Tool"/>
|
||||
</fixrequirement>
|
||||
|
||||
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
|
||||
<requireditem name="Screwdriver" type="Equipped"/>
|
||||
<input name="toggle"/>
|
||||
<input name="set_state"/>
|
||||
<output name="state_out"/>
|
||||
<output name="proximity_sensor"/>
|
||||
</ConnectionPanel>
|
||||
</Item>
|
||||
</Items>
|
||||
@@ -67,8 +67,7 @@
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable handle1="0,0"/>
|
||||
<Pickable slots="RightHand,Any"/>
|
||||
<Holdable handle1="0,0" slots="RightHand,Any"/>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
@@ -86,8 +85,7 @@
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable handle1="0,0"/>
|
||||
<Pickable slots="RightHand,Any"/>
|
||||
<Holdable handle1="0,0" slots="RightHand,Any"/>
|
||||
</Item>
|
||||
|
||||
|
||||
@@ -100,8 +98,7 @@
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable handle1="0,0"/>
|
||||
<Pickable slots="Any"/>
|
||||
<Holdable handle1="0,0" slots="Any"/>
|
||||
</Item>
|
||||
|
||||
</Items>
|
||||
|
||||
@@ -734,6 +734,10 @@ namespace Barotrauma
|
||||
{
|
||||
ladderSimPos += character.SelectedConstruction.Submarine.SimPosition;
|
||||
}
|
||||
else if (currentHull.Submarine != null && currentHull.Submarine != character.SelectedConstruction.Submarine)
|
||||
{
|
||||
ladderSimPos += character.SelectedConstruction.Submarine.SimPosition - currentHull.Submarine.SimPosition;
|
||||
}
|
||||
|
||||
MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, head.SimPosition.Y + 0.05f), 10.5f);
|
||||
MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, torso.SimPosition.Y), 10.5f);
|
||||
@@ -742,7 +746,9 @@ namespace Barotrauma
|
||||
|
||||
Vector2 handPos = new Vector2(
|
||||
ladderSimPos.X,
|
||||
head.SimPosition.Y + 0.0f + movement.Y * 0.1f - ladderSimPos.Y);
|
||||
head.SimPosition.Y + movement.Y * 0.1f - ladderSimPos.Y);
|
||||
|
||||
handPos.Y = Math.Min(-0.5f, handPos.Y);
|
||||
|
||||
MoveLimb(leftHand,
|
||||
new Vector2(handPos.X,
|
||||
@@ -815,8 +821,7 @@ namespace Barotrauma
|
||||
// - moving sideways
|
||||
// - reached the top or bottom of the ladder
|
||||
if (notClimbing ||
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) ||
|
||||
(TargetMovement.Y > 0.0f && handPos.Y > 0.1f))
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f))
|
||||
{
|
||||
Anim = Animation.None;
|
||||
character.SelectedConstruction = null;
|
||||
|
||||
@@ -20,23 +20,24 @@ namespace Barotrauma.Items.Components
|
||||
private static List<DockingPort> list = new List<DockingPort>();
|
||||
|
||||
private Sprite overlaySprite;
|
||||
|
||||
|
||||
private Vector2 distanceTolerance;
|
||||
|
||||
private DockingPort dockingTarget;
|
||||
|
||||
private float dockingState;
|
||||
private int dockingDir;
|
||||
|
||||
private Joint joint;
|
||||
|
||||
private int dockingDir;
|
||||
|
||||
private Hull[] hulls;
|
||||
|
||||
private Body[] bodies;
|
||||
|
||||
private Gap gap;
|
||||
|
||||
private bool docked;
|
||||
|
||||
[HasDefaultValue("32.0,32.0", false)]
|
||||
public string DistanceTolerance
|
||||
{
|
||||
@@ -58,22 +59,22 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
public override bool IsActive
|
||||
public bool Docked
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsActive;
|
||||
return docked;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!IsActive && value)
|
||||
if (!docked && value)
|
||||
{
|
||||
if (dockingTarget == null) AttemptDock();
|
||||
if (dockingTarget == null) return;
|
||||
|
||||
base.IsActive = value;
|
||||
docked = true;
|
||||
}
|
||||
else if (IsActive && !value)
|
||||
else if (docked && !value)
|
||||
{
|
||||
Undock();
|
||||
}
|
||||
@@ -97,10 +98,12 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
IsActive = true;
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
private void AttemptDock()
|
||||
private DockingPort FindAdjacentPort()
|
||||
{
|
||||
foreach (DockingPort port in list)
|
||||
{
|
||||
@@ -109,24 +112,41 @@ namespace Barotrauma.Items.Components
|
||||
if (Math.Abs(port.item.WorldPosition.X - item.WorldPosition.X) > distanceTolerance.X) continue;
|
||||
if (Math.Abs(port.item.WorldPosition.Y - item.WorldPosition.Y) > distanceTolerance.Y) continue;
|
||||
|
||||
Dock(port);
|
||||
return;
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AttemptDock()
|
||||
{
|
||||
var adjacentPort = FindAdjacentPort();
|
||||
if (adjacentPort != null) Dock(adjacentPort);
|
||||
}
|
||||
|
||||
private void Dock(DockingPort target)
|
||||
{
|
||||
if (dockingTarget!=null)
|
||||
if (dockingTarget != null)
|
||||
{
|
||||
Undock();
|
||||
}
|
||||
|
||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
|
||||
|
||||
dockingTarget = target;
|
||||
dockingTarget.dockingTarget = this;
|
||||
dockingTarget.IsActive = true;
|
||||
dockingTarget.Docked = true;
|
||||
|
||||
dockingDir = Math.Sign(dockingTarget.item.WorldPosition.X - item.WorldPosition.X);
|
||||
if (Character.Controlled != null &&
|
||||
(Character.Controlled.Submarine == dockingTarget.item.Submarine || Character.Controlled.Submarine == item.Submarine))
|
||||
{
|
||||
GameMain.GameScreen.Cam.Shake = Vector2.Distance(dockingTarget.item.Submarine.Velocity, item.Submarine.Velocity);
|
||||
}
|
||||
|
||||
dockingDir = IsHorizontal ?
|
||||
Math.Sign(dockingTarget.item.WorldPosition.X - item.WorldPosition.X) :
|
||||
Math.Sign(item.WorldPosition.Y - dockingTarget.item.WorldPosition.Y);
|
||||
dockingTarget.dockingDir = -dockingDir;
|
||||
|
||||
CreateJoint(false);
|
||||
@@ -184,59 +204,62 @@ namespace Barotrauma.Items.Components
|
||||
subs = new Submarine[] { dockingTarget.item.Submarine,item.Submarine };
|
||||
}
|
||||
|
||||
|
||||
hullRects[0] = new Rectangle(hullRects[0].Center.X, hullRects[0].Y, ((int)DockedDistance / 2), hullRects[0].Height);
|
||||
hullRects[1] = new Rectangle(hullRects[1].Center.X - ((int)DockedDistance / 2), hullRects[1].Y, ((int)DockedDistance / 2), hullRects[1].Height);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 2;i++ )
|
||||
{
|
||||
hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint();
|
||||
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]);
|
||||
hulls[i].AddToGrid(subs[i]);
|
||||
|
||||
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
bodies[i + j * 2] = BodyFactory.CreateEdge(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X, hullRects[i].Y - hullRects[i].Height * j)),
|
||||
ConvertUnits.ToSimUnits(new Vector2(hullRects[i].Right, hullRects[i].Y - hullRects[i].Height * j)));
|
||||
|
||||
//bodies[i + j * 2] = BodyFactory.CreateRectangle(GameMain.World, ConvertUnits.ToSimUnits(hullRects[i].Width), 0.1f, 5.0f);
|
||||
//bodies[i + j * 2].SetTransform(ConvertUnits.ToSimUnits(new Vector2(hullRects[i].Center.X, hullRects[i].Y - (hullRects[i].Height+5) * j)), 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
gap = new Gap(new Rectangle(hullRects[0].Right-2, hullRects[0].Y, 4, hullRects[0].Height), true, item.Submarine);
|
||||
gap.linkedTo.Clear();
|
||||
gap.linkedTo.Add(hulls[0]);
|
||||
gap.linkedTo.Add(hulls[1]);
|
||||
|
||||
//var hullRect1 = new Rectangle(hullRects.Min(h => h.Center.X), hullRect.Y, ((int)DockedDistance / 2), hullRects[0].Height);
|
||||
//var hullRect2 = new Rectangle(hullRects.Max(h => h.Center.X), hullRect.Y, ((int)DockedDistance / 2), hullRects[0].Height);
|
||||
|
||||
//var sub1 = hullRect.Center.X < targetRect.Center.X ? item.Submarine : dockingTarget.item.Submarine;
|
||||
//var sub2 = hullRect.Center.X > targetRect.Center.X ? item.Submarine : dockingTarget.item.Submarine;
|
||||
|
||||
// hullRect1.Location -= (sub1.WorldPosition - sub1.HiddenSubPosition).ToPoint();
|
||||
//hulls[0] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRect1, sub1);
|
||||
//hulls[0].AddToGrid(sub1);
|
||||
|
||||
//hullRect2.Location -= (sub2.WorldPosition - sub2.HiddenSubPosition).ToPoint();
|
||||
//hulls[1] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRect2, sub2);
|
||||
//hulls[1].AddToGrid(sub2);
|
||||
|
||||
gap = new Gap(new Rectangle(hullRects[0].Right-2, hullRects[0].Y, 4, hullRects[0].Height), true, subs[0]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//hullRect = new Rectangle(hullRect.X,
|
||||
// Math.Max(hullRect.Y - hullRect.Height / 2, targetRect.Y - targetRect.Height / 2), hullRect.Width, (int)DockedDistance);
|
||||
if (hullRects[0].Center.Y > hullRects[1].Center.Y)
|
||||
{
|
||||
hullRects = new Rectangle[] { dockingTarget.item.WorldRect, item.WorldRect };
|
||||
subs = new Submarine[] { dockingTarget.item.Submarine, item.Submarine };
|
||||
}
|
||||
|
||||
hullRects[0] = new Rectangle(hullRects[0].X, hullRects[0].Y + (int)(-hullRects[0].Height+DockedDistance)/2, hullRects[0].Width, ((int)DockedDistance / 2));
|
||||
hullRects[1] = new Rectangle(hullRects[1].X, hullRects[1].Y - hullRects[1].Height/2, hullRects[1].Width, ((int)DockedDistance / 2));
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint();
|
||||
hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]);
|
||||
hulls[i].AddToGrid(subs[i]);
|
||||
|
||||
//for (int j = 0; j < 2; j++)
|
||||
//{
|
||||
// bodies[i + j * 2] = BodyFactory.CreateEdge(GameMain.World,
|
||||
// ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X + hullRects[i].Width * j, hullRects[i].Y)),
|
||||
// ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X + hullRects[i].Width * j, hullRects[i].Y-hullRects[i].Height)));
|
||||
//}
|
||||
}
|
||||
|
||||
gap = new Gap(new Rectangle(hullRects[0].X, hullRects[0].Y+2, hullRects[0].Width, 4), true, subs[0]);
|
||||
|
||||
}
|
||||
|
||||
gap.linkedTo.Clear();
|
||||
gap.linkedTo.Add(hulls[0]);
|
||||
gap.linkedTo.Add(hulls[1]);
|
||||
|
||||
foreach (Body body in bodies)
|
||||
{
|
||||
if (body == null) continue;
|
||||
body.BodyType = BodyType.Static;
|
||||
body.Friction = 0.5f;
|
||||
|
||||
@@ -248,62 +271,83 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void Undock()
|
||||
{
|
||||
if (dockingTarget == null) return;
|
||||
if (dockingTarget == null || !docked) return;
|
||||
|
||||
dockingTarget.dockingTarget = null;
|
||||
dockingTarget.IsActive = false;
|
||||
PlaySound(ActionType.OnUse, item.WorldPosition);
|
||||
|
||||
docked = false;
|
||||
|
||||
dockingTarget.Undock();
|
||||
dockingTarget = null;
|
||||
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
joint = null;
|
||||
|
||||
hulls[0].Remove();
|
||||
hulls[1].Remove();
|
||||
|
||||
gap.Remove();
|
||||
gap = null;
|
||||
|
||||
foreach (Body body in bodies)
|
||||
if (joint != null)
|
||||
{
|
||||
GameMain.World.RemoveBody(body);
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
joint = null;
|
||||
}
|
||||
bodies = null;
|
||||
|
||||
if (hulls != null)
|
||||
{
|
||||
hulls[0].Remove();
|
||||
hulls[1].Remove();
|
||||
hulls = null;
|
||||
}
|
||||
|
||||
|
||||
//foreach (Gap g in hulls[0].ConnectedGaps)
|
||||
//{
|
||||
// g.Remove();
|
||||
//}
|
||||
if (gap != null)
|
||||
{
|
||||
gap.Remove();
|
||||
gap = null;
|
||||
}
|
||||
|
||||
//foreach (Gap g in hulls[1].ConnectedGaps)
|
||||
//{
|
||||
// g.Remove();
|
||||
//}
|
||||
if (bodies!=null)
|
||||
{
|
||||
foreach (Body body in bodies)
|
||||
{
|
||||
if (body == null) continue;
|
||||
GameMain.World.RemoveBody(body);
|
||||
}
|
||||
bodies = null;
|
||||
}
|
||||
|
||||
|
||||
hulls = null;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (dockingTarget==null)
|
||||
|
||||
|
||||
if (dockingTarget == null)
|
||||
{
|
||||
dockingState = MathHelper.Lerp(dockingState, 0.0f, deltaTime * 10.0f);
|
||||
if (dockingState < 0.01f) base.IsActive = false;
|
||||
if (dockingState < 0.01f) docked = false;
|
||||
|
||||
item.SendSignal(0, "0", "state_out");
|
||||
|
||||
item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (joint is DistanceJoint && Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
||||
if (joint is DistanceJoint)
|
||||
{
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
item.SendSignal(0, "0", "state_out");
|
||||
|
||||
CreateJoint(true);
|
||||
CreateHull();
|
||||
if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f)
|
||||
{
|
||||
GameMain.World.RemoveJoint(joint);
|
||||
|
||||
PlaySound(ActionType.OnSecondaryUse, item.WorldPosition);
|
||||
|
||||
CreateJoint(true);
|
||||
CreateHull();
|
||||
}
|
||||
dockingState = MathHelper.Lerp(dockingState, 0.5f, deltaTime * 10.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SendSignal(0, "1", "state_out");
|
||||
|
||||
dockingState = MathHelper.Lerp(dockingState, 1.0f, deltaTime * 10.0f);
|
||||
dockingState = MathHelper.Lerp(dockingState, 1.0f, deltaTime * 10.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,10 +359,11 @@ namespace Barotrauma.Items.Components
|
||||
drawPos.Y = -drawPos.Y;
|
||||
|
||||
var rect = overlaySprite.SourceRect;
|
||||
drawPos.Y -= rect.Height / 2;
|
||||
|
||||
|
||||
if (IsHorizontal)
|
||||
{
|
||||
drawPos.Y -= rect.Height / 2;
|
||||
|
||||
if (dockingDir == 1)
|
||||
{
|
||||
spriteBatch.Draw(overlaySprite.Texture,
|
||||
@@ -339,6 +384,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
drawPos.X -= rect.Width / 2;
|
||||
|
||||
if (dockingDir == 1)
|
||||
{
|
||||
spriteBatch.Draw(overlaySprite.Texture,
|
||||
@@ -363,5 +410,19 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
list.Remove(this);
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f)
|
||||
{
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "toggle":
|
||||
Docked = !docked;
|
||||
break;
|
||||
case "set_active":
|
||||
case "set_state":
|
||||
Docked = signal != "0";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class SignalCheckComponent : ItemComponent
|
||||
{
|
||||
private string output;
|
||||
private string output, falseOutput;
|
||||
|
||||
private string targetSignal;
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace Barotrauma.Items.Components
|
||||
get { return output; }
|
||||
set { output = value; }
|
||||
}
|
||||
[InGameEditable, HasDefaultValue("0", true)]
|
||||
public string FalseOutput
|
||||
{
|
||||
get { return falseOutput; }
|
||||
set { falseOutput = value; }
|
||||
}
|
||||
|
||||
[InGameEditable, HasDefaultValue("", true)]
|
||||
public string TargetSignal
|
||||
@@ -32,7 +38,10 @@ namespace Barotrauma.Items.Components
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "signal_in":
|
||||
item.SendSignal(stepsTaken, (signal == targetSignal) ? output : "0", "signal_out");
|
||||
string signalOut = (signal == targetSignal) ? output : falseOutput;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(signalOut)) return;
|
||||
item.SendSignal(stepsTaken, signalOut, "signal_out");
|
||||
|
||||
break;
|
||||
case "set_output":
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Barotrauma
|
||||
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnUse,
|
||||
Always, OnPicked, OnUse, OnSecondaryUse,
|
||||
OnWearing, OnContaining, OnContained,
|
||||
OnActive, OnFailure, OnBroken,
|
||||
OnFire, InWater,
|
||||
@@ -1248,6 +1248,7 @@ namespace Barotrauma
|
||||
{
|
||||
picked = true;
|
||||
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
|
||||
ic.PlaySound(ActionType.OnPicked, picker.WorldPosition);
|
||||
|
||||
if (picker==Character.Controlled) GUIComponent.MouseOn = null;
|
||||
|
||||
|
||||
@@ -173,8 +173,6 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Height/ 2.0f));
|
||||
|
||||
|
||||
|
||||
GUI.DrawLine(sb, center, center + new Vector2(flowForce.X, -flowForce.Y)/10.0f, Color.Red);
|
||||
|
||||
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + new Vector2(lerpedFlowForce.X, -lerpedFlowForce.Y) / 10.0f + Vector2.One * 5.0f, Color.Orange);
|
||||
@@ -329,6 +327,18 @@ namespace Barotrauma
|
||||
if (linkedTo.Count < 2) return;
|
||||
Hull hull1 = (Hull)linkedTo[0];
|
||||
Hull hull2 = (Hull)linkedTo[1];
|
||||
|
||||
Vector2 subOffset = Vector2.Zero;
|
||||
if (hull1.Submarine != Submarine)
|
||||
{
|
||||
subOffset =Submarine.Position - hull1.Submarine.Position;
|
||||
}
|
||||
else if (hull2.Submarine != Submarine)
|
||||
{
|
||||
|
||||
subOffset = hull2.Submarine.Position - Submarine.Position;
|
||||
|
||||
}
|
||||
|
||||
if (hull1.Volume == 0.0 && hull2.Volume == 0.0) return;
|
||||
|
||||
@@ -341,13 +351,14 @@ namespace Barotrauma
|
||||
//horizontal gap (such as a regular door)
|
||||
if (isHorizontal)
|
||||
{
|
||||
higherSurface = Math.Max(hull1.Surface,hull2.Surface);
|
||||
float delta=0.0f;
|
||||
higherSurface = Math.Max(hull1.Surface, hull2.Surface + subOffset.Y);
|
||||
float delta=0.0f;
|
||||
|
||||
//water level is above the lower boundary of the gap
|
||||
if (Math.Max(hull1.Surface+hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface+hull2.WaveY[0]) > rect.Y - size)
|
||||
if (Math.Max(hull1.Surface+hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y +hull2.WaveY[0]) > rect.Y - size)
|
||||
{
|
||||
|
||||
int dir = (hull1.Pressure > hull2.Pressure) ? 1 : -1;
|
||||
int dir = (hull1.Pressure > hull2.Pressure+subOffset.Y) ? 1 : -1;
|
||||
|
||||
//water flowing from the righthand room to the lefthand room
|
||||
if (dir == -1)
|
||||
@@ -360,38 +371,42 @@ namespace Barotrauma
|
||||
flowTargetHull = hull1;
|
||||
|
||||
//make sure not to move more than what the room contains
|
||||
delta = Math.Min((hull2.Pressure - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume));
|
||||
delta = Math.Min(((hull2.Pressure + subOffset.Y) - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume));
|
||||
|
||||
//make sure not to place more water to the target room than it can hold
|
||||
delta = Math.Min(delta, hull1.FullVolume + Hull.MaxCompress - (hull1.Volume));
|
||||
hull1.Volume += delta;
|
||||
hull2.Volume -= delta;
|
||||
if (hull1.Volume > hull1.FullVolume)
|
||||
hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure) / 2);
|
||||
{
|
||||
hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure+subOffset.Y) / 2);
|
||||
}
|
||||
|
||||
flowForce = new Vector2(-delta, 0.0f);
|
||||
}
|
||||
else if (dir == 1)
|
||||
{
|
||||
if (!(hull1.Volume > 0.0f)) return;
|
||||
lowerSurface = hull2.Surface - hull2.WaveY[1];
|
||||
//lowerSurface = hull2.Surface - hull2.WaveY[1];
|
||||
|
||||
flowTargetHull = hull2;
|
||||
|
||||
//make sure not to move more than what the room contains
|
||||
delta = Math.Min((hull1.Pressure - hull2.Pressure) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume));
|
||||
delta = Math.Min((hull1.Pressure - (hull2.Pressure + subOffset.Y)) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume));
|
||||
|
||||
//make sure not to place more water to the target room than it can hold
|
||||
delta = Math.Min(delta, hull2.FullVolume + Hull.MaxCompress - (hull2.Volume));
|
||||
hull1.Volume -= delta;
|
||||
hull2.Volume += delta;
|
||||
if (hull2.Volume > hull2.FullVolume)
|
||||
hull2.Pressure = Math.Max(hull2.Pressure, (hull1.Pressure + hull2.Pressure) / 2);
|
||||
{
|
||||
hull2.Pressure = Math.Max(hull2.Pressure, ((hull1.Pressure-subOffset.Y) + hull2.Pressure) / 2);
|
||||
}
|
||||
|
||||
flowForce = new Vector2(delta, 0.0f);
|
||||
}
|
||||
|
||||
if (delta>100.0f)
|
||||
if (delta>100.0f && subOffset == Vector2.Zero)
|
||||
{
|
||||
float avg = (hull1.Surface + hull2.Surface) / 2.0f;
|
||||
//float avgVel = (hull2.WaveVel[1] + hull1.WaveVel[hull1.WaveY.Length - 2]) / 2.0f;
|
||||
@@ -625,10 +640,9 @@ namespace Barotrauma
|
||||
|
||||
GapList.Remove(this);
|
||||
|
||||
foreach (MapEntity entity in linkedTo)
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
var hull = entity as Hull;
|
||||
if (hull.ConnectedGaps.Contains(this)) hull.ConnectedGaps.Remove(this);
|
||||
hull.ConnectedGaps.Remove(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Barotrauma
|
||||
|
||||
private bool update;
|
||||
|
||||
private Sound currentFlowSound;
|
||||
private int soundIndex;
|
||||
private float soundVolume;
|
||||
|
||||
@@ -392,12 +393,24 @@ namespace Barotrauma
|
||||
foreach (Gap gap in ConnectedGaps)
|
||||
{
|
||||
float gapFlow = gap.LerpedFlowForce.Length();
|
||||
|
||||
#if DEBUG
|
||||
var asd = MapEntity.FindEntityByID(gap.ID);
|
||||
|
||||
if (asd != gap)
|
||||
{
|
||||
int adslkmfdlasfk = 9;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (gapFlow > strongestFlow)
|
||||
{
|
||||
strongestFlow = gapFlow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (strongestFlow>0.1f)
|
||||
{
|
||||
soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f);
|
||||
@@ -406,13 +419,24 @@ namespace Barotrauma
|
||||
int index = (int)Math.Floor(strongestFlow / 100.0f);
|
||||
index = Math.Min(index, 2);
|
||||
|
||||
soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
|
||||
var flowSound = SoundPlayer.flowSounds[index];
|
||||
if (flowSound != currentFlowSound && soundIndex > -1)
|
||||
{
|
||||
Sounds.SoundManager.Stop(soundIndex);
|
||||
currentFlowSound = null;
|
||||
soundIndex = -1;
|
||||
}
|
||||
|
||||
currentFlowSound = flowSound;
|
||||
|
||||
soundIndex = currentFlowSound.Loop(soundIndex, soundVolume, WorldPosition, 2000.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (soundIndex > -1)
|
||||
{
|
||||
Sounds.SoundManager.Stop(soundIndex);
|
||||
currentFlowSound = null;
|
||||
soundIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,18 @@ namespace Barotrauma.Lights
|
||||
|
||||
Vector2 lightSourcePos = light.Position;
|
||||
|
||||
if (light.Submarine==null && parentEntity != null && parentEntity.Submarine != null) lightSourcePos -= parentEntity.Submarine.Position;
|
||||
if (parentEntity != null && parentEntity.Submarine != null)
|
||||
{
|
||||
if (light.Submarine == null)
|
||||
{
|
||||
lightSourcePos -= parentEntity.Submarine.Position;
|
||||
}
|
||||
else if (light.Submarine != parentEntity.Submarine)
|
||||
{
|
||||
lightSourcePos += (light.Submarine.Position-parentEntity.Submarine.Position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CachedShadow cachedShadow = null;
|
||||
if (!cachedShadows.TryGetValue(light, out cachedShadow) ||
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace Barotrauma.Lights
|
||||
foreach (LightSource light in lights)
|
||||
{
|
||||
if (light.Color.A < 0.01f || light.Range < 1.0f) continue;
|
||||
//!!!!!!!!!!!!!!!!
|
||||
if (light.hullsInRange == null) light.UpdateHullsInRange();
|
||||
if (!light.hullsInRange.Any() || !MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
|
||||
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
|
||||
if (Math.Abs(prevHullUpdateRange - range) < 5.0f) return;
|
||||
if (Math.Abs(prevHullUpdateRange - range) < 10.0f) return;
|
||||
|
||||
UpdateHullsInRange();
|
||||
prevHullUpdateRange = range;
|
||||
@@ -143,18 +143,24 @@ namespace Barotrauma.Lights
|
||||
|
||||
foreach (ConvexHull ch in ConvexHull.list)
|
||||
{
|
||||
if (Submarine == null && ch.ParentEntity.Submarine != null)
|
||||
Vector2 lightPos = position;
|
||||
|
||||
if (Submarine==null)
|
||||
{
|
||||
if (MathUtils.CircleIntersectsRectangle(position - ch.ParentEntity.Submarine.Position, range, ch.BoundingBox))
|
||||
if (ch.ParentEntity.Submarine != null)
|
||||
{
|
||||
hullsInRange.Add(ch);
|
||||
lightPos -= ch.ParentEntity.Submarine.Position;
|
||||
}
|
||||
}
|
||||
else if (MathUtils.CircleIntersectsRectangle(position, range, ch.BoundingBox))
|
||||
else if (ch.ParentEntity.Submarine != null && ch.ParentEntity.Submarine != Submarine)
|
||||
{
|
||||
lightPos -= (ch.ParentEntity.Submarine.Position - Submarine.Position);
|
||||
}
|
||||
|
||||
if (MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox))
|
||||
{
|
||||
hullsInRange.Add(ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -349,6 +349,14 @@ namespace Barotrauma
|
||||
GameMain.World.RemoveBody(b);
|
||||
}
|
||||
|
||||
foreach (WallSection s in sections)
|
||||
{
|
||||
if (s.gap != null)
|
||||
{
|
||||
s.gap.Remove();
|
||||
s.gap = null;
|
||||
}
|
||||
}
|
||||
if (convexHulls != null) convexHulls.ForEach(x => x.Remove());
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user