Lighting bugfixes, setting camera position to character on shift start
This commit is contained in:
@@ -1104,6 +1104,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (controlled != this) yield return CoroutineStatus.Success;
|
||||
|
||||
Character.controlled = null;
|
||||
|
||||
float dimDuration = 8.0f;
|
||||
float timer = 0.0f;
|
||||
|
||||
@@ -1114,13 +1116,12 @@ namespace Barotrauma
|
||||
{
|
||||
timer += CoroutineManager.DeltaTime;
|
||||
|
||||
if (controlled == this)
|
||||
{
|
||||
if (cam != null) cam.OffsetAmount = 0.0f;
|
||||
if (cam != null) cam.OffsetAmount = 0.0f;
|
||||
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration);
|
||||
}
|
||||
cam.TargetPos = WorldPosition;
|
||||
|
||||
GameMain.LightManager.AmbientLight = Color.Lerp(prevAmbientLight, darkLight, timer / dimDuration);
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
@@ -1138,6 +1139,8 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
cam.TargetPos = Vector2.Zero;
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,13 +143,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//string spritePath = Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\"+ ToolBox.GetAttributeString(element, "sprite", "");
|
||||
|
||||
Vector2[] corners = GetConvexHullCorners(doorRect);
|
||||
|
||||
convexHull = new ConvexHull(corners, Color.Black, item.CurrentHull == null ? null : item.CurrentHull.Submarine);
|
||||
if (window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black, item.CurrentHull == null ? null : item.CurrentHull.Submarine);
|
||||
|
||||
UpdateConvexHulls();
|
||||
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
@@ -210,10 +203,10 @@ namespace Barotrauma.Items.Components
|
||||
private Vector2[] GetConvexHullCorners(Rectangle rect)
|
||||
{
|
||||
Vector2[] corners = new Vector2[4];
|
||||
corners[0] = new Vector2(rect.X, rect.Y - rect.Height);
|
||||
corners[1] = new Vector2(rect.X, rect.Y);
|
||||
corners[2] = new Vector2(rect.Right, rect.Y);
|
||||
corners[3] = new Vector2(rect.Right, rect.Y - rect.Height);
|
||||
corners[0] = new Vector2(rect.X, rect.Y - rect.Height) + Submarine.HiddenSubPosition;
|
||||
corners[1] = new Vector2(rect.X, rect.Y) + Submarine.HiddenSubPosition;
|
||||
corners[2] = new Vector2(rect.Right, rect.Y) + Submarine.HiddenSubPosition;
|
||||
corners[3] = new Vector2(rect.Right, rect.Y - rect.Height) + Submarine.HiddenSubPosition;
|
||||
|
||||
return corners;
|
||||
}
|
||||
@@ -331,6 +324,13 @@ namespace Barotrauma.Items.Components
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
LinkedGap.ConnectedDoor = this;
|
||||
|
||||
Vector2[] corners = GetConvexHullCorners(doorRect);
|
||||
|
||||
convexHull = new ConvexHull(corners, Color.Black, item);
|
||||
if (window != Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black, item);
|
||||
|
||||
UpdateConvexHulls();
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
|
||||
@@ -148,6 +148,8 @@ namespace Barotrauma.Lights
|
||||
cachedShadows.Clear();
|
||||
|
||||
vertices = points;
|
||||
|
||||
CalculateDimensions();
|
||||
}
|
||||
|
||||
public bool Intersects(Rectangle rect)
|
||||
@@ -307,6 +309,7 @@ namespace Barotrauma.Lights
|
||||
else
|
||||
{
|
||||
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0);
|
||||
cachedShadows.Remove(light);
|
||||
cachedShadows.Add(light, cachedShadow);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +353,7 @@ namespace Barotrauma.Lights
|
||||
else
|
||||
{
|
||||
shadowEffect.CurrentTechnique.Passes[0].Apply();
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount);
|
||||
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount*2 - 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace Barotrauma.Lights
|
||||
|
||||
public Entity Submarine;
|
||||
|
||||
//what was the range of the light when HullsInRange were last updated
|
||||
private float prevHullUpdateRange;
|
||||
|
||||
private Vector2 position;
|
||||
public Vector2 Position
|
||||
{
|
||||
@@ -64,11 +67,11 @@ namespace Barotrauma.Lights
|
||||
set
|
||||
{
|
||||
|
||||
float prevRange = range;
|
||||
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
|
||||
if (Math.Abs(prevRange - range)<5.0f) return;
|
||||
if (Math.Abs(prevHullUpdateRange - range)>5.0f) return;
|
||||
|
||||
UpdateHullsInRange();
|
||||
prevHullUpdateRange = range;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -301,7 +301,10 @@ namespace Barotrauma
|
||||
|
||||
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null, Category? collisionCategory = null)
|
||||
{
|
||||
if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.0f) return null;
|
||||
if (Vector2.DistanceSquared(rayStart, rayEnd) < 0.00001f)
|
||||
{
|
||||
rayEnd += Vector2.UnitX * 0.001f;
|
||||
}
|
||||
|
||||
float closestFraction = 1.0f;
|
||||
Body closestBody = null;
|
||||
|
||||
@@ -55,12 +55,12 @@ namespace Barotrauma
|
||||
|
||||
GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration);
|
||||
|
||||
cam.Translate((cameraPos - cam.Position) * CoroutineManager.DeltaTime);
|
||||
cam.Translate((cameraPos - cam.Position) * CoroutineManager.DeltaTime*10.0f);
|
||||
|
||||
cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.DeltaTime * 0.1f);
|
||||
sub.ApplyForce((Vector2.Normalize(diff) * targetSpeed - sub.Velocity) * 500.0f);
|
||||
|
||||
timer -= CoroutineManager.DeltaTime;
|
||||
timer += CoroutineManager.DeltaTime;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (myCharacter.IsDead)
|
||||
{
|
||||
Character.Controlled = null;
|
||||
//Character.Controlled = null;
|
||||
//GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
}
|
||||
else if (gameStarted)
|
||||
@@ -610,7 +610,7 @@ namespace Barotrauma.Networking
|
||||
(float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f),
|
||||
(float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f)));
|
||||
|
||||
GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.Position + offset * 0.8f;
|
||||
GameMain.GameScreen.Cam.TargetPos = Submarine.Loaded.DrawPosition + offset * 0.8f;
|
||||
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
|
||||
|
||||
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
|
||||
@@ -742,6 +742,7 @@ namespace Barotrauma.Networking
|
||||
float closestDist = 0.0f;
|
||||
foreach (WayPoint wp in WayPoint.WayPointList)
|
||||
{
|
||||
if (wp.SpawnType != SpawnType.Human) continue;
|
||||
float dist = Vector2.Distance(wp.WorldPosition, position);
|
||||
if (closestWaypoint != null && dist > closestDist) continue;
|
||||
|
||||
|
||||
@@ -39,7 +39,15 @@ namespace Barotrauma
|
||||
{
|
||||
base.Select();
|
||||
|
||||
if (Submarine.Loaded != null) cam.TargetPos = Submarine.Loaded.Position;
|
||||
if (Character.Controlled!=null)
|
||||
{
|
||||
cam.Position = Character.Controlled.WorldPosition;
|
||||
}
|
||||
else if (Submarine.Loaded != null)
|
||||
{
|
||||
cam.Position = Submarine.Loaded.Position;
|
||||
}
|
||||
|
||||
|
||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||
entity.IsHighlighted = false;
|
||||
|
||||
@@ -839,7 +839,9 @@ namespace Barotrauma
|
||||
public bool TrySelectSub(string subName, string md5Hash)
|
||||
{
|
||||
|
||||
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName);
|
||||
subName = subName.ToLower();
|
||||
|
||||
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name.ToLower() == subName);
|
||||
if (sub == null)
|
||||
{
|
||||
new GUIMessageBox("Submarine not found!","The submarine ''" + subName + "'' has been selected by the server. Matching file not found in your map folder.");
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user