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;
|
||||
}
|
||||
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, nameColor, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, -20);
|
||||
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, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Barotrauma
|
||||
TeamASub = Submarine.MainSubs[0];
|
||||
TeamBSub = Submarine.MainSubs[1];
|
||||
TeamBSub.SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
||||
//TeamASub.FlipX();
|
||||
|
||||
foreach (Submarine submarine in Submarine.Loaded)
|
||||
{
|
||||
@@ -128,6 +129,7 @@ namespace Barotrauma
|
||||
if (ADead && !BDead)
|
||||
{
|
||||
//team B wins!
|
||||
GameMain.GameSession.CrewManager.WinningTeam = 2;
|
||||
if (GameMain.Server!=null) GameMain.Server.EndGame();
|
||||
}
|
||||
}
|
||||
@@ -137,6 +139,7 @@ namespace Barotrauma
|
||||
if (BDead && !ADead)
|
||||
{
|
||||
//team A wins!
|
||||
GameMain.GameSession.CrewManager.WinningTeam = 1;
|
||||
if (GameMain.Server != null) GameMain.Server.EndGame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace Barotrauma
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Barotrauma
|
||||
{
|
||||
public List<Character> characters;
|
||||
public List<CharacterInfo> characterInfos;
|
||||
|
||||
public int WinningTeam = 1;
|
||||
|
||||
private int money;
|
||||
|
||||
|
||||
@@ -66,43 +66,46 @@ namespace Barotrauma
|
||||
int x = 0;
|
||||
foreach (Character character in gameSession.CrewManager.characters)
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
if (singleplayer || character.TeamID == GameMain.GameSession.CrewManager.WinningTeam)
|
||||
{
|
||||
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString());
|
||||
statusColor = Color.DarkRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (character.IsUnconscious)
|
||||
{
|
||||
statusText = "Unconscious";
|
||||
statusColor = Color.DarkOrange;
|
||||
}
|
||||
else if (character.Health / character.MaxHealth < 0.8f)
|
||||
{
|
||||
statusText = "Injured";
|
||||
statusColor = Color.DarkOrange;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
|
||||
GUI.Style, Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
|
||||
character.Info.CreateCharacterFrame(characterFrame,
|
||||
character.Info.Job != null ? (character.Info.Name + '\n' + "(" + character.Info.Job.Name + ")") : character.Info.Name, null);
|
||||
|
||||
x += characterFrame.Rect.Width + 10;
|
||||
|
||||
string statusText = "OK";
|
||||
Color statusColor = Color.DarkGreen;
|
||||
|
||||
if (character.IsDead)
|
||||
{
|
||||
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + character.CauseOfDeath.ToString());
|
||||
statusColor = Color.DarkRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
y += 120;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private float lastUpdate;
|
||||
|
||||
private Hull hull1;
|
||||
public Hull hull1;
|
||||
|
||||
private GUITickBox isActiveTickBox;
|
||||
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace Barotrauma
|
||||
{
|
||||
public static List<Hull> hullList = new List<Hull>();
|
||||
private static List<EntityGrid> entityGrids = new List<EntityGrid>();
|
||||
public static List<EntityGrid> EntityGrids
|
||||
{
|
||||
get
|
||||
{
|
||||
return entityGrids;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ShowHulls = true;
|
||||
|
||||
@@ -65,7 +72,7 @@ namespace Barotrauma
|
||||
|
||||
private float lastSentVolume, lastSentOxygen;
|
||||
private float lastNetworkUpdate;
|
||||
|
||||
|
||||
public List<Gap> ConnectedGaps;
|
||||
|
||||
public override string Name
|
||||
@@ -249,7 +256,7 @@ namespace Barotrauma
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static void GenerateEntityGrid(Submarine submarine)
|
||||
public static EntityGrid GenerateEntityGrid(Submarine submarine)
|
||||
{
|
||||
var newGrid = new EntityGrid(submarine, 200.0f);
|
||||
|
||||
@@ -259,6 +266,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (hull.Submarine == submarine) newGrid.InsertEntity(hull);
|
||||
}
|
||||
return newGrid;
|
||||
}
|
||||
|
||||
public void AddToGrid(Submarine submarine)
|
||||
|
||||
@@ -39,6 +39,14 @@ namespace Barotrauma
|
||||
private bool loadSub;
|
||||
private Submarine sub;
|
||||
|
||||
public Submarine Sub
|
||||
{
|
||||
get
|
||||
{
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
|
||||
private XElement saveElement;
|
||||
|
||||
public override bool IsLinkable
|
||||
@@ -48,7 +56,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LinkedSubmarine(Submarine submarine)
|
||||
: base(null, submarine)
|
||||
{
|
||||
@@ -386,8 +394,8 @@ namespace Barotrauma
|
||||
{
|
||||
if (!loadSub) return;
|
||||
|
||||
sub = Submarine.Load(saveElement, false);
|
||||
|
||||
sub = Submarine.Load(saveElement, false);
|
||||
|
||||
Vector2 worldPos = ToolBox.GetAttributeVector2(saveElement, "worldpos", Vector2.Zero);
|
||||
if (worldPos != Vector2.Zero)
|
||||
{
|
||||
@@ -399,8 +407,6 @@ namespace Barotrauma
|
||||
sub.Submarine = Submarine;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var linkedItem = linkedTo.FirstOrDefault(lt => (lt is Item) && ((Item)lt).GetComponent<DockingPort>() != null);
|
||||
|
||||
if (linkedItem == null) return;
|
||||
|
||||
@@ -76,6 +76,8 @@ namespace Barotrauma
|
||||
private Vector2 prevPosition;
|
||||
|
||||
private float lastNetworkUpdate, networkUpdateTimer;
|
||||
|
||||
private EntityGrid entityGrid = null;
|
||||
|
||||
//properties ----------------------------------------------------
|
||||
|
||||
@@ -321,7 +323,7 @@ namespace Barotrauma
|
||||
|
||||
public void UpdateTransform()
|
||||
{
|
||||
DrawPosition = Physics.Interpolate(prevPosition, Position);
|
||||
DrawPosition = Physics.Interpolate(prevPosition, Position);
|
||||
}
|
||||
|
||||
//math/physics stuff ----------------------------------------------------
|
||||
@@ -473,14 +475,136 @@ namespace Barotrauma
|
||||
lastPickedFraction = closestFraction;
|
||||
return closestBody;
|
||||
}
|
||||
|
||||
|
||||
//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)
|
||||
{
|
||||
if (Level.Loaded == null) return;
|
||||
|
||||
if (PlayerInput.KeyHit(InputType.Crouch)) FlipX();
|
||||
|
||||
if (Level.Loaded == null) return;
|
||||
|
||||
if (subBody == null) return;
|
||||
|
||||
subBody.Update(deltaTime);
|
||||
@@ -925,8 +1049,13 @@ namespace Barotrauma
|
||||
|
||||
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++)
|
||||
{
|
||||
if (MapEntity.mapEntityList[i].Submarine != this) continue;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Barotrauma
|
||||
|
||||
public Vector2 TargetPosition
|
||||
{
|
||||
//get { return targetPosition; }
|
||||
//get { return targetPosition.Value; }
|
||||
set
|
||||
{
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
|
||||
@@ -909,7 +909,7 @@ namespace Barotrauma.Networking
|
||||
for (int j = 1; j <= teamCount; j++)
|
||||
{
|
||||
List<Client> teamClients = connectedClients.FindAll(c => c.TeamID == j);
|
||||
if (!teamClients.Any()) continue;
|
||||
if (!teamClients.Any() && j!=1) continue;
|
||||
|
||||
AssignJobs(teamClients);
|
||||
|
||||
@@ -928,7 +928,7 @@ namespace Barotrauma.Networking
|
||||
client.characterInfo.Job = new Job(client.assignedJob);
|
||||
}
|
||||
|
||||
if (characterInfo != null)
|
||||
if (characterInfo != null && j == 1)
|
||||
{
|
||||
characterInfo.Job = new Job(GameMain.NetLobbyScreen.JobPreferences[0]);
|
||||
characterInfos.Add(characterInfo);
|
||||
|
||||
@@ -395,9 +395,9 @@ namespace Barotrauma
|
||||
|
||||
public void ReadNetworkData(NetIncomingMessage message, float sendingTime)
|
||||
{
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
return;
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (sendingTime < lastNetworkUpdateTime) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user