Renaming fields for consistency

This commit is contained in:
Joonas Rikkonen
2017-11-14 22:45:22 +02:00
parent 5f4bf48449
commit 04e3710a65
15 changed files with 83 additions and 108 deletions
@@ -105,7 +105,7 @@ namespace Barotrauma
List<Vector2> points = new List<Vector2>();
var wallPrefabs =
MapEntityPrefab.list.FindAll(mp => (mp is StructurePrefab) && ((StructurePrefab)mp).HasBody);
MapEntityPrefab.List.FindAll(mp => (mp is StructurePrefab) && ((StructurePrefab)mp).HasBody);
foreach (XElement element in rootElement.Elements())
{
@@ -14,11 +14,15 @@ namespace Barotrauma
partial class MapEntityPrefab
{
public static List<MapEntityPrefab> list = new List<MapEntityPrefab>();
public readonly static List<MapEntityPrefab> List = new List<MapEntityPrefab>();
protected string name;
public List<string> tags;
public List<string> Tags
{
get;
protected set;
}
protected bool isLinkable;
@@ -30,8 +34,8 @@ namespace Barotrauma
protected ConstructorInfo constructor;
//is it possible to stretch the entity horizontally/vertically
public bool resizeHorizontal { get; protected set; }
public bool resizeVertical { get; protected set; }
public bool ResizeHorizontal { get; protected set; }
public bool ResizeVertical { get; protected set; }
//which prefab has been selected for placing
protected static MapEntityPrefab selected;
@@ -60,17 +64,7 @@ namespace Barotrauma
{
get { return isLinkable; }
}
public bool ResizeHorizontal
{
get { return resizeHorizontal; }
}
public bool ResizeVertical
{
get { return resizeVertical; }
}
public MapEntityCategory Category
{
get;
@@ -102,27 +96,27 @@ namespace Barotrauma
ep.name = "Hull";
ep.Description = "Hulls determine which parts are considered to be \"inside the sub\". Generally every room should be enclosed by a hull.";
ep.constructor = typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep.resizeHorizontal = true;
ep.resizeVertical = true;
list.Add(ep);
ep.ResizeHorizontal = true;
ep.ResizeVertical = true;
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Gap";
ep.Description = "Gaps allow water and air to flow between two hulls. ";
ep.constructor = typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
ep.resizeHorizontal = true;
ep.resizeVertical = true;
list.Add(ep);
ep.ResizeHorizontal = true;
ep.ResizeVertical = true;
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Waypoint";
ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
list.Add(ep);
List.Add(ep);
ep = new MapEntityPrefab();
ep.name = "Spawnpoint";
ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) });
list.Add(ep);
List.Add(ep);
}
public MapEntityPrefab()
@@ -144,8 +138,8 @@ namespace Barotrauma
{
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
if (ResizeHorizontal) placeSize.X = position.X - placePosition.X;
if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y;
Rectangle newRect = Submarine.AbsRect(placePosition, placeSize);
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
@@ -196,7 +190,7 @@ namespace Barotrauma
{
if (caseSensitive)
{
foreach (MapEntityPrefab prefab in list)
foreach (MapEntityPrefab prefab in List)
{
if (prefab.name == name || (prefab.Aliases != null && prefab.Aliases.Contains(name))) return prefab;
}
@@ -204,7 +198,7 @@ namespace Barotrauma
else
{
name = name.ToLowerInvariant();
foreach (MapEntityPrefab prefab in list)
foreach (MapEntityPrefab prefab in List)
{
if (prefab.name.ToLowerInvariant() == name || (prefab.Aliases != null && prefab.Aliases.Any(a => a.ToLowerInvariant() == name))) return prefab;
}
@@ -42,7 +42,7 @@ namespace Barotrauma
partial class Structure : MapEntity, IDamageable, IServerSerializable, ISerializableEntity
{
public static int wallSectionSize = 96;
public const int WallSectionSize = 96;
public static List<Structure> WallList = new List<Structure>();
private StructurePrefab prefab;
@@ -54,24 +54,14 @@ namespace Barotrauma
private SpriteEffects SpriteEffects = SpriteEffects.None;
private bool flippedX;
//sections of the wall that are supposed to be rendered
public WallSection[] sections
{
get;
private set;
}
public bool resizeHorizontal
{
get { return prefab.resizeHorizontal; }
}
public bool resizeVertical
{
get { return prefab.resizeVertical; }
}
private bool flippedX;
}
public override Sprite Sprite
{
@@ -145,7 +135,7 @@ namespace Barotrauma
public List<string> Tags
{
get { return prefab.tags; }
get { return prefab.Tags; }
}
protected Color spriteColor;
@@ -334,15 +324,15 @@ namespace Barotrauma
{
if (isHorizontal)
{
xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize);
xsections = (int)Math.Ceiling((float)rect.Width / WallSectionSize);
sections = new WallSection[xsections];
width = (int)wallSectionSize;
width = (int)WallSectionSize;
}
else
{
ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize);
ysections = (int)Math.Ceiling((float)rect.Height / WallSectionSize);
sections = new WallSection[ysections];
height = (int)wallSectionSize;
height = (int)WallSectionSize;
}
}
@@ -599,14 +589,14 @@ namespace Barotrauma
//if the sub has been flipped horizontally, the first section may be smaller than wallSectionSize
//and we need to adjust the position accordingly
if (sections[0].rect.Width < wallSectionSize)
if (sections[0].rect.Width < WallSectionSize)
{
displayPos.X += wallSectionSize - sections[0].rect.Width;
displayPos.X += WallSectionSize - sections[0].rect.Width;
}
int index = (isHorizontal) ?
(int)Math.Floor((displayPos.X - rect.X) / wallSectionSize) :
(int)Math.Floor((rect.Y - displayPos.Y) / wallSectionSize);
(int)Math.Floor((displayPos.X - rect.X) / WallSectionSize) :
(int)Math.Floor((rect.Y - displayPos.Y) / WallSectionSize);
if (index < 0 || index > sections.Length - 1) return -1;
return index;
@@ -74,7 +74,7 @@ namespace Barotrauma
{
StructurePrefab sp = Load(el);
list.Add(sp);
List.Add(sp);
}
}
}
@@ -84,8 +84,8 @@ namespace Barotrauma
StructurePrefab sp = new StructurePrefab();
sp.name = element.Name.ToString();
sp.tags = new List<string>();
sp.tags.AddRange(element.GetAttributeString("tags", "").Split(','));
sp.Tags = new List<string>();
sp.Tags.AddRange(element.GetAttributeString("tags", "").Split(','));
foreach (XElement subElement in element.Elements())
{
@@ -140,8 +140,8 @@ namespace Barotrauma
sp.maxHealth = element.GetAttributeFloat("health", 100.0f);
sp.resizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
sp.resizeVertical = element.GetAttributeBool("resizevertical", false);
sp.ResizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
sp.ResizeVertical = element.GetAttributeBool("resizevertical", false);
sp.isPlatform = element.GetAttributeBool("platform", false);
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), element.GetAttributeString("stairdirection", "None"), true);
@@ -169,15 +169,15 @@ namespace Barotrauma
else
{
Vector2 placeSize = size;
if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
if (ResizeHorizontal) placeSize.X = position.X - placePosition.X;
if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y;
newRect = Submarine.AbsRect(placePosition, placeSize);
if (PlayerInput.LeftButtonReleased())
{
//don't allow resizing width/height to zero
if ((!resizeHorizontal || placeSize.X != 0.0f) && (!resizeVertical || placeSize.Y != 0.0f))
if ((!ResizeHorizontal || placeSize.X != 0.0f) && (!ResizeVertical || placeSize.Y != 0.0f))
{
newRect.Location -= MathUtils.ToPoint(Submarine.MainSub.Position);