Mission refactoring (mission prefabs) and option to select which types of missions can be selected when mission type is set to random (TODO: a way to set the allowed types from the UI).

This commit is contained in:
Joonas Rikkonen
2018-05-17 23:45:29 +03:00
parent 244acd3ec5
commit f931d81aed
15 changed files with 273 additions and 191 deletions
@@ -1,7 +1,6 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Xml.Linq;
namespace Barotrauma
{
@@ -23,10 +22,10 @@ namespace Barotrauma
}
}
public SalvageMission(XElement element, Location[] locations)
: base(element, locations)
public SalvageMission(MissionPrefab prefab, Location[] locations)
: base(prefab, locations)
{
string itemName = element.GetAttributeString("itemname", "");
string itemName = prefab.ConfigElement.GetAttributeString("itemname", "");
itemPrefab = MapEntityPrefab.Find(itemName) as ItemPrefab;
if (itemPrefab == null)
@@ -35,10 +34,10 @@ namespace Barotrauma
return;
}
string spawnPositionTypeStr = element.GetAttributeString("spawntype", "");
string spawnPositionTypeStr = prefab.ConfigElement.GetAttributeString("spawntype", "");
if (string.IsNullOrWhiteSpace(spawnPositionTypeStr) ||
!Enum.TryParse<Level.PositionType>(spawnPositionTypeStr, true, out spawnPositionType))
!Enum.TryParse(spawnPositionTypeStr, true, out spawnPositionType))
{
spawnPositionType = Level.PositionType.Cave | Level.PositionType.Ruin;
}