Using filename as sub name, disposing convexhull vertexbuffers when removing, canceling networkplayer ladder climbing only if movement key pressed

This commit is contained in:
Regalis
2016-01-29 00:08:17 +02:00
parent f5c2dbf22a
commit a1770427a0
5 changed files with 53 additions and 27 deletions

View File

@@ -133,7 +133,7 @@ namespace Barotrauma.Lights
public void Move(Vector2 amount)
{
cachedShadows.Clear();
ClearCachedShadows();
for (int i = 0; i < vertices.Count(); i++)
{
@@ -145,13 +145,34 @@ namespace Barotrauma.Lights
public void SetVertices(Vector2[] points)
{
cachedShadows.Clear();
ClearCachedShadows();
vertices = points;
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)
{
Rectangle transformedBounds = boundingBox;
@@ -309,7 +330,7 @@ namespace Barotrauma.Lights
else
{
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0);
cachedShadows.Remove(light);
RemoveCachedShadow(light);
cachedShadows.Add(light, cachedShadow);
}
}
@@ -373,11 +394,7 @@ namespace Barotrauma.Lights
public void Remove()
{
foreach (KeyValuePair<LightSource, CachedShadow> cachedShadow in cachedShadows)
{
cachedShadow.Value.Dispose();
}
cachedShadows.Clear();
ClearCachedShadows();
list.Remove(this);
}

View File

@@ -55,7 +55,7 @@ namespace Barotrauma
public string Name
{
get { return name; }
set { name = value; }
//set { name = value; }
}
public static Vector2 LastPickedPosition
@@ -482,6 +482,8 @@ namespace Barotrauma
public bool SaveAs(string filePath)
{
name = System.IO.Path.GetFileNameWithoutExtension(filePath);
XDocument doc = new XDocument(new XElement("Submarine"));
doc.Root.Add(new XAttribute("name", name));
@@ -632,7 +634,7 @@ namespace Barotrauma
XDocument doc = OpenDoc(filePath);
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())
{