electricity bugfixes, destructable doors, ai improvements, removed rope, container changes
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Subsurface
|
||||
protected AITarget aiTarget;
|
||||
//protected float soundRange;
|
||||
//protected float sightRange;
|
||||
|
||||
|
||||
public int ID
|
||||
{
|
||||
get { return id; }
|
||||
|
||||
@@ -49,10 +49,9 @@ namespace Subsurface
|
||||
{
|
||||
for (int i = 0; i<range*10; i++)
|
||||
{
|
||||
Game1.particleManager.CreateParticle(position,
|
||||
ToolBox.RandomFloat(0.0f,3.14f),
|
||||
Vector2.Normalize(new Vector2(ToolBox.RandomFloat(-1.0f, 1.0f), ToolBox.RandomFloat(-1.0f, 1.0f))) * ToolBox.RandomFloat(3.0f,4.0f),
|
||||
"explosionfire");
|
||||
Game1.particleManager.CreateParticle("explosionfire", position,
|
||||
Vector2.Normalize(new Vector2(ToolBox.RandomFloat(-1.0f, 1.0f), ToolBox.RandomFloat(-1.0f, 1.0f))) * ToolBox.RandomFloat(3.0f, 4.0f),
|
||||
0.0f);
|
||||
}
|
||||
|
||||
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(position);
|
||||
|
||||
+69
-50
@@ -96,68 +96,84 @@ namespace Subsurface
|
||||
|
||||
private void FindHulls()
|
||||
{
|
||||
Hull hull1 = null, hull2 = null;
|
||||
Hull[] hulls = new Hull[2];
|
||||
|
||||
linkedTo.Clear();
|
||||
|
||||
foreach (Hull h in Hull.hullList)
|
||||
{
|
||||
if (!Map.RectsOverlap(h.Rect, rect)) continue;
|
||||
if (!Map.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;
|
||||
|
||||
if (hull1 == null)
|
||||
|
||||
for (int i = 0; i < 2; i++ )
|
||||
{
|
||||
hull1 = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
hull2 = h;
|
||||
if (hulls[i] != null) continue;
|
||||
hulls[i] = h;
|
||||
break;
|
||||
}
|
||||
|
||||
if (hulls[1] != null) break;
|
||||
}
|
||||
|
||||
if (hull1 == null && hull2 == null) return;
|
||||
if (hulls[0] == null && hulls[1] == null) return;
|
||||
|
||||
if (hull1 != null && hull2 != null)
|
||||
if (hulls[0]!=null && hulls[1]!=null)
|
||||
{
|
||||
if (isHorizontal)
|
||||
if ((isHorizontal && hulls[0].Rect.X > hulls[1].Rect.X) || (!isHorizontal && hulls[0].Rect.Y < hulls[1].Rect.Y))
|
||||
{
|
||||
//make sure that water1 is the lefthand room
|
||||
//or that water2 is null if the gap doesn't lead to another room
|
||||
if (hull1.Rect.X < hull2.Rect.X)
|
||||
{
|
||||
linkedTo.Add(hull1);
|
||||
linkedTo.Add(hull2);
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedTo.Add(hull2);
|
||||
linkedTo.Add(hull1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//make sure that water1 is the room on the top
|
||||
//or that water2 is null if the gap doesn't lead to another room
|
||||
if (hull1.Rect.Y > hull2.Rect.Y)
|
||||
{
|
||||
linkedTo.Add(hull1);
|
||||
linkedTo.Add(hull2);
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedTo.Add(hull2);
|
||||
linkedTo.Add(hull1);
|
||||
}
|
||||
//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;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
linkedTo.Add(hull1);
|
||||
}
|
||||
|
||||
linkedTo.Add(hulls[0]);
|
||||
if (hulls[1] != null) linkedTo.Add(hulls[1]);
|
||||
|
||||
//if (hull1 != null && hull2 != null)
|
||||
//{
|
||||
// if (isHorizontal)
|
||||
// {
|
||||
// //make sure that water1 is the lefthand room
|
||||
// //or that water2 is null if the gap doesn't lead to another room
|
||||
// if (hull1.Rect.X < hull2.Rect.X)
|
||||
// {
|
||||
// linkedTo.Add(hull1);
|
||||
// linkedTo.Add(hull2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// linkedTo.Add(hull2);
|
||||
// linkedTo.Add(hull1);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //make sure that water1 is the room on the top
|
||||
// //or that water2 is null if the gap doesn't lead to another room
|
||||
// if (hull1.Rect.Y > hull2.Rect.Y)
|
||||
// {
|
||||
// linkedTo.Add(hull1);
|
||||
// linkedTo.Add(hull2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// linkedTo.Add(hull2);
|
||||
// linkedTo.Add(hull1);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// linkedTo.Add(hull1);
|
||||
//}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch sb, bool editing)
|
||||
@@ -244,22 +260,25 @@ namespace Subsurface
|
||||
{
|
||||
pos.Y = ConvertUnits.ToSimUnits(MathHelper.Clamp(lowerSurface, rect.Y-rect.Height, rect.Y));
|
||||
|
||||
Game1.particleManager.CreateParticle(new Vector2(pos.X, pos.Y - ToolBox.RandomFloat(0.0f, 0.1f)),
|
||||
0.0f, new Vector2(flowForce.X * ToolBox.RandomFloat(0.005f, 0.007f), flowForce.Y * ToolBox.RandomFloat(0.005f, 0.007f)), "watersplash");
|
||||
Game1.particleManager.CreateParticle("watersplash",
|
||||
new Vector2(pos.X, pos.Y - ToolBox.RandomFloat(0.0f, 0.1f)),
|
||||
new Vector2(flowForce.X * ToolBox.RandomFloat(0.005f, 0.007f), flowForce.Y * ToolBox.RandomFloat(0.005f, 0.007f)));
|
||||
|
||||
pos.Y = ConvertUnits.ToSimUnits(ToolBox.RandomFloat(lowerSurface, rect.Y - rect.Height));
|
||||
Game1.particleManager.CreateParticle(pos, 0.0f, flowForce / 200.0f, "bubbles");
|
||||
Game1.particleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.Y += Math.Sign(flowForce.Y) * ConvertUnits.ToSimUnits(rect.Height / 2.0f);
|
||||
for (int i = 0; i < rect.Width; i += (int)ToolBox.RandomFloat(20, 50))
|
||||
for (int i = 0; i < rect.Width; i += (int)ToolBox.RandomFloat(80, 100))
|
||||
{
|
||||
pos.X = ConvertUnits.ToSimUnits(ToolBox.RandomFloat(rect.X, rect.X+rect.Width));
|
||||
Game1.particleManager.CreateParticle(pos,
|
||||
0.0f, new Vector2(flowForce.X * ToolBox.RandomFloat(0.005f, 0.008f), flowForce.Y * ToolBox.RandomFloat(0.005f, 0.008f)), "watersplash");
|
||||
Subsurface.Particles.Particle splash = Game1.particleManager.CreateParticle("watersplash", pos,
|
||||
new Vector2(flowForce.X * ToolBox.RandomFloat(0.005f, 0.008f), flowForce.Y * ToolBox.RandomFloat(0.005f, 0.008f)));
|
||||
|
||||
Game1.particleManager.CreateParticle(pos, ToolBox.VectorToAngle(flowForce), flowForce / 200.0f, "bubbles");
|
||||
if (splash!=null) splash.Size = splash.Size * MathHelper.Clamp(rect.Width / 50.0f, 0.8f, 4.0f);
|
||||
|
||||
Game1.particleManager.CreateParticle("bubbles", pos, flowForce / 200.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,8 +212,9 @@ namespace Subsurface
|
||||
float maxDelta = Math.Max(Math.Abs(rightDelta[i]), Math.Abs(leftDelta[i]));
|
||||
if (maxDelta > ToolBox.RandomFloat(0.2f,10.0f))
|
||||
{
|
||||
Game1.particleManager.CreateParticle(ConvertUnits.ToSimUnits(new Vector2(rect.X + WaveWidth * i,surface + waveY[i])),
|
||||
ToolBox.RandomFloat(0.0f,6.2f), new Vector2(0.0f, -0.5f), "mist");
|
||||
Game1.particleManager.CreateParticle("mist",
|
||||
ConvertUnits.ToSimUnits(new Vector2(rect.X + WaveWidth * i,surface + waveY[i])),
|
||||
new Vector2(0.0f, -0.5f));
|
||||
}
|
||||
|
||||
waveY[i] = waveY[i] + waveVel[i];
|
||||
|
||||
@@ -4,17 +4,16 @@ namespace Subsurface
|
||||
{
|
||||
interface IDamageable
|
||||
{
|
||||
//float Damage
|
||||
//{
|
||||
// get;
|
||||
// set;
|
||||
//}
|
||||
|
||||
Vector2 SimPosition
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
float Health
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
void AddDamage(Vector2 position, float amount, float bleedingAmount, float stun);
|
||||
}
|
||||
}
|
||||
|
||||
+26
-8
@@ -116,10 +116,19 @@ namespace Subsurface
|
||||
&& pos.Y < rect.Y && pos.Y > rect.Y - rect.Height);
|
||||
}
|
||||
|
||||
public static bool RectsOverlap(Rectangle rect1, Rectangle rect2)
|
||||
public static bool RectsOverlap(Rectangle rect1, Rectangle rect2, bool inclusive=true)
|
||||
{
|
||||
return !(rect1.X > rect2.X + rect2.Width || rect1.X + rect1.Width < rect2.X ||
|
||||
rect1.Y < rect2.Y - rect2.Height || rect1.Y - rect1.Height > rect2.Y);
|
||||
if (inclusive)
|
||||
{
|
||||
return !(rect1.X > rect2.X + rect2.Width || rect1.X + rect1.Width < rect2.X ||
|
||||
rect1.Y < rect2.Y - rect2.Height || rect1.Y - rect1.Height > rect2.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return !(rect1.X >= rect2.X + rect2.Width || rect1.X + rect1.Width <= rect2.X ||
|
||||
rect1.Y <= rect2.Y - rect2.Height || rect1.Y - rect1.Height >= rect2.Y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null)
|
||||
@@ -149,9 +158,9 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public static Structure CheckVisibility(Vector2 rayStart, Vector2 rayEnd)
|
||||
public static Body CheckVisibility(Vector2 rayStart, Vector2 rayEnd)
|
||||
{
|
||||
Structure closestStructure = null;
|
||||
Body closestBody = null;
|
||||
float closestFraction = 1.0f;
|
||||
|
||||
if (Vector2.Distance(rayStart,rayEnd)<0.01f)
|
||||
@@ -174,7 +183,7 @@ namespace Subsurface
|
||||
|
||||
if (fraction < closestFraction)
|
||||
{
|
||||
if (structure != null) closestStructure = structure;
|
||||
closestBody = fixture.Body;
|
||||
closestFraction = fraction;
|
||||
}
|
||||
return closestFraction;
|
||||
@@ -184,7 +193,7 @@ namespace Subsurface
|
||||
|
||||
lastPickedPosition = rayStart + (rayEnd - rayStart) * closestFraction;
|
||||
lastPickedFraction = closestFraction;
|
||||
return closestStructure;
|
||||
return closestBody;
|
||||
}
|
||||
|
||||
public static Body PickBody(Vector2 point)
|
||||
@@ -284,8 +293,17 @@ namespace Subsurface
|
||||
Clear();
|
||||
filePath = file;
|
||||
XDocument doc = null;
|
||||
string extension = "";
|
||||
|
||||
string extension = Path.GetExtension(file);
|
||||
try
|
||||
{
|
||||
extension = Path.GetExtension(file);
|
||||
}
|
||||
catch
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't load map ''" + file + "! (Unrecognized file extension)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (extension==".gz")
|
||||
{
|
||||
|
||||
@@ -88,6 +88,11 @@ namespace Subsurface
|
||||
get { return sections.Length; }
|
||||
}
|
||||
|
||||
public float Health
|
||||
{
|
||||
get { return prefab.MaxHealth; }
|
||||
}
|
||||
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
{
|
||||
@@ -380,7 +385,7 @@ namespace Subsurface
|
||||
int i = FindSectionIndex(ConvertUnits.ToDisplayUnits(position));
|
||||
if (i == -1) return;
|
||||
|
||||
Game1.particleManager.CreateParticle(ConvertUnits.ToSimUnits(SectionPosition(i)), 0.0f, 0.0f, "dustcloud");
|
||||
Game1.particleManager.CreateParticle("dustcloud", ConvertUnits.ToSimUnits(SectionPosition(i)), 0.0f, 0.0f);
|
||||
|
||||
|
||||
AddDamage(i, amount);
|
||||
|
||||
Reference in New Issue
Block a user