Using filename as sub name, disposing convexhull vertexbuffers when removing, canceling networkplayer ladder climbing only if movement key pressed
This commit is contained in:
@@ -716,12 +716,20 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
trigger = character.SelectedConstruction.TransformTrigger(trigger);
|
trigger = character.SelectedConstruction.TransformTrigger(trigger);
|
||||||
|
|
||||||
|
bool notClimbing = false;
|
||||||
|
if (character.IsNetworkPlayer)
|
||||||
|
{
|
||||||
|
notClimbing = character.IsKeyDown(InputType.Left) || character.IsKeyDown(InputType.Right);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notClimbing = targetMovement.X != 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
//stop climbing if:
|
//stop climbing if:
|
||||||
// - going too fast (can't grab a ladder while falling)
|
|
||||||
// - moving sideways
|
// - moving sideways
|
||||||
// - reached the top or bottom of the ladder
|
// - reached the top or bottom of the ladder
|
||||||
if (Math.Abs(torso.LinearVelocity.Y) > 5.0f ||
|
if (notClimbing ||
|
||||||
TargetMovement.X != 0.0f ||
|
|
||||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) ||
|
(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 && handPos.Y > 0.1f))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
public void Move(Vector2 amount)
|
public void Move(Vector2 amount)
|
||||||
{
|
{
|
||||||
cachedShadows.Clear();
|
ClearCachedShadows();
|
||||||
|
|
||||||
for (int i = 0; i < vertices.Count(); i++)
|
for (int i = 0; i < vertices.Count(); i++)
|
||||||
{
|
{
|
||||||
@@ -145,13 +145,34 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
public void SetVertices(Vector2[] points)
|
public void SetVertices(Vector2[] points)
|
||||||
{
|
{
|
||||||
cachedShadows.Clear();
|
ClearCachedShadows();
|
||||||
|
|
||||||
vertices = points;
|
vertices = points;
|
||||||
|
|
||||||
CalculateDimensions();
|
CalculateDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RemoveCachedShadow(Lights.LightSource light)
|
||||||
|
{
|
||||||
|
CachedShadow shadow = null;
|
||||||
|
cachedShadows.TryGetValue(light, out shadow);
|
||||||
|
|
||||||
|
if (shadow != null)
|
||||||
|
{
|
||||||
|
shadow.Dispose();
|
||||||
|
cachedShadows.Remove(light);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearCachedShadows()
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<LightSource, CachedShadow> cachedShadow in cachedShadows)
|
||||||
|
{
|
||||||
|
cachedShadow.Value.Dispose();
|
||||||
|
}
|
||||||
|
cachedShadows.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public bool Intersects(Rectangle rect)
|
public bool Intersects(Rectangle rect)
|
||||||
{
|
{
|
||||||
Rectangle transformedBounds = boundingBox;
|
Rectangle transformedBounds = boundingBox;
|
||||||
@@ -309,7 +330,7 @@ namespace Barotrauma.Lights
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0);
|
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0);
|
||||||
cachedShadows.Remove(light);
|
RemoveCachedShadow(light);
|
||||||
cachedShadows.Add(light, cachedShadow);
|
cachedShadows.Add(light, cachedShadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,11 +394,7 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
public void Remove()
|
public void Remove()
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<LightSource, CachedShadow> cachedShadow in cachedShadows)
|
ClearCachedShadows();
|
||||||
{
|
|
||||||
cachedShadow.Value.Dispose();
|
|
||||||
}
|
|
||||||
cachedShadows.Clear();
|
|
||||||
|
|
||||||
list.Remove(this);
|
list.Remove(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Barotrauma
|
|||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
set { name = value; }
|
//set { name = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 LastPickedPosition
|
public static Vector2 LastPickedPosition
|
||||||
@@ -482,6 +482,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool SaveAs(string filePath)
|
public bool SaveAs(string filePath)
|
||||||
{
|
{
|
||||||
|
name = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
||||||
|
|
||||||
XDocument doc = new XDocument(new XElement("Submarine"));
|
XDocument doc = new XDocument(new XElement("Submarine"));
|
||||||
doc.Root.Add(new XAttribute("name", name));
|
doc.Root.Add(new XAttribute("name", name));
|
||||||
|
|
||||||
@@ -632,7 +634,7 @@ namespace Barotrauma
|
|||||||
XDocument doc = OpenDoc(filePath);
|
XDocument doc = OpenDoc(filePath);
|
||||||
if (doc == null) return;
|
if (doc == null) return;
|
||||||
|
|
||||||
name = ToolBox.GetAttributeString(doc.Root, "name", name);
|
//name = ToolBox.GetAttributeString(doc.Root, "name", name);
|
||||||
|
|
||||||
foreach (XElement element in doc.Root.Elements())
|
foreach (XElement element in doc.Root.Elements())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
using (var game = new GameMain())
|
using (var game = new GameMain())
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
game.Run();
|
game.Run();
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
@@ -92,7 +91,7 @@ namespace Barotrauma
|
|||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
MessageBox.Show( "A crash report (''crashreport.txt'') was saved in the root folder of the game."+
|
MessageBox.Show( "A crash report (''crashreport.txt'') was saved in the root folder of the game."+
|
||||||
" If you'd like to help fix this bug, please post the report on the Undertow Games forums.",
|
" If you'd like to help fix this bug, please post the report on the Undertow Games forums.",
|
||||||
"Oops! Subsurface just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
"Oops! Barotrauma just crashed.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Sounds.SoundManager.Dispose();
|
Sounds.SoundManager.Dispose();
|
||||||
|
|||||||
@@ -274,10 +274,10 @@ namespace Barotrauma
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Submarine.Loaded!=null)
|
//if (Submarine.Loaded!=null)
|
||||||
{
|
//{
|
||||||
Submarine.Loaded.Name = nameBox.Text;
|
// Submarine.Loaded.Name = nameBox.Text;
|
||||||
}
|
//}
|
||||||
|
|
||||||
Submarine.SaveCurrent(nameBox.Text + ".sub");
|
Submarine.SaveCurrent(nameBox.Text + ".sub");
|
||||||
|
|
||||||
@@ -326,15 +326,15 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ChangeSubName(GUITextBox textBox, string text)
|
//private bool ChangeSubName(GUITextBox textBox, string text)
|
||||||
{
|
//{
|
||||||
if (Submarine.Loaded != null) Submarine.Loaded.Name = text;
|
// if (Submarine.Loaded != null) Submarine.Loaded.Name = text;
|
||||||
textBox.Deselect();
|
// textBox.Deselect();
|
||||||
|
|
||||||
textBox.Text = text;
|
// textBox.Text = text;
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
private bool SelectPrefab(GUIComponent component, object obj)
|
private bool SelectPrefab(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user