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

View File

@@ -16,7 +16,7 @@ namespace Barotrauma
return;
}
if (!resizeHorizontal && !resizeVertical)
if (!ResizeHorizontal && !ResizeVertical)
{
sprite.Draw(spriteBatch, new Vector2(position.X + sprite.size.X / 2.0f, -position.Y + sprite.size.Y / 2.0f), SpriteColor);
}
@@ -30,9 +30,9 @@ namespace Barotrauma
}
else
{
if (resizeHorizontal)
if (ResizeHorizontal)
placeSize.X = Math.Max(position.X - placePosition.X, size.X);
if (resizeVertical)
if (ResizeVertical)
placeSize.Y = Math.Max(placePosition.Y - position.Y, size.Y);
position = placePosition;

View File

@@ -22,8 +22,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);

View File

@@ -26,8 +26,8 @@ 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);
}

View File

@@ -245,9 +245,9 @@ namespace Barotrauma.Networking
};
foreach (MapEntityPrefab pf in MapEntityPrefab.list)
foreach (MapEntityPrefab pf in MapEntityPrefab.List)
{
if (!(pf is ItemPrefab) || (pf.Price <= 0.0f && !pf.tags.Contains("smallitem"))) continue;
if (!(pf is ItemPrefab) || (pf.Price <= 0.0f && !pf.Tags.Contains("smallitem"))) continue;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 260, 25),

View File

@@ -94,7 +94,7 @@ namespace Barotrauma
List<MapEntityCategory> itemCategories = Enum.GetValues(typeof(MapEntityCategory)).Cast<MapEntityCategory>().ToList();
//don't show categories with no buyable items
itemCategories.RemoveAll(c => !MapEntityPrefab.list.Any(ep => ep.Price > 0.0f && ep.Category.HasFlag(c)));
itemCategories.RemoveAll(c => !MapEntityPrefab.List.Any(ep => ep.Price > 0.0f && ep.Category.HasFlag(c)));
int buttonWidth = Math.Min(sellColumnWidth / itemCategories.Count, 100);
foreach (MapEntityCategory category in itemCategories)
@@ -311,7 +311,7 @@ namespace Barotrauma
storeItemList.ClearChildren();
MapEntityCategory category = (MapEntityCategory)selection;
var items = MapEntityPrefab.list.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category));
var items = MapEntityPrefab.List.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category));
int width = storeItemList.Rect.Width;

View File

@@ -210,7 +210,7 @@ namespace Barotrauma
itemList.OnSelected = SelectPrefab;
itemList.CheckSelected = MapEntityPrefab.GetSelected;
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
foreach (MapEntityPrefab ep in MapEntityPrefab.List)
{
if (!ep.Category.HasFlag(category)) continue;
@@ -756,7 +756,7 @@ namespace Barotrauma
GUIListBox listBox = new GUIListBox(Rectangle.Empty, "", frame);
listBox.OnSelected = SelectWire;
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
foreach (MapEntityPrefab ep in MapEntityPrefab.List)
{
var itemPrefab = ep as ItemPrefab;
if (itemPrefab == null || itemPrefab.Name == null) continue;

View File

@@ -307,7 +307,7 @@ namespace Barotrauma
msg.Write((UInt16)CargoManager.PurchasedItems.Count);
foreach (ItemPrefab ip in CargoManager.PurchasedItems)
{
msg.Write((UInt16)MapEntityPrefab.list.IndexOf(ip));
msg.Write((UInt16)MapEntityPrefab.List.IndexOf(ip));
}
}
@@ -329,7 +329,7 @@ namespace Barotrauma
for (int i = 0; i<purchasedItemCount; i++)
{
UInt16 itemPrefabIndex = msg.ReadUInt16();
purchasedItems.Add(MapEntityPrefab.list[itemPrefabIndex] as ItemPrefab);
purchasedItems.Add(MapEntityPrefab.List[itemPrefabIndex] as ItemPrefab);
}
MultiplayerCampaign campaign = GameMain.GameSession?.GameMode as MultiplayerCampaign;
@@ -384,7 +384,7 @@ namespace Barotrauma
msg.Write((UInt16)CargoManager.PurchasedItems.Count);
foreach (ItemPrefab ip in CargoManager.PurchasedItems)
{
msg.Write((UInt16)MapEntityPrefab.list.IndexOf(ip));
msg.Write((UInt16)MapEntityPrefab.List.IndexOf(ip));
}
}
@@ -397,7 +397,7 @@ namespace Barotrauma
for (int i = 0; i < purchasedItemCount; i++)
{
UInt16 itemPrefabIndex = msg.ReadUInt16();
purchasedItems.Add(MapEntityPrefab.list[itemPrefabIndex] as ItemPrefab);
purchasedItems.Add(MapEntityPrefab.List[itemPrefabIndex] as ItemPrefab);
}
if (!sender.HasPermission(ClientPermissions.ManageCampaign))

View File

