Some progress on flipping subs
Press crouch to flip every sub in the map, texture alignment breaks and physics items vanish, but other than that it's working.
This commit is contained in:
@@ -1327,8 +1327,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
nameColor = Color.Red;
|
nameColor = Color.Red;
|
||||||
}
|
}
|
||||||
spriteBatch.DrawString(GUI.Font, Info.Name, namePos - new Vector2(1.0f, 1.0f), Color.Black, 0.0f,Vector2.Zero,1.0f,SpriteEffects.None,-15);
|
spriteBatch.DrawString(GUI.Font, Info.Name, namePos + new Vector2(1.0f, 1.0f), Color.Black, 0.0f,Vector2.Zero,Vector2.One,SpriteEffects.None,0.001f);
|
||||||
spriteBatch.DrawString(GUI.Font, Info.Name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, -20);
|
spriteBatch.DrawString(GUI.Font, Info.Name, namePos, nameColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||||
|
|
||||||
if (GameMain.DebugDraw)
|
if (GameMain.DebugDraw)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace Barotrauma
|
|||||||
TeamASub = Submarine.MainSubs[0];
|
TeamASub = Submarine.MainSubs[0];
|
||||||
TeamBSub = Submarine.MainSubs[1];
|
TeamBSub = Submarine.MainSubs[1];
|
||||||
TeamBSub.SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
TeamBSub.SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
||||||
|
//TeamASub.FlipX();
|
||||||
|
|
||||||
foreach (Submarine submarine in Submarine.Loaded)
|
foreach (Submarine submarine in Submarine.Loaded)
|
||||||
{
|
{
|
||||||
@@ -128,6 +129,7 @@ namespace Barotrauma
|
|||||||
if (ADead && !BDead)
|
if (ADead && !BDead)
|
||||||
{
|
{
|
||||||
//team B wins!
|
//team B wins!
|
||||||
|
GameMain.GameSession.CrewManager.WinningTeam = 2;
|
||||||
if (GameMain.Server!=null) GameMain.Server.EndGame();
|
if (GameMain.Server!=null) GameMain.Server.EndGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,6 +139,7 @@ namespace Barotrauma
|
|||||||
if (BDead && !ADead)
|
if (BDead && !ADead)
|
||||||
{
|
{
|
||||||
//team A wins!
|
//team A wins!
|
||||||
|
GameMain.GameSession.CrewManager.WinningTeam = 1;
|
||||||
if (GameMain.Server != null) GameMain.Server.EndGame();
|
if (GameMain.Server != null) GameMain.Server.EndGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual void Update(float deltaTime) { }
|
public virtual void Update(float deltaTime) { }
|
||||||
|
|
||||||
public virtual bool AssignTeamIDs(List<Networking.Client> clients) { return false; }
|
public virtual bool AssignTeamIDs(List<Networking.Client> clients) { clients.ForEach(client => { client.TeamID = 1; }); return false; }
|
||||||
|
|
||||||
public void ShowMessage(int index)
|
public void ShowMessage(int index)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace Barotrauma
|
|||||||
public List<Character> characters;
|
public List<Character> characters;
|
||||||
public List<CharacterInfo> characterInfos;
|
public List<CharacterInfo> characterInfos;
|
||||||
|
|
||||||
|
public int WinningTeam = 1;
|
||||||
|
|
||||||
private int money;
|
private int money;
|
||||||
|
|
||||||
private GUIFrame guiFrame;
|
private GUIFrame guiFrame;
|
||||||
|
|||||||
@@ -66,43 +66,46 @@ namespace Barotrauma
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
foreach (Character character in gameSession.CrewManager.characters)
|
foreach (Character character in gameSession.CrewManager.characters)
|
||||||
{
|
{
|
||||||
var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), Color.Transparent, GUI.Style, listBox);
|
if (singleplayer || character.TeamID == GameMain.GameSession.CrewManager.WinningTeam)
|
||||||
characterFrame.OutlineColor = Color.Transparent;
|
|
||||||
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
|
||||||
characterFrame.CanBeFocused = false;
|
|
||||||
|
|
||||||
character.Info.CreateCharacterFrame(characterFrame,
|
|
||||||
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
|
|
||||||
|
|
||||||
|
|
||||||
string statusText = "OK";
|
|
||||||
Color statusColor = Color.DarkGreen;
|
|
||||||
|
|
||||||
if (character.IsDead)
|
|
||||||
{
|
|
||||||
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString());
|
|
||||||
statusColor = Color.DarkRed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
var characterFrame = new GUIFrame(new Rectangle(x, y, 170, 70), Color.Transparent, GUI.Style, listBox);
|
||||||
|
characterFrame.OutlineColor = Color.Transparent;
|
||||||
|
characterFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||||
|
characterFrame.CanBeFocused = false;
|
||||||
|
|
||||||
if (character.IsUnconscious)
|
character.Info.CreateCharacterFrame(characterFrame,
|
||||||
|
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
|
||||||
|
|
||||||
|
|
||||||
|
string statusText = "OK";
|
||||||
|
Color statusColor = Color.DarkGreen;
|
||||||
|
|
||||||
|
if (character.IsDead)
|
||||||
{
|
{
|
||||||
statusText = "Unconscious";
|
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString());
|
||||||
statusColor = Color.DarkOrange;
|
statusColor = Color.DarkRed;
|
||||||
}
|
}
|
||||||
else if (character.Health / character.MaxHealth < 0.8f)
|
else
|
||||||
{
|
{
|
||||||
statusText = "Injured";
|
|
||||||
statusColor = Color.DarkOrange;
|
if (character.IsUnconscious)
|
||||||
|
{
|
||||||
|
statusText = "Unconscious";
|
||||||
|
statusColor = Color.DarkOrange;
|
||||||
|
}
|
||||||
|
else if (character.Health / character.MaxHealth < 0.8f)
|
||||||
|
{
|
||||||
|
statusText = "Injured";
|
||||||
|
statusColor = Color.DarkOrange;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
|
||||||
|
GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
|
||||||
|
|
||||||
|
x += characterFrame.Rect.Width + 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
|
|
||||||
GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
|
|
||||||
|
|
||||||
x += characterFrame.Rect.Width + 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 120;
|
y += 120;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private float lastUpdate;
|
private float lastUpdate;
|
||||||
|
|
||||||
private Hull hull1;
|
public Hull hull1;
|
||||||
|
|
||||||
private GUITickBox isActiveTickBox;
|
private GUITickBox isActiveTickBox;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
public static List<Hull> hullList = new List<Hull>();
|
public static List<Hull> hullList = new List<Hull>();
|
||||||
private static List<EntityGrid> entityGrids = new List<EntityGrid>();
|
private static List<EntityGrid> entityGrids = new List<EntityGrid>();
|
||||||
|
public static List<EntityGrid> EntityGrids
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return entityGrids;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool ShowHulls = true;
|
public static bool ShowHulls = true;
|
||||||
|
|
||||||
@@ -249,7 +256,7 @@ namespace Barotrauma
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GenerateEntityGrid(Submarine submarine)
|
public static EntityGrid GenerateEntityGrid(Submarine submarine)
|
||||||
{
|
{
|
||||||
var newGrid = new EntityGrid(submarine, 200.0f);
|
var newGrid = new EntityGrid(submarine, 200.0f);
|
||||||
|
|
||||||
@@ -259,6 +266,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (hull.Submarine == submarine) newGrid.InsertEntity(hull);
|
if (hull.Submarine == submarine) newGrid.InsertEntity(hull);
|
||||||
}
|
}
|
||||||
|
return newGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddToGrid(Submarine submarine)
|
public void AddToGrid(Submarine submarine)
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ namespace Barotrauma
|
|||||||
private bool loadSub;
|
private bool loadSub;
|
||||||
private Submarine sub;
|
private Submarine sub;
|
||||||
|
|
||||||
|
public Submarine Sub
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private XElement saveElement;
|
private XElement saveElement;
|
||||||
|
|
||||||
public override bool IsLinkable
|
public override bool IsLinkable
|
||||||
@@ -399,8 +407,6 @@ namespace Barotrauma
|
|||||||
sub.Submarine = Submarine;
|
sub.Submarine = Submarine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var linkedItem = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
var linkedItem = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||||
|
|
||||||
if (linkedItem == null) return;
|
if (linkedItem == null) return;
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private float lastNetworkUpdate, networkUpdateTimer;
|
private float lastNetworkUpdate, networkUpdateTimer;
|
||||||
|
|
||||||
|
private EntityGrid entityGrid = null;
|
||||||
|
|
||||||
//properties ----------------------------------------------------
|
//properties ----------------------------------------------------
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
@@ -476,9 +478,131 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//movement ----------------------------------------------------
|
//movement ----------------------------------------------------
|
||||||
|
|
||||||
|
private bool flippedX = false;
|
||||||
|
public bool FlippedX
|
||||||
|
{
|
||||||
|
get { return flippedX; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FlipX(List<Submarine> parents=null)
|
||||||
|
{
|
||||||
|
if (parents == null) parents = new List<Submarine>();
|
||||||
|
parents.Add(this);
|
||||||
|
|
||||||
|
flippedX = !flippedX;
|
||||||
|
|
||||||
|
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 is LinkedSubmarine)
|
||||||
|
{
|
||||||
|
Submarine sub = ((LinkedSubmarine)e).Sub;
|
||||||
|
if (!parents.Contains(sub))
|
||||||
|
{
|
||||||
|
Vector2 relative1 = sub.SubBody.Position - SubBody.Position;
|
||||||
|
relative1.X = -relative1.X;
|
||||||
|
sub.SetPosition(relative1 + SubBody.Position);
|
||||||
|
sub.FlipX(parents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*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++)
|
||||||
|
{
|
||||||
|
if (MapEntity.mapEntityList[i].Submarine != this) continue;
|
||||||
|
MapEntity.mapEntityList[i].Move(-HiddenSubPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 pos = new Vector2(subBody.Position.X, subBody.Position.Y);
|
||||||
|
SubmarineBody newSubBody = new SubmarineBody(this);
|
||||||
|
GameMain.World.RemoveBody(subBody.Body);
|
||||||
|
subBody = newSubBody;
|
||||||
|
SetPosition(pos);
|
||||||
|
|
||||||
|
if (entityGrid != null)
|
||||||
|
{
|
||||||
|
Hull.EntityGrids.Remove(entityGrid);
|
||||||
|
entityGrid = null;
|
||||||
|
}
|
||||||
|
entityGrid = Hull.GenerateEntityGrid(this);
|
||||||
|
|
||||||
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
|
{
|
||||||
|
if (MapEntity.mapEntityList[i].Submarine != this) continue;
|
||||||
|
MapEntity.mapEntityList[i].Move(HiddenSubPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < wire.Nodes.Count; i++)
|
||||||
|
{
|
||||||
|
wire.Nodes[i] = new Vector2(-wire.Nodes[i].X, wire.Nodes[i].Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.UpdateHulls();
|
||||||
|
Gap.UpdateHulls();
|
||||||
|
}
|
||||||
|
|
||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (PlayerInput.KeyHit(InputType.Crouch)) FlipX();
|
||||||
|
|
||||||
if (Level.Loaded == null) return;
|
if (Level.Loaded == null) return;
|
||||||
|
|
||||||
if (subBody == null) return;
|
if (subBody == null) return;
|
||||||
@@ -925,7 +1049,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
loaded.Add(this);
|
loaded.Add(this);
|
||||||
|
|
||||||
Hull.GenerateEntityGrid(this);
|
if (entityGrid != null)
|
||||||
|
{
|
||||||
|
Hull.EntityGrids.Remove(entityGrid);
|
||||||
|
entityGrid = null;
|
||||||
|
}
|
||||||
|
entityGrid = Hull.GenerateEntityGrid(this);
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Vector2 TargetPosition
|
public Vector2 TargetPosition
|
||||||
{
|
{
|
||||||
//get { return targetPosition; }
|
//get { return targetPosition.Value; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!MathUtils.IsValid(value)) return;
|
if (!MathUtils.IsValid(value)) return;
|
||||||
|
|||||||
@@ -909,7 +909,7 @@ namespace Barotrauma.Networking
|
|||||||
for (int j = 1; j <= teamCount; j++)
|
for (int j = 1; j <= teamCount; j++)
|
||||||
{
|
{
|
||||||
List<Client> teamClients = connectedClients.FindAll(c => c.TeamID == j);
|
List<Client> teamClients = connectedClients.FindAll(c => c.TeamID == j);
|
||||||
if (!teamClients.Any()) continue;
|
if (!teamClients.Any() && j!=1) continue;
|
||||||
|
|
||||||
AssignJobs(teamClients);
|
AssignJobs(teamClients);
|
||||||
|
|
||||||
@@ -928,7 +928,7 @@ namespace Barotrauma.Networking
|
|||||||
client.characterInfo.Job = new Job(client.assignedJob);
|
client.characterInfo.Job = new Job(client.assignedJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (characterInfo != null)
|
if (characterInfo != null && j == 1)
|
||||||
{
|
{
|
||||||
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
||||||
characterInfos.Add(characterInfo);
|
characterInfos.Add(characterInfo);
|
||||||
|
|||||||
Reference in New Issue
Block a user