Cleaned up the flipping logic a bit, overridable MapEntity.FlipX method
This commit is contained in:
@@ -577,21 +577,7 @@ namespace Barotrauma.Items.Components
|
|||||||
return (average+100.0f)/2.0f;
|
return (average+100.0f)/2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public bool CheckFailure(Character Character)
|
public virtual void FlipX() { }
|
||||||
//{
|
|
||||||
// foreach (Skill skill in requiredSkills)
|
|
||||||
// {
|
|
||||||
// int characterLevel = Character.GetSkillLevel(skill.Name);
|
|
||||||
// if (characterLevel > skill.Level) continue;
|
|
||||||
|
|
||||||
// item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, Character);
|
|
||||||
// //Item.ApplyStatusEffects();
|
|
||||||
// return true;
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public bool HasRequiredContainedItems(bool addMessage)
|
public bool HasRequiredContainedItems(bool addMessage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -470,6 +470,14 @@ namespace Barotrauma.Items.Components
|
|||||||
wireSprite.Depth + ((item.ID % 100) * 0.00001f));
|
wireSprite.Depth + ((item.ID % 100) * 0.00001f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void FlipX()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Nodes.Count; i++)
|
||||||
|
{
|
||||||
|
Nodes[i] = new Vector2(-Nodes[i].X, Nodes[i].Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
public override XElement Save(XElement parentElement)
|
||||||
{
|
{
|
||||||
XElement componentElement = base.Save(parentElement);
|
XElement componentElement = base.Save(parentElement);
|
||||||
|
|||||||
@@ -798,6 +798,16 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void FlipX()
|
||||||
|
{
|
||||||
|
base.FlipX();
|
||||||
|
|
||||||
|
foreach (ItemComponent component in components)
|
||||||
|
{
|
||||||
|
component.FlipX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
return Vector2.Distance(position, WorldPosition) < 50.0f;
|
return Vector2.Distance(position, WorldPosition) < 50.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||||
{
|
{
|
||||||
if (!editing || wallVertices == null) return;
|
if (!editing || wallVertices == null) return;
|
||||||
@@ -212,8 +212,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
return editingHUD;
|
return editingHUD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool Reload(GUIButton button, object obj)
|
private bool Reload(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
var pathBox = obj as GUITextBox;
|
var pathBox = obj as GUITextBox;
|
||||||
|
|||||||
@@ -510,6 +510,20 @@ namespace Barotrauma
|
|||||||
entity.isSelected = true;
|
entity.isSelected = true;
|
||||||
selectedList.Add(entity);
|
selectedList.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void FlipX()
|
||||||
|
{
|
||||||
|
if (Submarine == null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Couldn't flip MapEntity \""+Name+"\", submarine==null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 relative = WorldPosition - Submarine.WorldPosition;
|
||||||
|
relative.Y = 0.0f;
|
||||||
|
|
||||||
|
Move(-relative * 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) {}
|
public virtual void DrawEditing(SpriteBatch spriteBatch, Camera cam) {}
|
||||||
|
|
||||||
|
|||||||
@@ -496,22 +496,12 @@ namespace Barotrauma
|
|||||||
Item.UpdateHulls();
|
Item.UpdateHulls();
|
||||||
|
|
||||||
List<Item> bodyItems = Item.ItemList.FindAll(it => it.Submarine == this && it.body != null);
|
List<Item> bodyItems = Item.ItemList.FindAll(it => it.Submarine == this && it.body != null);
|
||||||
|
|
||||||
List<Vector2> bodyPos = new List<Vector2>();
|
|
||||||
for (int i = 0; i < bodyItems.Count; i++)
|
|
||||||
{
|
|
||||||
Vector2 relative = bodyItems[i].WorldPosition - WorldPosition;
|
|
||||||
relative.Y = 0.0f;
|
|
||||||
|
|
||||||
bodyPos.Add(bodyItems[i].Position - relative*2.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||||
{
|
{
|
||||||
if (e.MoveWithLevel || e.Submarine != this || e is Item || e is WayPoint) continue;
|
if (e.MoveWithLevel || e.Submarine != this || e is Item) continue;
|
||||||
Vector2 relative = e.WorldPosition - WorldPosition;
|
|
||||||
relative.Y = 0.0f;
|
e.FlipX();
|
||||||
e.Move(-relative * 2.0f);
|
|
||||||
|
|
||||||
if (e is LinkedSubmarine)
|
if (e is LinkedSubmarine)
|
||||||
{
|
{
|
||||||
@@ -526,26 +516,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*foreach (Submarine sub in loaded)
|
|
||||||
{
|
|
||||||
if (sub != this && sub.Submarine == this && !parents.Contains(sub))
|
|
||||||
{
|
|
||||||
Vector2 relative = sub.SubBody.Position - SubBody.Position;
|
|
||||||
relative.X = -relative.X;
|
|
||||||
sub.SetPosition(relative + SubBody.Position);
|
|
||||||
sub.FlipX(parents);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
List<WayPoint> subWayPoints = WayPoint.WayPointList.FindAll(wp => wp.Submarine == this);
|
|
||||||
foreach (WayPoint wp in subWayPoints)
|
|
||||||
{
|
|
||||||
Vector2 relative = wp.WorldPosition - WorldPosition;
|
|
||||||
relative.X = -relative.X * 2.0f;
|
|
||||||
relative.Y = 0.0f;
|
|
||||||
wp.Move(relative);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
{
|
{
|
||||||
if (MapEntity.mapEntityList[i].Submarine != this) continue;
|
if (MapEntity.mapEntityList[i].Submarine != this) continue;
|
||||||
@@ -573,30 +543,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (Item item in Item.ItemList)
|
foreach (Item item in Item.ItemList)
|
||||||
{
|
{
|
||||||
if (item.Submarine != this) continue;
|
if (bodyItems.Contains(item))
|
||||||
|
|
||||||
Items.Components.Wire wire = item.GetComponent<Items.Components.Wire>();
|
|
||||||
|
|
||||||
if (wire != null)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < wire.Nodes.Count; i++)
|
item.Submarine = this;
|
||||||
{
|
if (Position == Vector2.Zero) item.Move(-HiddenSubPosition);
|
||||||
wire.Nodes[i] = new Vector2(-wire.Nodes[i].X, wire.Nodes[i].Y);
|
}
|
||||||
}
|
else if (item.Submarine != this)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Submarine != this || bodyItems.Contains(item)) continue;
|
item.FlipX();
|
||||||
|
|
||||||
Vector2 relative = item.WorldPosition - WorldPosition;
|
|
||||||
relative.Y = 0.0f;
|
|
||||||
|
|
||||||
item.Move(-relative * 2.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < bodyItems.Count; i++)
|
|
||||||
{
|
|
||||||
bodyItems[i].SetTransform(ConvertUnits.ToSimUnits(bodyPos[i]), bodyItems[i].body.Rotation);
|
|
||||||
bodyItems[i].Submarine = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.UpdateHulls();
|
Item.UpdateHulls();
|
||||||
|
|||||||
Reference in New Issue
Block a user