Multi-sub transition cinematic, linkedsubs don't have to be docked to the main sub when leaving (being at the same exit is enough), resetting item/serverlog listbox scroll when filtering the list
This commit is contained in:
@@ -302,18 +302,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool TryEndShift(GUIButton button, object obj)
|
private bool TryEndShift(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
int subsNotDocked = 0;
|
List<Submarine> subsNotDocked = new List<Submarine>();
|
||||||
|
|
||||||
var leavingSub = obj as Submarine;
|
var leavingSub = obj as Submarine;
|
||||||
if (leavingSub != null)
|
if (leavingSub != null)
|
||||||
{
|
{
|
||||||
subsNotDocked = GetSubsToLeaveBehind(leavingSub).Count;
|
subsNotDocked = GetSubsToLeaveBehind(leavingSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subsNotDocked > 0)
|
if (subsNotDocked.Any())
|
||||||
{
|
{
|
||||||
string msg = "";
|
string msg = "";
|
||||||
if (subsNotDocked == 1)
|
if (subsNotDocked.Count==1)
|
||||||
{
|
{
|
||||||
msg = "One of your vessels isn't at the exit yet. Do you want to leave it behind?";
|
msg = "One of your vessels isn't at the exit yet. Do you want to leave it behind?";
|
||||||
}
|
}
|
||||||
@@ -325,6 +325,8 @@ namespace Barotrauma
|
|||||||
var msgBox = new GUIMessageBox("Warning", msg, new string[] {"Yes", "No"});
|
var msgBox = new GUIMessageBox("Warning", msg, new string[] {"Yes", "No"});
|
||||||
msgBox.Buttons[0].OnClicked += EndShift;
|
msgBox.Buttons[0].OnClicked += EndShift;
|
||||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||||
|
msgBox.Buttons[0].UserData = Submarine.Loaded.FindAll(s => !subsNotDocked.Contains(s));
|
||||||
|
|
||||||
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
msgBox.Buttons[1].OnClicked += msgBox.Close;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -339,7 +341,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
|
|
||||||
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, 5.0f);
|
List<Submarine> leavingSubs = obj as List<Submarine>;
|
||||||
|
if (leavingSubs == null) leavingSubs = new List<Submarine>() { GetLeavingSub() };
|
||||||
|
|
||||||
|
var cinematic = new TransitionCinematic(leavingSubs, GameMain.GameScreen.Cam, 5.0f);
|
||||||
|
|
||||||
SoundPlayer.OverrideMusicType = CrewManager.characters.Any(c => !c.IsDead) ? "endshift" : "crewdead";
|
SoundPlayer.OverrideMusicType = CrewManager.characters.Any(c => !c.IsDead) ? "endshift" : "crewdead";
|
||||||
|
|
||||||
|
|||||||
@@ -277,6 +277,9 @@ namespace Barotrauma
|
|||||||
saveElement = this.saveElement;
|
saveElement = this.saveElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saveElement.Attribute("pos") != null) saveElement.Attribute("pos").Remove();
|
||||||
|
saveElement.Add(new XAttribute("pos", ToolBox.Vector2ToString(Position - Submarine.HiddenSubPosition)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
var linkedPort = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||||
@@ -298,7 +301,22 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (sub != null)
|
if (sub != null)
|
||||||
{
|
{
|
||||||
|
bool leaveBehind = false;
|
||||||
if (!sub.DockedTo.Contains(Submarine.MainSub))
|
if (!sub.DockedTo.Contains(Submarine.MainSub))
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.Assert(Submarine.MainSub.AtEndPosition || Submarine.MainSub.AtStartPosition);
|
||||||
|
if (Submarine.MainSub.AtEndPosition)
|
||||||
|
{
|
||||||
|
leaveBehind = sub.AtEndPosition != Submarine.MainSub.AtEndPosition;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leaveBehind = sub.AtStartPosition != Submarine.MainSub.AtStartPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (leaveBehind)
|
||||||
{
|
{
|
||||||
saveElement.Add(new XAttribute("location", Level.Loaded.Seed));
|
saveElement.Add(new XAttribute("location", Level.Loaded.Seed));
|
||||||
saveElement.Add(new XAttribute("worldpos", ToolBox.Vector2ToString(sub.SubBody.Position)));
|
saveElement.Add(new XAttribute("worldpos", ToolBox.Vector2ToString(sub.SubBody.Position)));
|
||||||
|
|||||||
@@ -19,14 +19,24 @@ namespace Barotrauma
|
|||||||
private float duration;
|
private float duration;
|
||||||
|
|
||||||
public TransitionCinematic(Submarine submarine, Camera cam, float duration)
|
public TransitionCinematic(Submarine submarine, Camera cam, float duration)
|
||||||
|
: this(new List<Submarine>() { submarine }, cam, duration)
|
||||||
{
|
{
|
||||||
Vector2 targetPos = submarine.Position;
|
|
||||||
|
|
||||||
if (submarine.AtEndPosition)
|
}
|
||||||
|
|
||||||
|
public TransitionCinematic(List<Submarine> submarines, Camera cam, float duration)
|
||||||
|
{
|
||||||
|
Vector2 targetPos = new Vector2(
|
||||||
|
submarines.Sum(s => s.Position.X),
|
||||||
|
submarines.Sum(s => s.Position.Y)) / submarines.Count;
|
||||||
|
|
||||||
|
if (!submarines.Any()) return;
|
||||||
|
|
||||||
|
if (submarines.First().AtEndPosition)
|
||||||
{
|
{
|
||||||
targetPos = Level.Loaded.EndPosition + Vector2.UnitY * 500.0f;
|
targetPos = Level.Loaded.EndPosition + Vector2.UnitY * 500.0f;
|
||||||
}
|
}
|
||||||
else if (submarine.AtStartPosition)
|
else if (submarines.First().AtStartPosition)
|
||||||
{
|
{
|
||||||
targetPos = Level.Loaded.StartPosition + Vector2.UnitY * 500.0f;
|
targetPos = Level.Loaded.StartPosition + Vector2.UnitY * 500.0f;
|
||||||
}
|
}
|
||||||
@@ -34,16 +44,18 @@ namespace Barotrauma
|
|||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
|
|
||||||
Running = true;
|
Running = true;
|
||||||
CoroutineManager.StartCoroutine(UpdateTransitionCinematic(submarine, cam, targetPos));
|
CoroutineManager.StartCoroutine(UpdateTransitionCinematic(submarines, cam, targetPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> UpdateTransitionCinematic(Submarine sub, Camera cam, Vector2 targetPos)
|
private IEnumerable<object> UpdateTransitionCinematic(List<Submarine> subs, Camera cam, Vector2 targetPos)
|
||||||
{
|
{
|
||||||
|
if (!subs.Any()) yield return CoroutineStatus.Success;
|
||||||
|
|
||||||
Character.Controlled = null;
|
Character.Controlled = null;
|
||||||
cam.TargetPos = Vector2.Zero;
|
cam.TargetPos = Vector2.Zero;
|
||||||
GameMain.LightManager.LosEnabled = false;
|
GameMain.LightManager.LosEnabled = false;
|
||||||
|
|
||||||
Vector2 diff = targetPos - sub.Position;
|
//Vector2 diff = targetPos - sub.Position;
|
||||||
float targetSpeed = 10.0f;
|
float targetSpeed = 10.0f;
|
||||||
|
|
||||||
Level.Loaded.ShaftBodies[0].Enabled = false;
|
Level.Loaded.ShaftBodies[0].Enabled = false;
|
||||||
@@ -66,17 +78,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f);
|
cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f);
|
||||||
|
|
||||||
Vector2 cameraPos = sub.Position + Submarine.MainSub.HiddenSubPosition;
|
Vector2 cameraPos = subs.First().Position + Submarine.MainSub.HiddenSubPosition;
|
||||||
cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBodies[0].Position.Y) - cam.WorldView.Height/2.0f);
|
cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBodies[0].Position.Y) - cam.WorldView.Height/2.0f);
|
||||||
|
|
||||||
GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration);
|
GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration);
|
||||||
|
|
||||||
cam.Translate((cameraPos - cam.Position) * CoroutineManager.UnscaledDeltaTime*10.0f);
|
cam.Translate((cameraPos - cam.Position) * CoroutineManager.UnscaledDeltaTime*10.0f);
|
||||||
|
|
||||||
if (diff != Vector2.Zero)
|
foreach (Submarine sub in subs)
|
||||||
{
|
{
|
||||||
sub.ApplyForce((Vector2.Normalize(diff) * targetSpeed - sub.Velocity) * 500.0f);
|
sub.ApplyForce((Vector2.Normalize(sub.Position - targetPos) * targetSpeed - sub.Velocity) * 500.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
timer += CoroutineManager.UnscaledDeltaTime;
|
timer += CoroutineManager.UnscaledDeltaTime;
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ namespace Barotrauma.Networking
|
|||||||
textBlock.Visible = textBlock.Text.ToLower().Contains(text);
|
textBlock.Visible = textBlock.Text.ToLower().Contains(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listBox.BarScroll = 0.0f;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -464,9 +464,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (GUIComponent child in GUItabs[selectedTab].GetChild<GUIListBox>().children)
|
foreach (GUIComponent child in GUItabs[selectedTab].GetChild<GUIListBox>().children)
|
||||||
{
|
{
|
||||||
child.Visible = child.GetChild<GUITextBlock>().Text.ToLower().Contains(text);
|
var textBlock = child.GetChild<GUITextBlock>();
|
||||||
|
child.Visible = textBlock.Text.ToLower().Contains(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUItabs[selectedTab].GetChild<GUIListBox>().BarScroll = 0.0f;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user