Merged branch combat-mission into combat-mission
This commit is contained in:
@@ -577,21 +577,7 @@ namespace Barotrauma.Items.Components
|
||||
return (average+100.0f)/2.0f;
|
||||
}
|
||||
|
||||
//public bool CheckFailure(Character Character)
|
||||
//{
|
||||
// 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 virtual void FlipX() { }
|
||||
|
||||
public bool HasRequiredContainedItems(bool addMessage)
|
||||
{
|
||||
|
||||
@@ -470,6 +470,14 @@ namespace Barotrauma.Items.Components
|
||||
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)
|
||||
{
|
||||
XElement componentElement = base.Save(parentElement);
|
||||
|
||||
@@ -798,6 +798,16 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Barotrauma
|
||||
{
|
||||
return Vector2.Distance(position, WorldPosition) < 50.0f;
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (!editing || wallVertices == null) return;
|
||||
@@ -212,8 +212,7 @@ namespace Barotrauma
|
||||
}
|
||||
return editingHUD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool Reload(GUIButton button, object obj)
|
||||
{
|
||||
var pathBox = obj as GUITextBox;
|
||||
|
||||
@@ -510,6 +510,20 @@ namespace Barotrauma
|
||||
entity.isSelected = true;
|
||||
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) {}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ namespace Barotrauma
|
||||
|
||||
public Direction StairDirection
|
||||
{
|
||||
get { return prefab.StairDirection; }
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
@@ -176,6 +177,8 @@ namespace Barotrauma
|
||||
prefab = sp;
|
||||
|
||||
isHorizontal = (rect.Width>rect.Height);
|
||||
|
||||
StairDirection = prefab.StairDirection;
|
||||
|
||||
if (prefab.HasBody)
|
||||
{
|
||||
@@ -207,29 +210,9 @@ namespace Barotrauma
|
||||
sections = new WallSection[1];
|
||||
sections[0] = new WallSection(rect);
|
||||
|
||||
if (StairDirection!=Direction.None)
|
||||
if (StairDirection != Direction.None)
|
||||
{
|
||||
bodies = new List<Body>();
|
||||
|
||||
Body newBody = BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(rect.Width * Math.Sqrt(2.0) + Submarine.GridSize.X*3.0f),
|
||||
ConvertUnits.ToSimUnits(10),
|
||||
1.5f);
|
||||
|
||||
newBody.BodyType = BodyType.Static;
|
||||
Vector2 stairPos = new Vector2(Position.X, rect.Y - rect.Height + rect.Width / 2.0f);
|
||||
stairPos += new Vector2(
|
||||
(StairDirection == Direction.Right) ? -Submarine.GridSize.X*1.5f : Submarine.GridSize.X*1.5f,
|
||||
- Submarine.GridSize.Y*2.0f);
|
||||
|
||||
newBody.Position = ConvertUnits.ToSimUnits(stairPos);
|
||||
newBody.Rotation = (StairDirection == Direction.Right) ? MathHelper.PiOver4 : -MathHelper.PiOver4;
|
||||
newBody.Friction = 0.8f;
|
||||
|
||||
newBody.CollisionCategories = Physics.CollisionStairs;
|
||||
|
||||
newBody.UserData = this;
|
||||
bodies.Add(newBody);
|
||||
CreateStairBodies();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +225,31 @@ namespace Barotrauma
|
||||
InsertToList();
|
||||
}
|
||||
|
||||
private void CreateStairBodies()
|
||||
{
|
||||
bodies = new List<Body>();
|
||||
|
||||
Body newBody = BodyFactory.CreateRectangle(GameMain.World,
|
||||
ConvertUnits.ToSimUnits(rect.Width * Math.Sqrt(2.0) + Submarine.GridSize.X * 3.0f),
|
||||
ConvertUnits.ToSimUnits(10),
|
||||
1.5f);
|
||||
|
||||
newBody.BodyType = BodyType.Static;
|
||||
Vector2 stairPos = new Vector2(Position.X, rect.Y - rect.Height + rect.Width / 2.0f);
|
||||
stairPos += new Vector2(
|
||||
(StairDirection == Direction.Right) ? -Submarine.GridSize.X * 1.5f : Submarine.GridSize.X * 1.5f,
|
||||
-Submarine.GridSize.Y * 2.0f);
|
||||
|
||||
newBody.Position = ConvertUnits.ToSimUnits(stairPos);
|
||||
newBody.Rotation = (StairDirection == Direction.Right) ? MathHelper.PiOver4 : -MathHelper.PiOver4;
|
||||
newBody.Friction = 0.8f;
|
||||
|
||||
newBody.CollisionCategories = Physics.CollisionStairs;
|
||||
|
||||
newBody.UserData = this;
|
||||
bodies.Add(newBody);
|
||||
}
|
||||
|
||||
private void CreateSections()
|
||||
{
|
||||
int xsections = 1, ysections = 1;
|
||||
@@ -736,6 +744,20 @@ namespace Barotrauma
|
||||
return newBody;
|
||||
}
|
||||
|
||||
public override void FlipX()
|
||||
{
|
||||
base.FlipX();
|
||||
|
||||
if (StairDirection != Direction.None)
|
||||
{
|
||||
StairDirection = StairDirection == Direction.Left ? Direction.Right : Direction.Left;
|
||||
bodies.ForEach(b => GameMain.World.RemoveBody(b));
|
||||
|
||||
CreateStairBodies();
|
||||
}
|
||||
|
||||
//todo: flip sprites & wall sections
|
||||
}
|
||||
|
||||
public override XElement Save(XElement parentElement)
|
||||
{
|
||||
|
||||
@@ -494,19 +494,11 @@ namespace Barotrauma
|
||||
Item.UpdateHulls();
|
||||
|
||||
List<Item> bodyItems = Item.ItemList.FindAll(it => it.Submarine == this && it.body != null);
|
||||
List<Vector2> bodyPos = new List<Vector2>(); bodyItems.ForEach(it => bodyPos.Add(Vector2.Zero));
|
||||
for (int i = 0; i < bodyItems.Count; i++)
|
||||
{
|
||||
bodyPos[i] = bodyItems[i].WorldPosition;
|
||||
}
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
if (e.MoveWithLevel || e.Submarine != this || e is Item || e is WayPoint) continue;
|
||||
Vector2 relative = e.WorldPosition - WorldPosition;
|
||||
relative.X = -relative.X*2.0f;
|
||||
relative.Y = 0.0f;
|
||||
e.Move(relative);
|
||||
if (e.MoveWithLevel || e.Submarine != this || e is Item) continue;
|
||||
|
||||
if (e is LinkedSubmarine)
|
||||
{
|
||||
Submarine sub = ((LinkedSubmarine)e).Sub;
|
||||
@@ -518,26 +510,10 @@ namespace Barotrauma
|
||||
sub.FlipX(parents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*foreach (Submarine sub in loaded)
|
||||
{
|
||||
if (sub != this && sub.Submarine == this && !parents.Contains(sub))
|
||||
else
|
||||
{
|
||||
Vector2 relative = sub.SubBody.Position - SubBody.Position;
|
||||
relative.X = -relative.X;
|
||||
sub.SetPosition(relative + SubBody.Position);
|
||||
sub.FlipX(parents);
|
||||
e.FlipX();
|
||||
}
|
||||
}*/
|
||||
|
||||
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++)
|
||||
@@ -567,31 +543,17 @@ namespace Barotrauma
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.Submarine != this || bodyItems.Contains(item)) continue;
|
||||
|
||||
Vector2 relative;
|
||||
relative = item.WorldPosition - WorldPosition;
|
||||
relative.X = -relative.X * 2.0f;
|
||||
relative.Y = 0.0f;
|
||||
|
||||
Items.Components.Wire wire = item.GetComponent<Items.Components.Wire>();
|
||||
|
||||
if (wire != null)
|
||||
if (bodyItems.Contains(item))
|
||||
{
|
||||
for (int i = 0; i < wire.Nodes.Count; i++)
|
||||
{
|
||||
wire.Nodes[i] = new Vector2(-wire.Nodes[i].X, wire.Nodes[i].Y);
|
||||
}
|
||||
item.Submarine = this;
|
||||
if (Position == Vector2.Zero) item.Move(-HiddenSubPosition);
|
||||
}
|
||||
else if (item.Submarine != this)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
item.Move(relative);
|
||||
}
|
||||
|
||||
for (int i=0;i<bodyItems.Count;i++)
|
||||
{
|
||||
Vector2 relative = bodyPos[i] - bodyItems[i].WorldPosition;
|
||||
bodyItems[i].Move(relative);
|
||||
if (bodyItems[i].Name.ToLower().Contains("suit")) DebugConsole.NewMessage(bodyItems[i].Name,Color.Red);
|
||||
item.FlipX();
|
||||
}
|
||||
|
||||
Item.UpdateHulls();
|
||||
@@ -600,8 +562,7 @@ namespace Barotrauma
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
|
||||
if (PlayerInput.KeyHit(InputType.Crouch)) FlipX();
|
||||
if (PlayerInput.KeyHit(InputType.Crouch) && (this == MainSub)) FlipX();
|
||||
|
||||
if (Level.Loaded == null) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user