(42d13c09f) Merge remote-tracking branch 'origin/tutorial-rework' into dev

This commit is contained in:
Joonas Rikkonen
2019-04-25 18:07:37 +03:00
parent 99344e4031
commit e83dba2959
53 changed files with 3623 additions and 550 deletions
@@ -0,0 +1,46 @@
using Microsoft.Xna.Framework;
using System;
namespace Barotrauma
{
partial class DummyFireSource : FireSource
{
private Vector2 maxSize;
public bool Removed
{
get { return removed; }
}
public DummyFireSource(Vector2 maxSize, Vector2 worldPosition, Hull spawningHull = null, bool isNetworkMessage = false) : base(worldPosition, spawningHull, isNetworkMessage)
{
this.maxSize = maxSize;
}
public override float DamageRange
{
get { return 5f; }
}
protected override void LimitSize()
{
if (hull == null) return;
position.X = Math.Max(hull.Rect.X, position.X);
position.Y = Math.Min(hull.Rect.Y, position.Y);
size.X = Math.Min(maxSize.X, size.X);
size.Y = Math.Min(maxSize.Y, size.Y);
}
protected override void AdjustXPos(float growModifier, float deltaTime)
{
}
protected override void ReduceOxygen(float deltaTime)
{
}
}
}
@@ -40,7 +40,7 @@ namespace Barotrauma
flames = true;
underwaterBubble = true;
}
public Explosion(XElement element, string parentDebugName)
{
attack = new Attack(element, parentDebugName + ", Explosion");
@@ -62,6 +62,16 @@ namespace Barotrauma
CameraShake = element.GetAttributeFloat("camerashake", attack.Range * 0.1f);
}
public void DisableParticles()
{
sparks = false;
shockwave = false;
smoke = false;
flash = false;
flames = false;
underwaterBubble = false;
}
public List<Triplet<Explosion, Vector2, float>> GetRecentExplosions(float maxSecondsAgo)
{
return prevExplosions.FindAll(e => e.Third >= Timing.TotalTime - maxSecondsAgo);
@@ -14,15 +14,15 @@ namespace Barotrauma
{
const float OxygenConsumption = 50.0f;
const float GrowSpeed = 5.0f;
private Hull hull;
private Vector2 position;
private Vector2 size;
protected Hull hull;
protected Vector2 position;
protected Vector2 size;
private Entity Submarine;
private bool removed;
protected bool removed;
#if CLIENT
private List<Decal> burnDecals = new List<Decal>();
@@ -59,7 +59,7 @@ namespace Barotrauma
}
}
public float DamageRange
public virtual float DamageRange
{
get { return (float)Math.Sqrt(size.X) * 20.0f; }
}
@@ -94,7 +94,7 @@ namespace Barotrauma
size = new Vector2(10.0f, 10.0f);
}
private void LimitSize()
protected virtual void LimitSize()
{
if (hull == null) return;
@@ -160,9 +160,9 @@ namespace Barotrauma
if (removed) { return; }
}
hull.Oxygen -= size.X * deltaTime * OxygenConsumption;
ReduceOxygen(deltaTime);
position.X -= GrowSpeed * growModifier * 0.5f * deltaTime;
AdjustXPos(growModifier, deltaTime);
size.X += GrowSpeed * growModifier * deltaTime;
size.Y = MathHelper.Clamp(size.Y + GrowSpeed * growModifier * deltaTime, 10.0f, 50.0f);
@@ -182,6 +182,16 @@ namespace Barotrauma
}
}
protected virtual void ReduceOxygen(float deltaTime)
{
hull.Oxygen -= size.X * deltaTime * OxygenConsumption;
}
protected virtual void AdjustXPos(float growModifier, float deltaTime)
{
position.X -= GrowSpeed * growModifier * 0.5f * deltaTime;
}
partial void UpdateProjSpecific(float growModifier);
private void OnChangeHull(Vector2 pos, Hull particleHull)
@@ -138,6 +138,9 @@ namespace Barotrauma
public Submarine StartOutpost { get; private set; }
public Submarine EndOutpost { get; private set; }
private Submarine preSelectedStartOutpost;
private Submarine preSelectedEndOutpost;
public string Seed
{
get { return seed; }
@@ -209,7 +212,7 @@ namespace Barotrauma
/// </summary>
/// <param name="difficulty">A scalar between 0-100</param>
/// <param name="sizeFactor">A scalar between 0-1 (0 = the minimum width defined in the generation params is used, 1 = the max width is used)</param>
public Level(string seed, float difficulty, float sizeFactor, LevelGenerationParams generationParams, Biome biome)
public Level(string seed, float difficulty, float sizeFactor, LevelGenerationParams generationParams, Biome biome, Submarine startOutpost = null, Submarine endOutPost = null)
: base(null)
{
@@ -225,6 +228,9 @@ namespace Barotrauma
(width / GridCellSize) * GridCellSize,
(generationParams.Height / GridCellSize) * GridCellSize);
preSelectedStartOutpost = startOutpost;
preSelectedEndOutpost = endOutPost;
//remove from entity dictionary
base.Remove();
}
@@ -1510,14 +1516,24 @@ namespace Barotrauma
continue;
}
//only create a starting outpost in campaign mode
if (GameMain.GameSession?.GameMode as CampaignMode == null && ((i == 0) == !Mirrored))
//only create a starting outpost in campaign and tutorial modes
if (!IsModeStartOutpostCompatible() && ((i == 0) == !Mirrored))
{
continue;
}
string outpostFile = outpostFiles.GetRandom(Rand.RandSync.Server);
var outpost = new Submarine(outpostFile, tryLoad: false);
Submarine outpost = null;
if (i == 0 && preSelectedStartOutpost == null || i == 1 && preSelectedEndOutpost == null)
{
string outpostFile = outpostFiles.GetRandom(Rand.RandSync.Server);
outpost = new Submarine(outpostFile, tryLoad: false);
}
else
{
outpost = (i == 0) ? preSelectedStartOutpost : preSelectedEndOutpost;
}
outpost.Load(unloadPrevious: false);
outpost.MakeOutpost();
@@ -1569,6 +1585,15 @@ namespace Barotrauma
}
}
private bool IsModeStartOutpostCompatible()
{
#if CLIENT
return GameMain.GameSession?.GameMode as CampaignMode != null || GameMain.GameSession?.GameMode as TutorialMode != null;
#else
return GameMain.GameSession?.GameMode as CampaignMode != null;
#endif
}
public override void Remove()
{
base.Remove();
@@ -30,13 +30,15 @@ namespace Barotrauma
//the position and dimensions of the entity
protected Rectangle rect;
public bool ExternalHighlight = false;
//is the mouse inside the rect
protected bool isHighlighted;
private bool isHighlighted;
public bool IsHighlighted
{
get { return isHighlighted; }
get { return isHighlighted || ExternalHighlight; }
set { isHighlighted = value; }
}
@@ -431,6 +431,12 @@ namespace Barotrauma
else if (ic is Pickable pickable)
{
//prevent picking up (or deattaching) items
#if CLIENT
if (GameMain.GameSession.GameMode is TutorialMode)
{
continue;
}
#endif
pickable.CanBePicked = false;
pickable.CanBeSelected = false;
}
@@ -1426,7 +1432,7 @@ namespace Barotrauma
doc.Root.Add(new XAttribute("md5hash", hash.Hash));
if (previewImage != null)
{
doc.Root.Add(new XAttribute("previewimage", Convert.ToBase64String(previewImage.ToArray())));
//doc.Root.Add(new XAttribute("previewimage", Convert.ToBase64String(previewImage.ToArray())));
}
try
@@ -299,7 +299,7 @@ namespace Barotrauma
{
for (int dir = -1; dir <= 1; dir += 2)
{
WayPoint closest = stairPoints[i].FindClosest(dir, true, new Vector2(-30.0f,30f));
WayPoint closest = stairPoints[i].FindClosest(dir, true, new Vector2(-30.0f, 30f));
if (closest == null) continue;
stairPoints[i].ConnectTo(closest);
}
@@ -412,7 +412,7 @@ namespace Barotrauma
WayPoint closest = wayPoint.FindClosest(
dir, true, new Vector2(-tolerance, tolerance),
gap.ConnectedDoor == null ? null : gap.ConnectedDoor.Body.FarseerBody);
gap.ConnectedDoor?.Body.FarseerBody);
if (closest != null)
{
@@ -423,13 +423,26 @@ namespace Barotrauma
foreach (Gap gap in Gap.GapList)
{
if (gap.IsHorizontal || gap.IsRoomToRoom) continue;
if (gap.IsHorizontal || gap.IsRoomToRoom || !gap.linkedTo.Any(l => l is Hull)) { continue; }
//too small to walk through
if (gap.Rect.Width < 100.0f) continue;
if (gap.Rect.Width < 100.0f) { continue; }
var wayPoint = new WayPoint(
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height / 2), SpawnType.Path, submarine, gap);
float tolerance = outSideWaypointInterval / 2.0f;
Hull connectedHull = (Hull)gap.linkedTo.First(l => l is Hull);
int dir = Math.Sign(connectedHull.Position.Y - gap.Position.Y);
WayPoint closest = wayPoint.FindClosest(
dir, false, new Vector2(-tolerance, tolerance),
gap.ConnectedDoor?.Body.FarseerBody);
if (closest != null)
{
wayPoint.ConnectTo(closest);
}
}
var orphans = WayPointList.FindAll(w => w.spawnType == SpawnType.Path && !w.linkedTo.Any());