Started moving single player campaign logic to an abstract CampaignMode class to make it reusable in the eventual multiplayer campaign

This commit is contained in:
Joonas Rikkonen
2017-08-28 18:45:08 +03:00
parent 729108c7b9
commit a75fd12020
17 changed files with 202 additions and 189 deletions
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma
{
abstract class CampaignMode : GameMode
{
public readonly CargoManager CargoManager;
const int InitialMoney = 10000;
protected Map map;
public Map Map
{
get { return map; }
}
public override Mission Mission
{
get
{
return Map.SelectedConnection.Mission;
}
}
private int money;
public int Money
{
get { return money; }
set { money = Math.Max(value, 0); }
}
public CampaignMode(GameModePreset preset, object param)
: base(preset, param)
{
Money = InitialMoney;
CargoManager = new CargoManager();
}
public void GenerateMap(string seed)
{
map = new Map(seed, 1000);
}
protected List<Submarine> GetSubsToLeaveBehind(Submarine leavingSub)
{
//leave subs behind if they're not docked to the leaving sub and not at the same exit
return Submarine.Loaded.FindAll(s =>
s != leavingSub &&
!leavingSub.DockedTo.Contains(s) &&
(s.AtEndPosition != leavingSub.AtEndPosition || s.AtStartPosition != leavingSub.AtStartPosition));
}
public override void End(string endMessage = "")
{
base.End(endMessage);
}
public abstract void Save(XElement element);
}
}
@@ -34,7 +34,7 @@ namespace Barotrauma
public static void Init()
{
#if CLIENT
new GameModePreset("Single Player", typeof(SinglePlayerMode), true);
new GameModePreset("Single Player", typeof(SinglePlayerCampaign), true);
new GameModePreset("Tutorial", typeof(TutorialMode), true);
#endif
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class MultiplayerCampaign : CampaignMode
{
public MultiplayerCampaign(GameModePreset preset, object param) :
base(preset, param)
{
}
public override void Save(XElement element)
{
throw new NotImplementedException();
}
}
}