Endworm attacks working, itemlabel text saving bugfix, deconstructors & fabricators need power, engine sprite, disable wire node dragging in character mode, only hit with one meleeweapon at a time, fixrequirement text overflow fix, mapentities can hace multiple categories, Gap.FindHull fix, Waypoint ladder & gap saving, stuff

This commit is contained in:
Regalis
2016-01-18 20:09:38 +02:00
parent 5f1cb194ab
commit 1a5b3fa66a
39 changed files with 206 additions and 152 deletions

View File

@@ -120,50 +120,39 @@ namespace Barotrauma
linkedTo.Clear();
foreach (Hull h in Hull.hullList)
Vector2[] searchPos = new Vector2[2];
if (isHorizontal)
{
if (!Submarine.RectsOverlap(h.Rect, rect, false)) continue;
//if the gap is inside the hull completely, ignore it
if (rect.X > h.Rect.X && rect.X + rect.Width < h.Rect.X+h.Rect.Width &&
rect.Y < h.Rect.Y && rect.Y - rect.Height > h.Rect.Y - h.Rect.Height) continue;
for (int i = 0; i < 2; i++ )
{
if (hulls[i] != null) continue;
hulls[i] = h;
break;
}
if (hulls[1] != null) break;
searchPos[0] = new Vector2(rect.X, rect.Y - rect.Height / 2);
searchPos[1] = new Vector2(rect.Right, rect.Y - rect.Height / 2);
}
else
{
searchPos[0] = new Vector2(rect.Center.X, rect.Y);
searchPos[1] = new Vector2(rect.Center.X, rect.Y - rect.Height);
}
hulls[0] = Hull.FindHullOld(searchPos[0], null, false);
hulls[1] = Hull.FindHullOld(searchPos[1], null, false);
if (hulls[0] == null && hulls[1] == null) return;
if (hulls[0] != null && hulls[1] != null)
if (hulls[0]==null && hulls[1]!=null)
{
if ((isHorizontal && hulls[0].Rect.X > hulls[1].Rect.X) || (!isHorizontal && hulls[0].Rect.Y < hulls[1].Rect.Y))
{
//make sure that hull1 is the lefthand room if the gap is horizontal,
//or that hull1 is the upper hull if the gap is vertical
Hull temp = hulls[0];
hulls[0] = hulls[1];
hulls[1] = temp;
}
Hull temp = hulls[0];
hulls[0] = hulls[1];
hulls[1] = temp;
}
linkedTo.Add(hulls[0]);
if (hulls[1] != null) linkedTo.Add(hulls[1]);
}
public override void Draw(SpriteBatch sb, bool editing, bool back = true)
{
if (GameMain.DebugDraw)
{
Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Width / 2.0f));
Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Height/ 2.0f));
GUI.DrawLine(sb, center, center + flowForce/10.0f, Color.Red);
GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + lerpedFlowForce / 10.0f + Vector2.One * 5.0f, Color.Orange);
@@ -241,7 +230,7 @@ namespace Barotrauma
UpdateRoomToRoom(deltaTime);
}
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, deltaTime*2.0f);
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, deltaTime);
if (LerpedFlowForce.Length() > 100.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume)
{
@@ -276,19 +265,21 @@ namespace Barotrauma
}
else
{
if (Math.Sign(flowTargetHull.Rect.Y - rect.Y) != Math.Sign(lerpedFlowForce.Y)) return;
pos.Y += Math.Sign(flowForce.Y) * rect.Height / 2.0f;
for (int i = 0; i < rect.Width; i += (int)Rand.Range(80, 100))
{
pos.X = Rand.Range(rect.X, rect.X + rect.Width);
Vector2 velocity = new Vector2(
flowForce.X * Rand.Range(0.5f, 0.7f),
Math.Max(flowForce.Y,-100.0f) * Rand.Range(0.5f, 0.7f));
lerpedFlowForce.X * Rand.Range(0.5f, 0.7f),
Math.Max(lerpedFlowForce.Y, -100.0f) * Rand.Range(0.5f, 0.7f));
var splash = GameMain.ParticleManager.CreateParticle(
"watersplash",
Submarine.Loaded == null ? pos : pos + Submarine.Loaded.Position,
velocity);
-velocity);
if (splash != null) splash.Size = splash.Size * MathHelper.Clamp(rect.Width / 50.0f, 0.8f, 4.0f);
@@ -411,20 +402,10 @@ namespace Barotrauma
flowTargetHull = hull1;
//delta = (water2.Pressure - water1.Pressure) * 0.1f;
//if (delta > 0.1f)
//{
// int posX = (int)((rect.X + size / 2.0f - water1.Rect.X) / Hull.WaveWidth);
// //water1.WaveY[posX] = delta;
// water1.WaveVel[posX] = delta * 0.01f;
//}
if (hull1.Volume > hull1.FullVolume)
{
hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure) / 2);
}
}
}
//there's water in the upper room, drop to lower

