Progress (compiles now)
This commit is contained in:
@@ -78,6 +78,7 @@ namespace Barotrauma
|
|||||||
Vector2 pos = host.SimPosition;
|
Vector2 pos = host.SimPosition;
|
||||||
if (character!=null && character.Submarine==null)
|
if (character!=null && character.Submarine==null)
|
||||||
{
|
{
|
||||||
|
//todo: take multiple subs into account
|
||||||
pos -= Submarine.MainSub.SimPosition;
|
pos -= Submarine.MainSub.SimPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ namespace Barotrauma
|
|||||||
Vector2 pos2 = host.SimPosition;
|
Vector2 pos2 = host.SimPosition;
|
||||||
if (character != null && character.Submarine == null)
|
if (character != null && character.Submarine == null)
|
||||||
{
|
{
|
||||||
|
//todo: take multiple subs into account
|
||||||
pos2 -= Submarine.MainSub.SimPosition;
|
pos2 -= Submarine.MainSub.SimPosition;
|
||||||
}
|
}
|
||||||
return currentTarget-pos2;
|
return currentTarget-pos2;
|
||||||
@@ -120,6 +122,7 @@ namespace Barotrauma
|
|||||||
Vector2 pos = host.SimPosition;
|
Vector2 pos = host.SimPosition;
|
||||||
if (character != null && character.Submarine == null)
|
if (character != null && character.Submarine == null)
|
||||||
{
|
{
|
||||||
|
//todo: take multiple subs into account
|
||||||
pos -= Submarine.MainSub.SimPosition;
|
pos -= Submarine.MainSub.SimPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,21 +86,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
Coroutines[i].Coroutine.MoveNext();
|
Coroutines[i].Coroutine.MoveNext();
|
||||||
}
|
//}
|
||||||
|
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
DebugConsole.ThrowError("Coroutine " + Coroutines[i].Name + " threw an exception: " + e.Message);
|
// DebugConsole.ThrowError("Coroutine " + Coroutines[i].Name + " threw an exception: " + e.Message);
|
||||||
|
|
||||||
#if DEBUG
|
//#if DEBUG
|
||||||
throw e;
|
// throw e;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
Coroutines.RemoveAt(i);
|
// Coroutines.RemoveAt(i);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null, string missionType="")
|
public GameSession(Submarine submarine, string saveFile, GameModePreset gameModePreset = null, string missionType="")
|
||||||
{
|
{
|
||||||
|
Submarine.MainSub = submarine;
|
||||||
|
|
||||||
GameMain.GameSession = this;
|
GameMain.GameSession = this;
|
||||||
|
|
||||||
CrewManager = new CrewManager();
|
CrewManager = new CrewManager();
|
||||||
@@ -88,6 +90,8 @@ namespace Barotrauma
|
|||||||
public GameSession(Submarine selectedSub, string saveFile, XDocument doc)
|
public GameSession(Submarine selectedSub, string saveFile, XDocument doc)
|
||||||
: this(selectedSub, saveFile)
|
: this(selectedSub, saveFile)
|
||||||
{
|
{
|
||||||
|
Submarine.MainSub = submarine;
|
||||||
|
|
||||||
GameMain.GameSession = this;
|
GameMain.GameSession = this;
|
||||||
|
|
||||||
CrewManager = new CrewManager();
|
CrewManager = new CrewManager();
|
||||||
|
|||||||
@@ -132,81 +132,20 @@ namespace Barotrauma.Items.Components
|
|||||||
IsActive = true;
|
IsActive = true;
|
||||||
activeTimer = 0.1f;
|
activeTimer = 0.1f;
|
||||||
|
|
||||||
|
Vector2 rayStart = ConvertUnits.ToSimUnits(item.WorldPosition);
|
||||||
|
Vector2 rayEnd = ConvertUnits.ToSimUnits(targetPosition);
|
||||||
|
|
||||||
for (int n = 0; n < 2; n++)
|
if (character.Submarine == null)
|
||||||
{
|
{
|
||||||
Vector2 rayStart = ConvertUnits.ToSimUnits(item.WorldPosition);
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
Vector2 rayEnd = ConvertUnits.ToSimUnits(targetPosition);
|
|
||||||
|
|
||||||
if (n == 0)
|
|
||||||
{
|
{
|
||||||
//do a raycast in "submarine coordinates"
|
Repair(rayStart - sub.SimPosition, rayEnd - sub.SimPosition, deltaTime, character, degreeOfSuccess, ignoredBodies);
|
||||||
rayStart -= Submarine.Loaded.SimPosition;
|
|
||||||
rayEnd -= Submarine.Loaded.SimPosition;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//do a raycast outside the sub if the character is outside
|
|
||||||
if (character.AnimController.CurrentHull != null) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Body targetBody = Submarine.PickBody(rayStart, rayEnd, ignoredBodies);
|
|
||||||
|
|
||||||
pickedPosition = Submarine.LastPickedPosition;
|
|
||||||
|
|
||||||
if (ExtinquishAmount > 0.0f)
|
|
||||||
{
|
|
||||||
Vector2 displayPos = rayStart + (rayEnd - rayStart) * Submarine.LastPickedFraction * 0.9f;
|
|
||||||
Hull hull = Hull.FindHull(displayPos, item.CurrentHull);
|
|
||||||
if (hull != null) hull.Extinquish(deltaTime, ExtinquishAmount, displayPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetBody == null || targetBody.UserData == null) continue;
|
|
||||||
|
|
||||||
Structure targetStructure;
|
|
||||||
Limb targetLimb;
|
|
||||||
Item targetItem;
|
|
||||||
if ((targetStructure = (targetBody.UserData as Structure)) != null)
|
|
||||||
{
|
|
||||||
if (!fixableEntities.Contains(targetStructure.Name)) continue;
|
|
||||||
|
|
||||||
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
|
|
||||||
if (sectionIndex < 0) continue;
|
|
||||||
|
|
||||||
targetStructure.HighLightSection(sectionIndex);
|
|
||||||
|
|
||||||
targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess);
|
|
||||||
|
|
||||||
//if the next section is small enough, apply the effect to it as well
|
|
||||||
//(to make it easier to fix a small "left-over" section)
|
|
||||||
for (int i = -1; i < 2; i += 2)
|
|
||||||
{
|
|
||||||
int nextSectionLength = targetStructure.SectionLength(sectionIndex + i);
|
|
||||||
if ((sectionIndex == 1 && i == -1) ||
|
|
||||||
(sectionIndex == targetStructure.SectionCount - 2 && i == 1) ||
|
|
||||||
(nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f))
|
|
||||||
{
|
|
||||||
targetStructure.HighLightSection(sectionIndex + i);
|
|
||||||
targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
|
|
||||||
{
|
|
||||||
if (character.IsKeyDown(InputType.Aim))
|
|
||||||
{
|
|
||||||
targetLimb.character.AddDamage(CauseOfDeath.Damage, -LimbFixAmount * degreeOfSuccess, character);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((targetItem = (targetBody.UserData as Item)) != null)
|
|
||||||
{
|
|
||||||
targetItem.IsHighlighted = true;
|
|
||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnUse, targetItem.AllPropertyObjects, deltaTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Repair(rayStart, rayEnd, deltaTime, character, degreeOfSuccess, ignoredBodies);
|
||||||
|
}
|
||||||
|
|
||||||
GameMain.ParticleManager.CreateParticle(particles, item.WorldPosition + TransformedBarrelPos,
|
GameMain.ParticleManager.CreateParticle(particles, item.WorldPosition + TransformedBarrelPos,
|
||||||
-item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi), ParticleSpeed);
|
-item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi), ParticleSpeed);
|
||||||
@@ -214,6 +153,64 @@ namespace Barotrauma.Items.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Repair(Vector2 rayStart, Vector2 rayEnd, float deltaTime, Character user, float degreeOfSuccess, List<Body> ignoredBodies)
|
||||||
|
{
|
||||||
|
|
||||||
|
Body targetBody = Submarine.PickBody(rayStart, rayEnd, ignoredBodies);
|
||||||
|
|
||||||
|
pickedPosition = Submarine.LastPickedPosition;
|
||||||
|
|
||||||
|
if (ExtinquishAmount > 0.0f)
|
||||||
|
{
|
||||||
|
Vector2 displayPos = rayStart + (rayEnd - rayStart) * Submarine.LastPickedFraction * 0.9f;
|
||||||
|
Hull hull = Hull.FindHull(displayPos, item.CurrentHull);
|
||||||
|
if (hull != null) hull.Extinquish(deltaTime, ExtinquishAmount, displayPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetBody == null || targetBody.UserData == null) return;
|
||||||
|
|
||||||
|
Structure targetStructure;
|
||||||
|
Limb targetLimb;
|
||||||
|
Item targetItem;
|
||||||
|
if ((targetStructure = (targetBody.UserData as Structure)) != null)
|
||||||
|
{
|
||||||
|
if (!fixableEntities.Contains(targetStructure.Name)) return;
|
||||||
|
|
||||||
|
int sectionIndex = targetStructure.FindSectionIndex(ConvertUnits.ToDisplayUnits(pickedPosition));
|
||||||
|
if (sectionIndex < 0) return;
|
||||||
|
|
||||||
|
targetStructure.HighLightSection(sectionIndex);
|
||||||
|
|
||||||
|
targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess);
|
||||||
|
|
||||||
|
//if the next section is small enough, apply the effect to it as well
|
||||||
|
//(to make it easier to fix a small "left-over" section)
|
||||||
|
for (int i = -1; i < 2; i += 2)
|
||||||
|
{
|
||||||
|
int nextSectionLength = targetStructure.SectionLength(sectionIndex + i);
|
||||||
|
if ((sectionIndex == 1 && i == -1) ||
|
||||||
|
(sectionIndex == targetStructure.SectionCount - 2 && i == 1) ||
|
||||||
|
(nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f))
|
||||||
|
{
|
||||||
|
targetStructure.HighLightSection(sectionIndex + i);
|
||||||
|
targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
|
||||||
|
{
|
||||||
|
targetLimb.character.AddDamage(CauseOfDeath.Damage, -LimbFixAmount * degreeOfSuccess, user);
|
||||||
|
}
|
||||||
|
else if ((targetItem = (targetBody.UserData as Item)) != null)
|
||||||
|
{
|
||||||
|
targetItem.IsHighlighted = true;
|
||||||
|
|
||||||
|
ApplyStatusEffects(ActionType.OnUse, targetItem.AllPropertyObjects, deltaTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
|
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
|
||||||
{
|
{
|
||||||
Gap leak = objective.OperateTarget as Gap;
|
Gap leak = objective.OperateTarget as Gap;
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private float cellSize;
|
private float cellSize;
|
||||||
|
|
||||||
public EntityGrid(Rectangle limits, float cellSize)
|
public readonly Submarine Submarine;
|
||||||
|
|
||||||
|
public EntityGrid(Submarine submarine, float cellSize)
|
||||||
{
|
{
|
||||||
this.limits = limits;
|
this.limits = submarine.Borders;
|
||||||
|
this.Submarine = submarine;
|
||||||
this.cellSize = cellSize;
|
this.cellSize = cellSize;
|
||||||
|
|
||||||
entities = new List<MapEntity>[(int)Math.Ceiling(limits.Width / cellSize), (int)Math.Ceiling(limits.Height / cellSize)];
|
entities = new List<MapEntity>[(int)Math.Ceiling(limits.Width / cellSize), (int)Math.Ceiling(limits.Height / cellSize)];
|
||||||
@@ -71,11 +74,28 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<MapEntity> GetEntities(List<EntityGrid> entityGrids, Vector2 position, bool useWorldCoordinates = true)
|
||||||
|
{
|
||||||
|
List<MapEntity> entities = new List<MapEntity>();
|
||||||
|
foreach (EntityGrid entityGrid in entityGrids)
|
||||||
|
{
|
||||||
|
Vector2 transformedPosition = position;
|
||||||
|
if (useWorldCoordinates)
|
||||||
|
{
|
||||||
|
transformedPosition -= entityGrid.Submarine.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
entities.AddRange(entityGrid.GetEntities(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
|
||||||
public List<MapEntity> GetEntities(Vector2 position)
|
public List<MapEntity> GetEntities(Vector2 position)
|
||||||
{
|
{
|
||||||
if (!MathUtils.IsValid(position)) new List<MapEntity>();
|
if (!MathUtils.IsValid(position)) new List<MapEntity>();
|
||||||
|
|
||||||
if (Submarine.Loaded != null) position -= Submarine.HiddenSubPosition;
|
if (Submarine != null) position -= Submarine.HiddenSubPosition;
|
||||||
|
|
||||||
Point indices = GetIndices(position);
|
Point indices = GetIndices(position);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Barotrauma
|
|||||||
class Hull : MapEntity, IPropertyObject
|
class Hull : MapEntity, IPropertyObject
|
||||||
{
|
{
|
||||||
public static List<Hull> hullList = new List<Hull>();
|
public static List<Hull> hullList = new List<Hull>();
|
||||||
private static EntityGrid entityGrid;
|
private static List<EntityGrid> entityGrids = new List<EntityGrid>();
|
||||||
|
|
||||||
public static bool ShowHulls = true;
|
public static bool ShowHulls = true;
|
||||||
|
|
||||||
@@ -248,13 +248,15 @@ namespace Barotrauma
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GenerateEntityGrid()
|
public static void GenerateEntityGrid(Submarine submarine)
|
||||||
{
|
{
|
||||||
entityGrid = new EntityGrid(Submarine.Borders, 200.0f);
|
var newGrid = new EntityGrid(submarine, 200.0f);
|
||||||
|
|
||||||
|
entityGrids.Add(newGrid);
|
||||||
|
|
||||||
foreach (Hull hull in hullList)
|
foreach (Hull hull in hullList)
|
||||||
{
|
{
|
||||||
entityGrid.InsertEntity(hull);
|
if (hull.Submarine == submarine) newGrid.InsertEntity(hull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,8 +315,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
//renderer.Dispose();
|
//renderer.Dispose();
|
||||||
|
if (entityGrids != null)
|
||||||
|
{
|
||||||
|
foreach (EntityGrid entityGrid in entityGrids)
|
||||||
|
{
|
||||||
|
entityGrid.RemoveEntity(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (entityGrid != null) entityGrid.RemoveEntity(this);
|
|
||||||
|
|
||||||
hullList.Remove(this);
|
hullList.Remove(this);
|
||||||
}
|
}
|
||||||
@@ -652,15 +660,14 @@ namespace Barotrauma
|
|||||||
//returns the water block which contains the point (or null if it isn't inside any)
|
//returns the water block which contains the point (or null if it isn't inside any)
|
||||||
public static Hull FindHull(Vector2 position, Hull guess = null, bool useWorldCoordinates = true)
|
public static Hull FindHull(Vector2 position, Hull guess = null, bool useWorldCoordinates = true)
|
||||||
{
|
{
|
||||||
if (entityGrid == null) return null;
|
if (entityGrids == null) return null;
|
||||||
|
|
||||||
if (guess != null)
|
if (guess != null)
|
||||||
{
|
{
|
||||||
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess;
|
if (Submarine.RectContains(useWorldCoordinates ? guess.WorldRect : guess.rect, position)) return guess;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entities = entityGrid.GetEntities(
|
var entities = EntityGrid.GetEntities(entityGrids, position, useWorldCoordinates);
|
||||||
useWorldCoordinates && Submarine.Loaded!=null ? position-Submarine.Loaded.Position : position);
|
|
||||||
|
|
||||||
foreach (Hull hull in entities)
|
foreach (Hull hull in entities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ namespace Barotrauma
|
|||||||
float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3;
|
float avgValue = (backgroundColor.R + backgroundColor.G + backgroundColor.G) / 3;
|
||||||
GameMain.LightManager.AmbientLight = new Color(backgroundColor*(40.0f/avgValue), 1.0f);
|
GameMain.LightManager.AmbientLight = new Color(backgroundColor*(40.0f/avgValue), 1.0f);
|
||||||
|
|
||||||
float minWidth = Submarine.Loaded == null ? 0.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height);
|
float minWidth = Submarine.MainSub == null ? 0.0f : Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height);
|
||||||
minWidth = Math.Max(minWidth, 6500.0f);
|
minWidth = Math.Max(minWidth, 6500.0f);
|
||||||
|
|
||||||
startPosition = new Vector2(minWidth * 2, Rand.Range(minWidth * 2, borders.Height - minWidth * 2, false));
|
startPosition = new Vector2(minWidth * 2, Rand.Range(minWidth * 2, borders.Height - minWidth * 2, false));
|
||||||
@@ -783,9 +783,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void Update (float deltaTime)
|
public void Update (float deltaTime)
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
WrappingWall.UpdateWallShift(Submarine.Loaded.WorldPosition, wrappingWalls);
|
WrappingWall.UpdateWallShift(Submarine.MainSub.WorldPosition, wrappingWalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Update(deltaTime);
|
renderer.Update(deltaTime);
|
||||||
|
|||||||
@@ -518,7 +518,7 @@ namespace Barotrauma
|
|||||||
Vector2 placePosition = new Vector2(rect.X, rect.Y);
|
Vector2 placePosition = new Vector2(rect.X, rect.Y);
|
||||||
Vector2 placeSize = new Vector2(rect.Width, rect.Height);
|
Vector2 placeSize = new Vector2(rect.Width, rect.Height);
|
||||||
|
|
||||||
Vector2 mousePos = Submarine.MouseToWorldGrid(cam);
|
Vector2 mousePos = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
|
|
||||||
if (resizeDirX >0)
|
if (resizeDirX >0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (placePosition == Vector2.Zero)
|
if (placePosition == Vector2.Zero)
|
||||||
{
|
{
|
||||||
Vector2 position = Submarine.MouseToWorldGrid(cam);
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
|
|
||||||
GUI.DrawLine(spriteBatch, new Vector2(position.X-GameMain.GraphicsWidth, -position.Y), new Vector2(position.X+GameMain.GraphicsWidth, -position.Y), Color.White);
|
GUI.DrawLine(spriteBatch, new Vector2(position.X-GameMain.GraphicsWidth, -position.Y), new Vector2(position.X+GameMain.GraphicsWidth, -position.Y), Color.White);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector2 position = Submarine.MouseToWorldGrid(cam);
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
|
|
||||||
if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
|
if (resizeHorizontal) placeSize.X = position.X - placePosition.X;
|
||||||
if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
|
if (resizeVertical) placeSize.Y = placePosition.Y - position.Y;
|
||||||
@@ -147,9 +147,9 @@ namespace Barotrauma
|
|||||||
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
|
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
|
||||||
newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
|
newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
|
||||||
|
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
newRect.Location -= Submarine.Loaded.Position.ToPoint();
|
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayerInput.LeftButtonReleased())
|
if (PlayerInput.LeftButtonReleased())
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
|
public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null && Submarine.Loaded.GodMode && Submarine == Submarine.Loaded) return new AttackResult(0.0f, 0.0f);
|
if (Submarine != null && Submarine.GodMode) return new AttackResult(0.0f, 0.0f);
|
||||||
if (!prefab.HasBody || prefab.IsPlatform) return new AttackResult(0.0f, 0.0f);
|
if (!prefab.HasBody || prefab.IsPlatform) return new AttackResult(0.0f, 0.0f);
|
||||||
|
|
||||||
Vector2 transformedPos = worldPosition;
|
Vector2 transformedPos = worldPosition;
|
||||||
@@ -546,7 +546,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void SetDamage(int sectionIndex, float damage)
|
private void SetDamage(int sectionIndex, float damage)
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null && Submarine.Loaded.GodMode) return;
|
if (Submarine != null && Submarine.GodMode) return;
|
||||||
if (!prefab.HasBody) return;
|
if (!prefab.HasBody) return;
|
||||||
|
|
||||||
if (!MathUtils.IsValid(damage)) return;
|
if (!MathUtils.IsValid(damage)) return;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void UpdatePlacing(SpriteBatch spriteBatch, Camera cam)
|
public override void UpdatePlacing(SpriteBatch spriteBatch, Camera cam)
|
||||||
{
|
{
|
||||||
Vector2 position = Submarine.MouseToWorldGrid(cam);
|
Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
//Vector2 placeSize = size;
|
//Vector2 placeSize = size;
|
||||||
|
|
||||||
Rectangle newRect = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
|
Rectangle newRect = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
|
||||||
@@ -137,7 +137,7 @@ namespace Barotrauma
|
|||||||
if (placePosition == Vector2.Zero)
|
if (placePosition == Vector2.Zero)
|
||||||
{
|
{
|
||||||
if (PlayerInput.LeftButtonHeld())
|
if (PlayerInput.LeftButtonHeld())
|
||||||
placePosition = Submarine.MouseToWorldGrid(cam);
|
placePosition = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);
|
||||||
|
|
||||||
newRect.X = (int)position.X;
|
newRect.X = (int)position.X;
|
||||||
newRect.Y = (int)position.Y;
|
newRect.Y = (int)position.Y;
|
||||||
@@ -154,14 +154,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (PlayerInput.LeftButtonReleased())
|
if (PlayerInput.LeftButtonReleased())
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null)
|
newRect.Location -= Submarine.MainSub.Position.ToPoint();
|
||||||
{
|
|
||||||
newRect.Location -= Submarine.Loaded.Position.ToPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
var structure = new Structure(newRect, this, Submarine.Loaded);
|
var structure = new Structure(newRect, this, Submarine.MainSub);
|
||||||
|
structure.Submarine = Submarine.MainSub;
|
||||||
structure.Submarine = Submarine.Loaded;
|
|
||||||
|
|
||||||
selected = null;
|
selected = null;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Barotrauma
|
|||||||
public static readonly Vector2 GridSize = new Vector2(16.0f, 16.0f);
|
public static readonly Vector2 GridSize = new Vector2(16.0f, 16.0f);
|
||||||
|
|
||||||
public static Submarine MainSub;
|
public static Submarine MainSub;
|
||||||
private static List<Submarine> loaded;
|
private static List<Submarine> loaded = new List<Submarine>();
|
||||||
|
|
||||||
private SubmarineBody subBody;
|
private SubmarineBody subBody;
|
||||||
|
|
||||||
@@ -97,10 +97,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static List<Submarine> Loaded
|
public static List<Submarine> Loaded
|
||||||
//{
|
{
|
||||||
// get { return loaded; }
|
get { return loaded; }
|
||||||
//}
|
}
|
||||||
|
|
||||||
public Rectangle Borders
|
public Rectangle Borders
|
||||||
{
|
{
|
||||||
@@ -789,7 +789,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
loaded.Add(this);
|
loaded.Add(this);
|
||||||
|
|
||||||
Hull.GenerateEntityGrid();
|
Hull.GenerateEntityGrid(this);
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WayPoint(MapEntityPrefab prefab, Rectangle rectangle)
|
public WayPoint(MapEntityPrefab prefab, Rectangle rectangle)
|
||||||
: this (rectangle, Submarine.Loaded)
|
: this (rectangle, Submarine.MainSub)
|
||||||
{
|
{
|
||||||
if (prefab.Name.Contains("Spawn"))
|
if (prefab.Name.Contains("Spawn"))
|
||||||
{
|
{
|
||||||
@@ -306,7 +306,7 @@ namespace Barotrauma
|
|||||||
return editingHUD;
|
return editingHUD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GenerateSubWaypoints()
|
public static void GenerateSubWaypoints(Submarine submarine)
|
||||||
{
|
{
|
||||||
if (!Hull.hullList.Any())
|
if (!Hull.hullList.Any())
|
||||||
{
|
{
|
||||||
@@ -332,13 +332,13 @@ namespace Barotrauma
|
|||||||
if (hull.Rect.Width<minDist*3.0f)
|
if (hull.Rect.Width<minDist*3.0f)
|
||||||
{
|
{
|
||||||
new WayPoint(
|
new WayPoint(
|
||||||
new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (float x = hull.Rect.X + minDist; x <= hull.Rect.Right - minDist; x += minDist)
|
for (float x = hull.Rect.X + minDist; x <= hull.Rect.Right - minDist; x += minDist)
|
||||||
{
|
{
|
||||||
var wayPoint = new WayPoint(new Vector2(x, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
var wayPoint = new WayPoint(new Vector2(x, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
|
||||||
|
|
||||||
if (prevWaypoint != null) wayPoint.ConnectTo(prevWaypoint);
|
if (prevWaypoint != null) wayPoint.ConnectTo(prevWaypoint);
|
||||||
|
|
||||||
@@ -380,7 +380,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
var wayPoint = new WayPoint(
|
var wayPoint = new WayPoint(
|
||||||
new Vector2(x, borders.Y - borders.Height * i) + Submarine.HiddenSubPosition,
|
new Vector2(x, borders.Y - borders.Height * i) + Submarine.HiddenSubPosition,
|
||||||
SpawnType.Path, Submarine.Loaded);
|
SpawnType.Path, submarine);
|
||||||
|
|
||||||
if (x == borders.X + outSideWaypointInterval)
|
if (x == borders.X + outSideWaypointInterval)
|
||||||
{
|
{
|
||||||
cornerWaypoint[i, 0] = wayPoint;
|
cornerWaypoint[i, 0] = wayPoint;
|
||||||
@@ -401,7 +402,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
wayPoint = new WayPoint(
|
wayPoint = new WayPoint(
|
||||||
new Vector2(borders.X + borders.Width * i, y) + Submarine.HiddenSubPosition,
|
new Vector2(borders.X + borders.Width * i, y) + Submarine.HiddenSubPosition,
|
||||||
SpawnType.Path, Submarine.Loaded);
|
SpawnType.Path, submarine);
|
||||||
|
|
||||||
if (y == borders.Y - borders.Height)
|
if (y == borders.Y - borders.Height)
|
||||||
{
|
{
|
||||||
@@ -431,11 +432,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
stairPoints[0] = new WayPoint(
|
stairPoints[0] = new WayPoint(
|
||||||
new Vector2(stairs.Rect.X - 75.0f,
|
new Vector2(stairs.Rect.X - 75.0f,
|
||||||
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? 80 : stairs.Rect.Height) + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? 80 : stairs.Rect.Height) + heightFromFloor), SpawnType.Path, submarine);
|
||||||
|
|
||||||
stairPoints[1] = new WayPoint(
|
stairPoints[1] = new WayPoint(
|
||||||
new Vector2(stairs.Rect.Right + 75.0f,
|
new Vector2(stairs.Rect.Right + 75.0f,
|
||||||
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? stairs.Rect.Height : 80) + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
stairs.Rect.Y - (stairs.StairDirection == Direction.Left ? stairs.Rect.Height : 80) + heightFromFloor), SpawnType.Path, submarine);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++ )
|
for (int i = 0; i < 2; i++ )
|
||||||
{
|
{
|
||||||
@@ -457,9 +458,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
WayPoint[] ladderPoints = new WayPoint[2];
|
WayPoint[] ladderPoints = new WayPoint[2];
|
||||||
|
|
||||||
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
|
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, submarine);
|
||||||
|
|
||||||
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, Submarine.Loaded);
|
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, submarine);
|
||||||
|
|
||||||
|
|
||||||
WayPoint prevPoint = ladderPoints[0];
|
WayPoint prevPoint = ladderPoints[0];
|
||||||
@@ -480,7 +481,7 @@ namespace Barotrauma
|
|||||||
var door = ((Item)pickedBody.UserData).GetComponent<Door>();
|
var door = ((Item)pickedBody.UserData).GetComponent<Door>();
|
||||||
if (door != null)
|
if (door != null)
|
||||||
{
|
{
|
||||||
WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, Submarine.Loaded);
|
WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, submarine);
|
||||||
newPoint.Ladders = ladders;
|
newPoint.Ladders = ladders;
|
||||||
newPoint.ConnectedGap = door.LinkedGap;
|
newPoint.ConnectedGap = door.LinkedGap;
|
||||||
|
|
||||||
@@ -538,7 +539,7 @@ namespace Barotrauma
|
|||||||
if (gap.Rect.Height < 150.0f) continue;
|
if (gap.Rect.Height < 150.0f) continue;
|
||||||
|
|
||||||
var wayPoint = new WayPoint(
|
var wayPoint = new WayPoint(
|
||||||
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded, gap);
|
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height + heightFromFloor), SpawnType.Path, submarine, gap);
|
||||||
|
|
||||||
for (int dir = -1; dir <= 1; dir += 2)
|
for (int dir = -1; dir <= 1; dir += 2)
|
||||||
{
|
{
|
||||||
@@ -557,7 +558,7 @@ namespace Barotrauma
|
|||||||
if (gap.Rect.Width < 100.0f) continue;
|
if (gap.Rect.Width < 100.0f) continue;
|
||||||
|
|
||||||
var wayPoint = new WayPoint(
|
var wayPoint = new WayPoint(
|
||||||
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height/2), SpawnType.Path, Submarine.Loaded, gap);
|
new Vector2(gap.Rect.Center.X, gap.Rect.Y - gap.Rect.Height/2), SpawnType.Path, submarine, gap);
|
||||||
|
|
||||||
for (int dir = -1; dir <= 1; dir += 2)
|
for (int dir = -1; dir <= 1; dir += 2)
|
||||||
{
|
{
|
||||||
@@ -583,35 +584,35 @@ namespace Barotrauma
|
|||||||
WayPoint closest = null;
|
WayPoint closest = null;
|
||||||
|
|
||||||
|
|
||||||
foreach (WayPoint wp in WayPointList)
|
foreach (WayPoint wp in WayPointList)
|
||||||
|
{
|
||||||
|
if (wp.SpawnType != SpawnType.Path || wp == this) continue;
|
||||||
|
|
||||||
|
float diff = 0.0f;
|
||||||
|
if (horizontalSearch)
|
||||||
{
|
{
|
||||||
if (wp.SpawnType != SpawnType.Path || wp == this) continue;
|
if ((wp.Position.Y - Position.Y) < tolerance.X || (wp.Position.Y - Position.Y) > tolerance.Y) continue;
|
||||||
|
|
||||||
float diff = 0.0f;
|
diff = wp.Position.X - Position.X;
|
||||||
if (horizontalSearch)
|
|
||||||
{
|
|
||||||
if ((wp.Position.Y - Position.Y) < tolerance.X || (wp.Position.Y - Position.Y) > tolerance.Y) continue;
|
|
||||||
|
|
||||||
diff = wp.Position.X - Position.X;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((wp.Position.X - Position.X) < tolerance.X || (wp.Position.X - Position.X) > tolerance.Y) continue;
|
|
||||||
|
|
||||||
diff = wp.Position.Y - Position.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Math.Sign(diff) != dir) continue;
|
|
||||||
|
|
||||||
float dist = Vector2.Distance(wp.Position, Position);
|
|
||||||
if (closest == null || dist < closestDist)
|
|
||||||
{
|
|
||||||
if (Submarine.CheckVisibility(SimPosition, wp.SimPosition) != null) continue;
|
|
||||||
|
|
||||||
closestDist = dist;
|
|
||||||
closest = wp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((wp.Position.X - Position.X) < tolerance.X || (wp.Position.X - Position.X) > tolerance.Y) continue;
|
||||||
|
|
||||||
|
diff = wp.Position.Y - Position.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.Sign(diff) != dir) continue;
|
||||||
|
|
||||||
|
float dist = Vector2.Distance(wp.Position, Position);
|
||||||
|
if (closest == null || dist < closestDist)
|
||||||
|
{
|
||||||
|
if (Submarine.CheckVisibility(SimPosition, wp.SimPosition) != null) continue;
|
||||||
|
|
||||||
|
closestDist = dist;
|
||||||
|
closest = wp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return closest;
|
return closest;
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (Screen.Selected == GameMain.GameScreen)
|
if (Screen.Selected == GameMain.GameScreen)
|
||||||
{
|
{
|
||||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, endPreviewLength);
|
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||||
|
|
||||||
float secondsLeft = endPreviewLength;
|
float secondsLeft = endPreviewLength;
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ namespace Barotrauma.Networking
|
|||||||
//restart if all characters are dead or submarine is at the end of the level
|
//restart if all characters are dead or submarine is at the end of the level
|
||||||
if ((autoRestart && isCrewDead)
|
if ((autoRestart && isCrewDead)
|
||||||
||
|
||
|
||||||
(endRoundAtLevelEnd && Submarine.Loaded!=null && Submarine.Loaded.AtEndPosition))
|
(endRoundAtLevelEnd && Submarine.MainSub != null && Submarine.MainSub.AtEndPosition))
|
||||||
{
|
{
|
||||||
if (AutoRestart && isCrewDead)
|
if (AutoRestart && isCrewDead)
|
||||||
{
|
{
|
||||||
@@ -363,7 +363,8 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (!(c is AICharacter) || c.IsDead) continue;
|
if (!(c is AICharacter) || c.IsDead) continue;
|
||||||
|
|
||||||
Vector2 diff = c.WorldPosition-Submarine.Loaded.WorldPosition;
|
//todo: take multiple subs into account
|
||||||
|
Vector2 diff = c.WorldPosition - Submarine.MainSub.WorldPosition;
|
||||||
|
|
||||||
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||||
|
|
||||||
@@ -389,7 +390,13 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private void SparseUpdate()
|
private void SparseUpdate()
|
||||||
{
|
{
|
||||||
if (gameStarted) new NetworkEvent(Submarine.Loaded.ID, false);
|
if (gameStarted)
|
||||||
|
{
|
||||||
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
|
{
|
||||||
|
new NetworkEvent(sub.ID, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
@@ -397,7 +404,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (c is AICharacter)
|
if (c is AICharacter)
|
||||||
{
|
{
|
||||||
Vector2 diff = c.WorldPosition - Submarine.Loaded.WorldPosition;
|
//todo: take multiple subs into account
|
||||||
|
Vector2 diff = c.WorldPosition - Submarine.MainSub.WorldPosition;
|
||||||
|
|
||||||
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
if (FarseerPhysics.ConvertUnits.ToSimUnits(diff.Length()) > NetConfig.CharacterIgnoreDistance) continue;
|
||||||
}
|
}
|
||||||
@@ -601,7 +609,7 @@ namespace Barotrauma.Networking
|
|||||||
case (byte)PacketTypes.SpectateRequest:
|
case (byte)PacketTypes.SpectateRequest:
|
||||||
if (gameStarted && allowSpectating)
|
if (gameStarted && allowSpectating)
|
||||||
{
|
{
|
||||||
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
|
var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
||||||
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
|
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
|
||||||
|
|
||||||
dataSender.Spectating = true;
|
dataSender.Spectating = true;
|
||||||
@@ -985,7 +993,7 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
|
GameMain.GameSession.CrewManager.characters.Add(myCharacter);
|
||||||
}
|
}
|
||||||
|
|
||||||
var startMessage = CreateStartMessage(roundStartSeed, Submarine.Loaded, GameMain.GameSession.gameMode.Preset);
|
var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
||||||
SendMessage(startMessage, NetDeliveryMethod.ReliableUnordered);
|
SendMessage(startMessage, NetDeliveryMethod.ReliableUnordered);
|
||||||
|
|
||||||
|
|
||||||
@@ -1113,7 +1121,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
float endPreviewLength = 10.0f;
|
float endPreviewLength = 10.0f;
|
||||||
|
|
||||||
var cinematic = new TransitionCinematic(Submarine.Loaded, GameMain.GameScreen.Cam, endPreviewLength);
|
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||||
|
|
||||||
float secondsLeft = endPreviewLength;
|
float secondsLeft = endPreviewLength;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
|||||||
sb.AppendLine("Game version " + GameMain.Version);
|
sb.AppendLine("Game version " + GameMain.Version);
|
||||||
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
|
sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
|
||||||
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
|
sb.AppendLine("Level seed: "+ ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
|
||||||
sb.AppendLine("Loaded submarine: " + ((Submarine.Loaded == null) ? "none" : Submarine.Loaded.Name +" ("+Submarine.Loaded.MD5Hash+")"));
|
sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "none" : Submarine.MainSub.Name +" ("+Submarine.MainSub.MD5Hash+")"));
|
||||||
sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
|
sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public string GetSubName()
|
public string GetSubName()
|
||||||
{
|
{
|
||||||
return ((Submarine.Loaded == null) ? "" : Submarine.Loaded.Name);
|
return (Submarine.MainSub == null) ? "" : Submarine.MainSub.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetItemCount()
|
private string GetItemCount()
|
||||||
@@ -231,11 +231,11 @@ namespace Barotrauma
|
|||||||
GUIComponent.MouseOn = null;
|
GUIComponent.MouseOn = null;
|
||||||
characterMode = false;
|
characterMode = false;
|
||||||
|
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
cam.Position = Submarine.Loaded.Position + Submarine.HiddenSubPosition;
|
cam.Position = Submarine.MainSub.Position + Submarine.HiddenSubPosition;
|
||||||
nameBox.Text = Submarine.Loaded.Name;
|
nameBox.Text = Submarine.MainSub.Name;
|
||||||
descriptionBox.Text = ToolBox.LimitString(Submarine.Loaded.Description,15);
|
descriptionBox.Text = ToolBox.LimitString(Submarine.MainSub.Description, 15);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -303,9 +303,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
string savePath = nameBox.Text + ".sub";
|
string savePath = nameBox.Text + ".sub";
|
||||||
|
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
savePath = Path.Combine(Path.GetDirectoryName(Submarine.Loaded.FilePath), savePath);
|
savePath = Path.Combine(Path.GetDirectoryName(Submarine.MainSub.FilePath), savePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -313,9 +313,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
Submarine.SaveCurrent(savePath);
|
Submarine.SaveCurrent(savePath);
|
||||||
Submarine.Loaded.CheckForErrors();
|
Submarine.MainSub.CheckForErrors();
|
||||||
|
|
||||||
GUI.AddMessage("Submarine saved to " + Submarine.Loaded.FilePath, Color.Green, 3.0f);
|
GUI.AddMessage("Submarine saved to " + Submarine.MainSub.FilePath, Color.Green, 3.0f);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -560,7 +560,7 @@ namespace Barotrauma
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Submarine.Loaded != null) Submarine.Loaded.Name = text;
|
if (Submarine.MainSub != null) Submarine.MainSub.Name = text;
|
||||||
textBox.Deselect();
|
textBox.Deselect();
|
||||||
|
|
||||||
textBox.Text = text;
|
textBox.Text = text;
|
||||||
@@ -572,9 +572,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool ChangeSubDescription(GUITextBox textBox, string text)
|
private bool ChangeSubDescription(GUITextBox textBox, string text)
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
Submarine.Loaded.Description = text;
|
Submarine.MainSub.Description = text;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -593,9 +593,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void ExpandDescriptionBox(GUITextBox textBox, Keys key)
|
private void ExpandDescriptionBox(GUITextBox textBox, Keys key)
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
textBox.Text = Submarine.Loaded.Description;
|
textBox.Text = Submarine.MainSub.Description;
|
||||||
}
|
}
|
||||||
else if (textBox.UserData is string)
|
else if (textBox.UserData is string)
|
||||||
{
|
{
|
||||||
@@ -617,7 +617,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool GenerateWaypoints(GUIButton button, object obj)
|
private bool GenerateWaypoints(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
WayPoint.GenerateSubWaypoints();
|
if (Submarine.MainSub == null) return false;
|
||||||
|
|
||||||
|
WayPoint.GenerateSubWaypoints(Submarine.MainSub);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
cam.Position = Character.Controlled.WorldPosition;
|
cam.Position = Character.Controlled.WorldPosition;
|
||||||
}
|
}
|
||||||
else if (Submarine.Loaded != null)
|
else if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
cam.Position = Submarine.Loaded.WorldPosition;
|
cam.Position = Submarine.MainSub.WorldPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MapEntity entity in MapEntity.mapEntityList)
|
foreach (MapEntity entity in MapEntity.mapEntityList)
|
||||||
@@ -120,8 +120,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
cam.MoveCamera((float)Physics.step);
|
cam.MoveCamera((float)Physics.step);
|
||||||
|
|
||||||
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
if (Submarine.Loaded != null) Submarine.Loaded.SetPrevTransform(Submarine.Loaded.Position);
|
{
|
||||||
|
sub.SetPrevTransform(sub.Position);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (PhysicsBody pb in PhysicsBody.list)
|
foreach (PhysicsBody pb in PhysicsBody.list)
|
||||||
{
|
{
|
||||||
@@ -175,7 +177,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (GameMain.GameSession != null) GameMain.GameSession.Draw(spriteBatch);
|
if (GameMain.GameSession != null) GameMain.GameSession.Draw(spriteBatch);
|
||||||
|
|
||||||
if (Character.Controlled == null && Submarine.Loaded != null) DrawSubmarineIndicator(spriteBatch, Submarine.Loaded);
|
if (Character.Controlled == null && Submarine.Loaded != null) DrawSubmarineIndicator(spriteBatch, Submarine.MainSub);
|
||||||
|
|
||||||
GUI.Draw((float)deltaTime, spriteBatch, cam);
|
GUI.Draw((float)deltaTime, spriteBatch, cam);
|
||||||
|
|
||||||
@@ -187,7 +189,10 @@ namespace Barotrauma
|
|||||||
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
|
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Submarine.Loaded != null) Submarine.Loaded.UpdateTransform();
|
foreach (Submarine sub in Submarine.Loaded)
|
||||||
|
{
|
||||||
|
sub.UpdateTransform();
|
||||||
|
}
|
||||||
|
|
||||||
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
|
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ namespace Barotrauma
|
|||||||
startDrone = null;
|
startDrone = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Submarine.Loaded==null)
|
//todo: ambient sounds for multiple subs
|
||||||
|
if (Submarine.MainSub == null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < waterAmbienceIndexes.Length; i++)
|
for (int i = 0; i < waterAmbienceIndexes.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -213,9 +214,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//how fast the sub is moving, scaled to 0.0 -> 1.0
|
//how fast the sub is moving, scaled to 0.0 -> 1.0
|
||||||
float movementFactor = 0.0f;
|
float movementFactor = 0.0f;
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
movementFactor = (Submarine.Loaded.Velocity == Vector2.Zero) ? 0.0f : Submarine.Loaded.Velocity.Length() / 5.0f;
|
movementFactor = (Submarine.MainSub.Velocity == Vector2.Zero) ? 0.0f : Submarine.MainSub.Velocity.Length() / 5.0f;
|
||||||
|
|
||||||
movementFactor = MathHelper.Clamp(movementFactor, 0.0f, 1.0f);
|
movementFactor = MathHelper.Clamp(movementFactor, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
@@ -303,7 +304,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
return musicClips.Where(x => x != null && x.type == "ruins").ToList();
|
return musicClips.Where(x => x != null && x.type == "ruins").ToList();
|
||||||
}
|
}
|
||||||
else if (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth)
|
else if (Submarine.MainSub != null && Submarine.MainSub.AtDamageDepth)
|
||||||
{
|
{
|
||||||
return musicClips.Where(x => x != null && x.type == "deep").ToList();
|
return musicClips.Where(x => x != null && x.type == "deep").ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
Submarine.Loaded.SaveAs(Path.Combine(tempPath, Submarine.Loaded.Name+".sub"));
|
Submarine.MainSub.SaveAs(Path.Combine(tempPath, Submarine.MainSub.Name+".sub"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher2\Launcher.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher2\Launcher.csproj", "{251AAFE1-F24B-4837-9128-9D04FCBFD528}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrashReporter", "CrashReporter\CrashReporter.csproj", "{6BE950CD-9A34-49C9-939A-786AC89C287E}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyper.ComponentModel", "Hyper.ComponentModel\Hyper.ComponentModel.csproj", "{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyper.ComponentModel", "Hyper.ComponentModel\Hyper.ComponentModel.csproj", "{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}"
|
||||||
@@ -228,51 +226,6 @@ Global
|
|||||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
||||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.ActiveCfg = Release|x86
|
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.ActiveCfg = Release|x86
|
||||||
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.Build.0 = Release|x86
|
{251AAFE1-F24B-4837-9128-9D04FCBFD528}.Windows8|x86.Build.0 = Release|x86
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Android|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|x86.ActiveCfg = Debug|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Debug|x86.Build.0 = Debug|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.iOS|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Linux|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.OSX|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.PSM|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Release|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows|x86.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Any CPU.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Mixed Platforms.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|Mixed Platforms.Build.0 = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.ActiveCfg = Release|x86
|
|
||||||
{6BE950CD-9A34-49C9-939A-786AC89C287E}.Windows8|x86.Build.0 = Release|x86
|
|
||||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.Build.0 = Release|Any CPU
|
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{3B8F9EDB-6E5E-450C-ABC2-EC49075D0B50}.Android|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user