@@ -218,7 +218,7 @@ namespace Barotrauma.Items.Components
int nextSectionLength = targetStructure.SectionLength(sectionIndex + i);
if ((sectionIndex == 1 && i == -1) ||
(sectionIndex == targetStructure.SectionCount - 2 && i == 1) ||
(nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f))
(nextSectionLength > 0 && nextSectionLength < Structure.WallSectionSize * 0.3f))
{
//targetStructure.HighLightSection(sectionIndex + i);
targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess);

View File

@@ -146,7 +146,7 @@ namespace Barotrauma
return;
}
if (!resizeHorizontal && !resizeVertical)
if (!ResizeHorizontal && !ResizeVertical)
{
if (PlayerInput.LeftButtonClicked())
{
@@ -172,9 +172,9 @@ namespace Barotrauma
}
else
{
if (resizeHorizontal)
if (ResizeHorizontal)
placeSize.X = Math.Max(position.X - placePosition.X, size.X);
if (resizeVertical)
if (ResizeVertical)
placeSize.Y = Math.Max(placePosition.Y - position.Y, size.Y);
if (PlayerInput.LeftButtonReleased())
@@ -237,9 +237,9 @@ namespace Barotrauma
ConfigElement = element;
name = element.GetAttributeString("name", "");
if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!");
if (name == "") DebugConsole.ThrowError("Unnamed item in " + filePath + "!");
DebugConsole.Log(" "+name);
DebugConsole.Log(" " + name);
Description = element.GetAttributeString("description", "");
@@ -249,8 +249,8 @@ namespace Barotrauma
isLinkable = element.GetAttributeBool("linkable", false);
resizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
resizeVertical = element.GetAttributeBool("resizevertical", false);
ResizeHorizontal = element.GetAttributeBool("resizehorizontal", false);
ResizeVertical = element.GetAttributeBool("resizevertical", false);
focusOnSelected = element.GetAttributeBool("focusonselected", false);
@@ -277,10 +277,8 @@ namespace Barotrauma
}
Category = category;
string spriteColorStr = element.GetAttributeString("spritecolor", "1.0,1.0,1.0,1.0");
SpriteColor = new Color(XMLExtensions.ParseVector4(spriteColorStr));
SpriteColor = element.GetAttributeColor("spritecolor", Color.White);
price = element.GetAttributeInt("price", 0);
@@ -289,8 +287,8 @@ namespace Barotrauma
DeconstructItems = new List<DeconstructItem>();
DeconstructTime = 1.0f;
tags = new List<string>();
tags.AddRange(element.GetAttributeString("tags", "").Split(','));
Tags = new List<string>();
Tags.AddRange(element.GetAttributeString("tags", "").Split(','));
foreach (XElement subElement in element.Elements())
{
@@ -337,7 +335,7 @@ namespace Barotrauma
}
}
list.Add(this);
List.Add(this);
}
}
}

View File

@@ -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())
{

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -1295,7 +1295,7 @@ namespace Barotrauma.Networking
foreach (string s in extraCargo.Keys)
{
ItemPrefab itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name == s) as ItemPrefab;
ItemPrefab itemPrefab = MapEntityPrefab.Find(s) as ItemPrefab;
if (itemPrefab == null) continue;
for (int i = 0; i < extraCargo[s]; i++)

View File

@@ -164,7 +164,6 @@ namespace Barotrauma
public static bool GetAttributeBool(this XElement element, string name, bool defaultValue)
{
if (element?.Attribute(name) == null) return defaultValue;
return element.Attribute(name).GetAttributeBool(defaultValue);
}
@@ -189,37 +188,31 @@ namespace Barotrauma
public static Vector2 GetAttributeVector2(this XElement element, string name, Vector2 defaultValue)
{
if (element?.Attribute(name) == null) return defaultValue;
string val = element.Attribute(name).Value;
return ParseVector2(val);
return ParseVector2(element.Attribute(name).Value);
}
public static Vector3 GetAttributeVector3(this XElement element, string name, Vector3 defaultValue)
{
if (element == null || element.Attribute(name) == null) return defaultValue;
string val = element.Attribute(name).Value;
return ParseVector3(val);
return ParseVector3(element.Attribute(name).Value);
}
public static Vector4 GetAttributeVector4(this XElement element, string name, Vector4 defaultValue)
{
if (element == null || element.Attribute(name) == null) return defaultValue;
return ParseVector4(element.Attribute(name).Value);
}
string val = element.Attribute(name).Value;
return ParseVector4(val);
public static Color GetAttributeColor(this XElement element, string name, Color defaultValue)
{
if (element == null || element.Attribute(name) == null) return defaultValue;
return ParseColor(element.Attribute(name).Value);
}
public static Rectangle GetAttributeRect(this XElement element, string name, Rectangle defaultValue)
{
if (element == null || element.Attribute(name) == null) return defaultValue;
string val = element.Attribute(name).Value;
return ParseRect(val, false);
return ParseRect(element.Attribute(name).Value, false);
}
public static string ElementInnerText(this XElement el)