View File

@@ -7,9 +7,10 @@ using Microsoft.Xna.Framework.Input;
namespace Barotrauma
{
[Flags]
enum MapEntityCategory
{
Structure, Machine, Equipment, Electrical, Material, Misc
Structure = 1, Machine = 2, Equipment = 4, Electrical = 8, Material = 16, Misc = 32
}
class MapEntityPrefab
@@ -116,6 +117,10 @@ namespace Barotrauma
}
public MapEntityPrefab()
{
Category = MapEntityCategory.Structure;
}
public virtual void UpdatePlacing(SpriteBatch spriteBatch, Camera cam)
{

View File

@@ -33,8 +33,10 @@ namespace Barotrauma
private Hull currentHull;
private ushort ladderId;
public Ladder Ladders;
private ushort gapId;
public Gap ConnectedGap
{
get;
@@ -198,8 +200,8 @@ namespace Barotrauma
spawnType += (int)button.UserData;
if (spawnType > SpawnType.Path) spawnType = SpawnType.Human;
if (spawnType < SpawnType.Human) spawnType = SpawnType.Path;
if (spawnType > SpawnType.Cargo) spawnType = SpawnType.Path;
if (spawnType < SpawnType.Path) spawnType = SpawnType.Cargo;
spawnTypeText.Text = spawnType.ToString();
@@ -430,6 +432,7 @@ namespace Barotrauma
if (door != null)
{
WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, Submarine.Loaded);
newPoint.Ladders = ladders;
newPoint.ConnectedGap = door.LinkedGap;
newPoint.ConnectTo(prevPoint);
@@ -656,6 +659,15 @@ namespace Barotrauma
public override void OnMapLoaded()
{
currentHull = Hull.FindHull(WorldPosition, currentHull);
if (gapId > 0) ConnectedGap = FindEntityByID(gapId) as Gap;
if (ladderId > 0)
{
var ladderItem = FindEntityByID(ladderId) as Item;
if (ladderItem != null) Ladders = ladderItem.GetComponent<Ladder>();
}
}
public override XElement Save(XDocument doc)
@@ -673,10 +685,11 @@ namespace Barotrauma
element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags)));
}
if (assignedJob != null)
{
element.Add(new XAttribute("job", assignedJob.Name));
}
if (assignedJob != null) element.Add(new XAttribute("job", assignedJob.Name));
if (ConnectedGap != null) element.Add(new XAttribute("gap", ConnectedGap.ID));
if (Ladders != null) element.Add(new XAttribute("ladders", Ladders.Item.ID));
doc.Root.Add(element);
@@ -718,6 +731,9 @@ namespace Barotrauma
w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName);
}
w.ladderId = (ushort)ToolBox.GetAttributeInt(element, "ladders", 0);
w.gapId = (ushort)ToolBox.GetAttributeInt(element, "gap", 0);
w.linkedToID = new List<ushort>();
int i = 0;
while (element.Attribute("linkedto" + i) != null)