Turret rotation fix, CharacterInventory networking bugfixes, prevent limbs clipping with other colliders when mirroring, fixed mantis animations, better looking explosions, spark effect when overvoltage breaks an item

This commit is contained in:
Regalis
2015-09-04 21:56:39 +03:00
parent 2f08dcf3f9
commit 0cbcdd0b03
35 changed files with 393 additions and 262 deletions

View File

@@ -434,16 +434,13 @@ namespace FarseerPhysics.Collision
/// <param name="a">The first AABB.</param>
/// <param name="b">The second AABB.</param>
/// <returns>True if they are overlapping.</returns>
public static bool TestOverlap(ref AABB a, ref AABB b)
{
Vector2 d1 = b.LowerBound - a.UpperBound;
Vector2 d2 = a.LowerBound - b.UpperBound;
if (d1.X > 0.0f || d1.Y > 0.0f)
return false;
if (d2.X > 0.0f || d2.Y > 0.0f)
return false;
if (b.LowerBound.X - a.UpperBound.X > 0.0f ||
b.LowerBound.Y - a.UpperBound.Y > 0.0f ||
a.LowerBound.X - b.UpperBound.X > 0.0f ||
a.LowerBound.Y - b.UpperBound.Y > 0.0f) return false;
return true;
}

View File

@@ -77,10 +77,9 @@ namespace FarseerPhysics.Common
public static Vector2 Mul(ref Transform T, ref Vector2 v)
{
float x = (T.q.c * v.X - T.q.s * v.Y) + T.p.X;
float y = (T.q.s * v.X + T.q.c * v.Y) + T.p.Y;
return new Vector2(x, y);
return new Vector2(
(T.q.c * v.X - T.q.s * v.Y) + T.p.X,
(T.q.s * v.X + T.q.c * v.Y) + T.p.Y);
}
public static Vector2 MulT(ref Mat22 A, Vector2 v)
@@ -102,10 +101,8 @@ namespace FarseerPhysics.Common
{
float px = v.X - T.p.X;
float py = v.Y - T.p.Y;
float x = (T.q.c * px + T.q.s * py);
float y = (-T.q.s * px + T.q.c * py);
return new Vector2(x, y);
return new Vector2(T.q.c * px + T.q.s * py, -T.q.s * px + T.q.c * py);
}
// A^T * B

View File

@@ -47,7 +47,7 @@ namespace FarseerPhysics
/// NOTE: If you are using a debug view that shows performance counters,
/// you might want to enable this.
/// </summary>
public const bool EnableDiagnostics = true;
public const bool EnableDiagnostics = false;
/// <summary>
/// Set this to true to skip sanity checks in the engine. This will speed up the

View File

@@ -9,8 +9,7 @@
<ragdoll headposition="50" headangle="-70"
waveamplitude="50.0" wavelength="2500"
swimspeed="2.0" walkspeed="2.0"
stepsize ="15.0,20.0"
stepoffset="20.0,0.0"
stepsize ="15.0,20.0"
legtorque="10"
flip="true">
@@ -37,7 +36,7 @@
<limb id = "4" width="11" height="34" mass = "4" type="RightLeg" flip="true">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="82,83,11,34" depth="0.03" origin="0.5,0.5"/>
</limb>
<limb id = "5" width="5" height="40" mass = "4" type="RightFoot" flip="true" pullpos="0.0,15.0" refjoint="3">
<limb id = "5" width="5" height="40" mass = "4" type="RightFoot" flip="true" pullpos="0.0,15.0" refjoint="3" stepoffset="20.0,0.0">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="59,78,19,43" depth="0.03" origin="0.5,0.5"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
@@ -45,7 +44,7 @@
<limb id = "6" width="13" height="35" mass = "4" type="LeftLeg" flip="true">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="82,83,11,34" depth="0.03" origin="0.5,0.5"/>
</limb>
<limb id = "7" width="5" height="40" mass = "4" type="LeftFoot" flip="true" pullpos="0.0,15.0" refjoint="5">
<limb id = "7" width="5" height="40" mass = "4" type="LeftFoot" flip="true" pullpos="0.0,15.0" refjoint="5" stepoffset="20.0,0.0">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="59,78,19,43" depth="0.03" origin="0.5,0.5"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
@@ -53,7 +52,7 @@
<limb id = "8" width="13" height="35" mass = "4" type="RightLeg" flip="true">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="82,83,11,34" depth="0.03" origin="0.5,0.5"/>
</limb>
<limb id = "9" width="5" height="40" mass = "4" type="RightFoot" flip="true" pullpos="0.0,15.0" refjoint="7">
<limb id = "9" width="5" height="40" mass = "4" type="RightFoot" flip="true" pullpos="0.0,15.0" refjoint="7" stepoffset="20.0,0.0">
<sprite texture="Content/Characters/Crawler/crawler.png" sourcerect="59,78,19,43" depth="0.03" origin="0.5,0.5"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>

View File

@@ -1,20 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<character name ="mantis" humanoid="false">
<sound file="Content/Characters/Crawler/attack.ogg" state="Attack" range="500"/>
<sound file="Content/Characters/Crawler/attack1.ogg" state="Attack" range="500"/>
<sound file="Content/Characters/Crawler/attack2.ogg" state="Attack" range="500"/>
<sound file="Content/Characters/Crawler/idle1.ogg" state="None" range="500"/>
<sound file="Content/Characters/Crawler/idle2.ogg" state="None" range="500"/>
<ragdoll headposition="120" headangle="-90"
waveamplitude="50.0" wavelength="2500"
swimspeed="2.0" walkspeed="0.5"
stepsize ="30.0,20.0"
stepoffset="30.0,0.0"
swimspeed="2.0" walkspeed="1.0"
stepsize ="20.0,20.0"
legtorque="10"
footrotation ="180.0"
flip="true">
<!-- head -->
<limb id = "0" radius="30" height="30" mass = "6" type="Head" flip="true" steerforce="1.0" armorsector="0.0,180.0" armorvalue="5.0f">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="0,0,101,168" depth="0.02" origin="0.4,0.7"/>
<limb id = "0" radius="30" height="86" mass = "6" type="Head" flip="true" steerforce="1.0" armorsector="0.0,180.0" armorvalue="5.0f">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="0,0,101,168" depth="0.02" origin="0.4,0.53"/>
</limb>
<!-- middle part -->
@@ -41,43 +44,43 @@
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
<!-- ""claw" -->
<limb id = "6" width="15" height="63" mass = "4" flip="true" pullpos="0.0,30.0">
<limb id = "6" width="15" height="63" mass = "4" flip="true" pullpos="0.0,30.0" frefjoint="0">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="228,1,28,76" depth="0.01" origin="0.5,0.5"/>
<attack type="PinchCW" range="120" duration="0.5" damage="30" stun="0.1" bleedingdamage="5" structuredamage="50" damagetype="slash"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
<limb id = "7" width="15" height="63" mass = "4" type="LeftLeg" flip="true">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="205,91,20,63" depth="0.01" origin="0.5,0.5"/>
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="205,91,20,63" depth="0.013" origin="0.5,0.5"/>
</limb>
<limb id = "8" width="15" height="63" mass = "4" type="LeftFoot" flip="true" pullpos="0.0,30.0" refjoint="6">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="206,3,20,85" depth="0.011" origin="0.5,0.5"/>
<limb id = "8" width="15" height="63" mass = "4" type="LeftFoot" flip="true" pullpos="0.0,30.0" refjoint="0" stepoffset="100.0,0.0">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="206,3,20,85" depth="0.014" origin="0.5,0.5"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
<limb id = "9" width="15" height="63" mass = "4" type="RightLeg" flip="true">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="159,3,38,66" depth="0.01" origin="0.5,0.5"/>
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="159,3,38,66" depth="0.015" origin="0.5,0.5"/>
</limb>
<limb id = "10" width="15" height="102" mass = "4" type="RightFoot" flip="true" pullpos="0.0,50.0" refjoint="2">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="111,0,32,112" depth="0.011" origin="0.5,0.5"/>
<limb id = "10" width="15" height="102" mass = "4" type="RightFoot" flip="true" pullpos="0.0,50.0" refjoint="5" stepoffset="-150.0,0.0">
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="111,0,32,112" depth="0.016" origin="0.5,0.5"/>
<sound file ="Content/Sounds/stepMetal.ogg"/>
</limb>
<joint limb1="0" limb1anchor="-5,-25" limb2="1" limb2anchor="0,20" lowerlimit="-20" upperlimit="20"/>
<joint limb1="0" limb1anchor="-5,-53" limb2="1" limb2anchor="0,20" lowerlimit="-20" upperlimit="20"/>
<joint limb1="1" limb1anchor="6,-18" limb2="2" limb2anchor="-2,36" lowerlimit="-20" upperlimit="30"/>
<joint limb1="2" limb1anchor="1,7" limb2="3" limb2anchor="6,15" lowerlimit="-20" upperlimit="40"/>
<joint limb1="0" limb1anchor="16,30" limb2="4" limb2anchor="-5,-20" lowerlimit="-90" upperlimit="0"/>
<joint limb1="4" limb1anchor="2,21" limb2="5" limb2anchor="-8,-23" lowerlimit="-350" upperlimit="-280"/>
<joint limb1="0" limb1anchor="16,2" limb2="4" limb2anchor="-5,-20" lowerlimit="-90" upperlimit="0"/>
<joint limb1="4" limb1anchor="-2,21" limb2="5" limb2anchor="-5,-20" lowerlimit="-350" upperlimit="-280"/>
<joint limb1="5" limb1anchor="-2,27" limb2="6" limb2anchor="0,-30" lowerlimit="-190" upperlimit="-30"/>
<joint limb1="0" limb1anchor="52,-6" limb2="7" limb2anchor="-4,-19" lowerlimit="-90" upperlimit="0"/>
<joint limb1="0" limb1anchor="52,-34" limb2="7" limb2anchor="-4,-19" lowerlimit="-90" upperlimit="0"/>
<joint limb1="7" limb1anchor="-2,28" limb2="8" limb2anchor="2,-32" lowerlimit="-190" upperlimit="-30"/>
<joint limb1="0" limb1anchor="43,-39" limb2="9" limb2anchor="0,21" lowerlimit="-180" upperlimit="-10"/>
<joint limb1="0" limb1anchor="43,-67" limb2="9" limb2anchor="0,21" lowerlimit="-180" upperlimit="-10"/>
<joint limb1="9" limb1anchor="0,-28" limb2="10" limb2anchor="-11,-46" lowerlimit="-190" upperlimit="-50"/>
</ragdoll>

View File

@@ -2,7 +2,7 @@
<Item
name="Railgun"
focusonselected="true"
offsetonselected="500"
offsetonselected="700"
linkable="true"
pickdistance="150">
@@ -11,7 +11,9 @@
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="117, 57"
rotationlimits="180,360"
powerconsumption="500.0">
<Sound file="railgun.ogg" type="OnUse"/>
<StatusEffect type="OnUse" target="This" sound="Content/Items/Weapons/railgun.ogg">
<Explosion range="10.0" structuredamage="0" force="0.05"/>
</StatusEffect>
</Turret>
<ConnectionPanel canbeselected = "true" msg="Rewire [Screwdriver]">

View File

@@ -72,19 +72,45 @@
<sprite texture="Content/Particles/spatter.png"/>
</waterblood>
<spark
startsizemin="0.5,0.2" startsizemax="1.0,0.7"
sizechangemin="-0.5,-0.5" sizechangemax="-1.0,-1.0"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -0.3"
lifetime="5.0"
drawtarget="air"
deleteonhit="true"
rotatetodirection="true"
velocitychange="0.0, -5.0">
<sprite texture="Content/Particles/explosion.png" sourcerect="128,0,128,64"/>
</spark>
<shockwave
startsizemin="0.1,0.1" startsizemax="0.1,0.1"
sizechangemin="15.0,15.0" sizechangemax="15.0,15.0"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="0.0, 0.0, 0.0, -2.0"
lifetime="1.0"
drawtarget="both"
velocitychange="0.0, 0.0">
<sprite texture="Content/Particles/explosion.png" sourcerect="0,128,128,128"/>
</shockwave>
<explosionfire
startsizemin="1.5,1.5" startsizemax="3.0,3.0"
startsizemin="1.0,1.0" startsizemax="1.5,1.5"
sizechangemin="0.5,0.5" sizechangemax="0.6,0.6"
startrotationmin ="0.0" startrotationmax="6.28"
startcolor="1.0, 1.0, 1.0" startalpha="1.0"
colorchange="-0.4, -0.4, -0.4, -0.3"
colorchange="-0.6, -0.6, -0.6, -0.5"
lifetime="5.0"
drawtarget="air"
deleteonhit="true"
velocitychange="0.0, 0.5">
<sprite texture="Content/Particles/explosion.png"/>
<sprite texture="Content/Particles/explosion.png" sourcerect="0,0,128,128"/>
</explosionfire>
<weld
startsizemin="0.9,0.9" startsizemax="1.1,1.1"
sizechangemin="-4.0,-0.1" sizechangemax="-4.0,-0.5"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -26,7 +26,6 @@ namespace Subsurface
protected readonly Vector2 stepSize;
protected readonly float legTorque;
protected readonly Vector2 stepOffset;
public float StunTimer
{
@@ -46,8 +45,8 @@ namespace Subsurface
stepSize = ToolBox.GetAttributeVector2(element, "stepsize", Vector2.One);
stepSize = ConvertUnits.ToSimUnits(stepSize);
stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.One);
stepOffset = ConvertUnits.ToSimUnits(stepOffset);
//stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.One);
//stepOffset = ConvertUnits.ToSimUnits(stepOffset);
//impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f);

View File

@@ -69,22 +69,22 @@ namespace Subsurface
depth = MathHelper.Clamp(depth + velocity.Z * deltaTime, 0.0f, MaxDepth);
checkWallsTimer -= deltaTime;
if (checkWallsTimer<=0.0f)
if (checkWallsTimer<=0.0f && Level.Loaded!=null)
{
checkWallsTimer = CheckWallsInterval;
obstacleDiff = Vector2.Zero;
var cells = Level.Loaded.GetCells(position, 1);
if (cells.Count>0)
if (cells.Count > 0)
{
foreach (Voronoi2.VoronoiCell cell in cells)
{
obstacleDiff += cell.Center - position;
}
obstacleDiff = Vector2.Normalize(obstacleDiff)*prefab.Speed;
obstacleDiff = Vector2.Normalize(obstacleDiff) * prefab.Speed;
}
}
@@ -141,7 +141,9 @@ namespace Subsurface
if (velocity.X < 0.0f) rotation -= MathHelper.Pi;
}
Vector2 drawPos = position + Level.Loaded.Position;
Vector2 drawPos = position;
if (Level.Loaded != null) drawPos += Level.Loaded.Position;
if (depth > 0.0f)
{

View File

@@ -866,7 +866,7 @@ namespace Subsurface
for (int i = 0; i < sounds.Count(); i++)
{
if (soundStates[i] != state) continue;
if (n == selectedSound)
if (n == selectedSound && sounds[i]!=null)
{
sounds[i].Play(1.0f, 2000.0f,
AnimController.limbs[0].body.FarseerBody);

View File

@@ -302,8 +302,8 @@ namespace Subsurface
RevoluteJoint refJoint = limbJoints[limb.RefJointIndex];
footPos.X = refJoint.WorldAnchorA.X;
}
footPos.X += stepOffset.X * Dir;
footPos.Y += stepOffset.Y;
footPos.X += limb.StepOffset.X * Dir;
footPos.Y += limb.StepOffset.Y;
if (limb.type == LimbType.LeftFoot)
{
@@ -373,7 +373,20 @@ namespace Subsurface
foreach (Limb l in limbs)
{
Vector2 newPos = new Vector2(midX - (l.SimPosition.X - midX), l.SimPosition.Y);
l.body.SetTransform(newPos, l.body.Rotation);
if (Submarine.CheckVisibility(l.SimPosition, newPos)!=null)
{
Vector2 diff = newPos - l.SimPosition;
l.body.SetTransform(
l.SimPosition + Submarine.LastPickedFraction * diff * 0.8f, l.body.Rotation);
}
else
{
l.body.SetTransform(newPos, l.body.Rotation);
}
}
}

View File

@@ -786,7 +786,6 @@ namespace Subsurface
arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f);
hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f);
}
}

View File

@@ -32,6 +32,8 @@ namespace Subsurface
private readonly bool doesFlip;
protected readonly Vector2 stepOffset;
public Sprite sprite;
public bool inWater;
@@ -128,6 +130,11 @@ namespace Subsurface
get { return refJointIndex; }
}
public Vector2 StepOffset
{
get { return stepOffset; }
}
//public float Damage
//{
// get { return damage; }
@@ -205,9 +212,11 @@ namespace Subsurface
Vector2 jointPos = ToolBox.GetAttributeVector2(element, "pullpos", Vector2.Zero);
jointPos = ConvertUnits.ToSimUnits(jointPos);
stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.Zero);
stepOffset = ConvertUnits.ToSimUnits(stepOffset);
refJointIndex = ToolBox.GetAttributeInt(element, "refjoint", -1);
pullJoint = new FixedMouseJoint(body.FarseerBody, jointPos);

View File

@@ -367,13 +367,13 @@ namespace Subsurface
{
infoBox = CreateInfoFrame("The diving mask will let you breathe underwater, but it won't protect from the water pressure outside the sub. "+
"It should be fine for the situation at hand, but you still need to find an oxygen tank and drag it into the same slot as the mask." +
"You should grab one or two.");
"You should grab one or two from one of the cabinets.");
}
else if (HasItem("Diving Suit"))
{
infoBox = CreateInfoFrame("In addition to letting you breathe underwater, the suit will protect you from the water pressure outside the sub " +
"(unlike the diving mask). However, you still need to drag an oxygen tank into the same slot as the suit to supply oxygen. "+
"You should grab one or two.");
"(unlike the diving mask). However, you still need to drag an oxygen tank into the same slot as the suit to supply oxygen. "+
"You should grab one or two from one of the cabinets.");
}
while (!HasItem("Oxygen Tank"))
@@ -431,7 +431,8 @@ namespace Subsurface
yield return CoroutineStatus.Running;
}
infoBox = CreateInfoFrame("Use the right mouse button to aim and left to shoot.");
infoBox = CreateInfoFrame("Use the right mouse button to aim and wait for the creature to come closer. When you're ready to shoot, "
+"press the left mouse button.");
while (!moloch.IsDead)
{
@@ -510,6 +511,7 @@ namespace Subsurface
float secondsLeft = endPreviewLength;
Character.Controlled = null;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
do
{

View File

@@ -107,7 +107,7 @@ namespace Subsurface
public void StartShift(TimeSpan duration, Level level, bool reloadSub = true)
{
Game1.LightManager.LosEnabled = (Game1.Server==null && Character.Controlled==null);
Game1.LightManager.LosEnabled = (Game1.Server==null || Game1.Server.CharacterInfo!=null);
this.level = level;

View File

@@ -66,8 +66,13 @@ namespace Subsurface
protected override void DropItem(Item item)
{
bool enabled = draggingItem.body.Enabled;
item.Drop(character);
item.body.SetTransform(character.SimPosition, 0.0f);
if (!enabled)
{
draggingItem.body.SetTransform(character.SimPosition, 0.0f);
}
}
public int FindLimbSlot(LimbSlot limbSlot)
@@ -202,8 +207,8 @@ namespace Subsurface
if (items[rightHandSlot] != null) return false;
if (items[leftHandSlot] != null) return false;
PutItem(item, rightHandSlot, true, true);
PutItem(item, leftHandSlot, true, false);
PutItem(item, rightHandSlot, createNetworkEvent, true);
PutItem(item, leftHandSlot, createNetworkEvent, false);
item.Equip(character);
return true;
}
@@ -269,8 +274,7 @@ namespace Subsurface
DrawSlot(spriteBatch, slotRect, draggingItem, false, false);
}
else
{
draggingItem.body.SetTransform(character.SimPosition, 0.0f);
{
DropItem(draggingItem);
//draggingItem = null;
}

View File

@@ -12,36 +12,39 @@ namespace Subsurface.Items.Components
{
//the rate at which the reactor is being run un
//higher rates generate more power (and heat)
float fissionRate;
private float fissionRate;
//the rate at which the heat is being dissipated
float coolingRate;
private float coolingRate;
float temperature;
private float temperature;
//is automatic temperature control on
//(adjusts the cooling rate automatically to keep the
//amount of power generated balanced with the load)
bool autoTemp;
private bool autoTemp;
//the temperature after which fissionrate is automatically
//turned down and cooling increased
float shutDownTemp;
private float shutDownTemp;
float meltDownTemp;
private float meltDownTemp;
//how much power is provided to the grid per 1 temperature unit
float powerPerTemp;
private float powerPerTemp;
int graphSize = 25;
private int graphSize = 25;
float graphTimer;
private float graphTimer;
int updateGraphInterval = 500;
private int updateGraphInterval = 500;
float[] fissionRateGraph;
float[] coolingRateGraph;
float[] tempGraph;
private float[] fissionRateGraph;
private float[] coolingRateGraph;
private float[] tempGraph;
private float[] loadGraph;
private float load;
private PropertyTask powerUpTask;
@@ -118,9 +121,10 @@ namespace Subsurface.Items.Components
public Reactor(Item item, XElement element)
: base(item, element)
{
fissionRateGraph = new float[graphSize];
coolingRateGraph = new float[graphSize];
tempGraph = new float[graphSize];
fissionRateGraph = new float[graphSize];
coolingRateGraph = new float[graphSize];
tempGraph = new float[graphSize];
loadGraph = new float[graphSize];
meltDownTemp = 9000.0f;
@@ -155,6 +159,24 @@ namespace Subsurface.Items.Components
powerUpTask = new PropertyTask(item, IsRunning, 50.0f, "Power up the reactor");
}
}
load = 0.0f;
List<Connection> connections = item.Connections;
if (connections != null && connections.Count > 0)
{
foreach (Connection connection in connections)
{
foreach (Connection recipient in connection.Recipients)
{
Item it = recipient.Item as Item;
if (it == null) continue;
PowerTransfer pt = it.GetComponent<PowerTransfer>();
if (pt != null) load += pt.PowerLoad;
}
}
}
//item.Condition -= temperature * deltaTime * 0.00005f;
@@ -165,34 +187,6 @@ namespace Subsurface.Items.Components
}
else if (autoTemp)
{
float load = 0.0f;
List<Connection> connections = item.Connections;
if (connections!=null && connections.Count>0)
{
foreach (Connection connection in connections)
{
foreach (Connection recipient in connection.Recipients)
{
Item it = recipient.Item as Item;
if (it == null) continue;
PowerTransfer pt = it.GetComponent<PowerTransfer>();
if (pt != null) load += pt.PowerLoad;
}
}
}
//foreach (MapEntity e in item.linkedTo)
//{
// Item it = e as Item;
// if (it == null) continue;
// PowerTransfer pt = it.GetComponent<PowerTransfer>();
// if (pt != null) load += pt.PowerLoad;
//}
fissionRate = Math.Min(load / 200.0f, shutDownTemp);
//float target = Math.Min(targetTemp, load);
CoolingRate = coolingRate + (temperature - Math.Min(load, shutDownTemp) + deltaTemp)*0.1f;
@@ -247,6 +241,9 @@ namespace Subsurface.Items.Components
UpdateGraph(fissionRateGraph, fissionRate);
UpdateGraph(coolingRateGraph, coolingRate);
UpdateGraph(tempGraph, temperature);
UpdateGraph(loadGraph, load);
graphTimer = 0.0f;
}
}
@@ -304,62 +301,73 @@ namespace Subsurface.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
spriteBatch.DrawString(GUI.Font, "Temperature: " + (int)temperature + " C", new Vector2(x + 30, y + 30), Color.White);
DrawGraph(tempGraph, spriteBatch, x + 30, y + 50, 10000.0f, xOffset);
spriteBatch.DrawString(GUI.Font, "Temperature: " + (int)temperature + " C",
new Vector2(x + 450, y + 30), Color.Red);
spriteBatch.DrawString(GUI.Font, "Grid load: " + (int)load + " C",
new Vector2(x + 620, y + 30), Color.Yellow);
y += 130;
DrawGraph(tempGraph, spriteBatch,
new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Red);
spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y + 30), Color.White);
DrawGraph(fissionRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
DrawGraph(loadGraph, spriteBatch,
new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Yellow);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 450, y + 80), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 110, 40, 40), "+", true))
{
valueChanged = true;
FissionRate += 1.0f;
ShutDownTemp += 100.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 500, y + 110, 40, 40), "-", true))
{
valueChanged = true;
FissionRate -= 1.0f;
ShutDownTemp -= 100.0f;
}
y += 130;
spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 30, y + 30), Color.White);
DrawGraph(coolingRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
{
valueChanged = true;
CoolingRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
{
valueChanged = true;
CoolingRate -= 1.0f;
}
y = y - 260;
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 210, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
{
valueChanged = true;
autoTemp = !autoTemp;
}
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true))
y += 300;
spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y), Color.White);
DrawGraph(fissionRateGraph, spriteBatch,
new Rectangle(x + 30, y + 30, 200, 100), 100.0f, xOffset, Color.Orange);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 30, 40, 40), "+", true))
{
valueChanged = true;
ShutDownTemp += 100.0f;
FissionRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true))
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 80, 40, 40), "-", true))
{
valueChanged = true;
ShutDownTemp -= 100.0f;
FissionRate -= 1.0f;
}
spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 320, y), Color.White);
DrawGraph(coolingRateGraph, spriteBatch,
new Rectangle(x + 320, y + 30, 200, 100), 100.0f, xOffset, Color.LightBlue);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 30, 40, 40), "+", true))
{
valueChanged = true;
CoolingRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 80, 40, 40), "-", true))
{
valueChanged = true;
CoolingRate -= 1.0f;
}
//y = y - 260;
if (valueChanged)
{
item.NewComponentEvent(this, true);
@@ -376,35 +384,32 @@ namespace Subsurface.Items.Components
graph[0] = newValue;
}
static void DrawGraph(IList<float> graph, SpriteBatch spriteBatch, int x, int y, float maxVal, float xOffset)
static void DrawGraph(IList<float> graph, SpriteBatch spriteBatch, Rectangle rect, float maxVal, float xOffset, Color color)
{
int width = 200;
int height = 100;
float lineWidth = (float)rect.Width / (float)(graph.Count - 2);
float yScale = (float)rect.Height / maxVal;
float lineWidth = (float)width / (float)(graph.Count - 2);
float yScale = (float)height / maxVal;
GUI.DrawRectangle(spriteBatch, rect, Color.White);
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.White);
Vector2 prevPoint = new Vector2(rect.Right, rect.Bottom - (graph[1] + (graph[0] - graph[1]) * xOffset) * yScale);
Vector2 prevPoint = new Vector2(x + width, y + height - (graph[1] + (graph[0] - graph[1]) * xOffset) * yScale);
float currX = x + width - ((xOffset - 1.0f) * lineWidth);
float currX = rect.Right - ((xOffset - 1.0f) * lineWidth);
for (int i = 1; i < graph.Count - 1; i++)
{
currX -= lineWidth;
Vector2 newPoint = new Vector2(currX, y + height - graph[i] * yScale);
Vector2 newPoint = new Vector2(currX, rect.Bottom - graph[i] * yScale);
GUI.DrawLine(spriteBatch, prevPoint, newPoint, Color.White);
GUI.DrawLine(spriteBatch, prevPoint, newPoint - new Vector2(1.0f, 0), color);
prevPoint = newPoint;
}
Vector2 lastPoint = new Vector2(x,
y + height - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
Vector2 lastPoint = new Vector2(rect.X,
rect.Bottom - (graph[graph.Count - 1] + (graph[graph.Count - 2] - graph[graph.Count - 1]) * xOffset) * yScale);
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, Color.White);
GUI.DrawLine(spriteBatch, prevPoint, lastPoint, color);
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)

View File

@@ -45,13 +45,34 @@ namespace Subsurface.Items.Components
foreach (Powered p in connectedList)
{
PowerTransfer pt = p as PowerTransfer;
if (pt!=null)
if (pt == null) continue;
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f));
//damage the item if voltage is too high
if (-pt.currPowerConsumption > Math.Max(pt.powerLoad * 2.0f, 200.0f))
{
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f));
if (-pt.currPowerConsumption > Math.Max(pt.powerLoad * 2.0f, 200.0f)) pt.item.Condition -= deltaTime*10.0f;
float prevCondition = pt.item.Condition;
pt.item.Condition -= deltaTime * 10.0f;
if (pt.item.Condition<=0.0f && prevCondition > 0.0f)
{
sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 600.0f, item.Position);
Vector2 baseVel = Rand.Vector(3.0f);
for (int i = 0; i < 10; i++)
{
var particle = Game1.ParticleManager.CreateParticle("spark", pt.item.SimPosition,
baseVel + Rand.Vector(1.0f), 0.0f);
if (particle != null) particle.Size *= Rand.Range(0.5f,1.0f);
}
}
}
}
@@ -135,7 +156,7 @@ namespace Subsurface.Items.Components
{
base.ReceiveSignal(signal, connection, sender, power);
if (connection.Name.Length>5 && connection.Name.Substring(0, 6).ToLower() == "signal")
if (connection.Name.Length > 5 && connection.Name.Substring(0, 6).ToLower() == "signal")
{
connection.SendSignal(signal, sender, 0.0f);
}

View File

@@ -1,11 +1,15 @@
using System;
using System.Globalization;
using System.IO;
using System.Xml.Linq;
namespace Subsurface.Items.Components
{
class Powered : ItemComponent
{
protected static Sound[] sparkSounds;
//the amount of power CURRENTLY consumed by the item
//negative values mean that the item is providing power to connected items
protected float currPowerConsumption;
@@ -63,6 +67,25 @@ namespace Subsurface.Items.Components
set { voltage = Math.Max(0.0f, value); }
}
public Powered(Item item, XElement element)
: base(item, element)
{
if (powerOnSound == null)
{
powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg");
}
if (sparkSounds == null)
{
sparkSounds = new Sound[4];
string dir = Path.GetDirectoryName(item.Prefab.ConfigFile) + "\\";
for (int i = 0; i < 4; i++)
{
sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap" + (i + 1) + ".ogg");
}
}
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
{
if (currPowerConsumption == 0.0f) voltage = 0.0f;
@@ -87,13 +110,6 @@ namespace Subsurface.Items.Components
}
}
public Powered(Item item, XElement element)
: base(item, element)
{
if (powerOnSound==null)
{
powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg");
}
}
}
}

View File

@@ -162,9 +162,11 @@ namespace Subsurface.Items.Components
ignoredBodies.Clear();
f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
if (attackResult.HitArmor)
{
item.body.LinearVelocity *= 0.5f;
item.body.LinearVelocity *= 0.1f;
}
else if (doesStick)
{
@@ -175,7 +177,10 @@ namespace Subsurface.Items.Components
if (Vector2.Dot(f1.Body.LinearVelocity, normal) < 0.0f) return StickToTarget(f2.Body, dir);
}
else
{
item.body.LinearVelocity *= 0.5f;
}
var containedItems = item.ContainedItems;
if (containedItems == null) return true;
@@ -188,7 +193,7 @@ namespace Subsurface.Items.Components
contained.Condition = 0.0f;
}
return true;
return false;
}
private bool StickToTarget(Body targetBody, Vector2 axis)

View File

@@ -10,7 +10,6 @@ namespace Subsurface.Items.Components
{
class LightComponent : Powered
{
static Sound[] sparkSounds;
private Color lightColor;
@@ -67,16 +66,6 @@ namespace Subsurface.Items.Components
public LightComponent(Item item, XElement element)
: base (item, element)
{
if (sparkSounds==null)
{
sparkSounds = new Sound[4];
string dir = Path.GetDirectoryName(item.Prefab.ConfigFile)+"\\";
for (int i = 0; i<4; i++)
{
sparkSounds[i] = Sound.Load("Content/Items/Electricity/zap"+(i+1)+".ogg");
}
}
//foreach (XElement subElement in element.Elements())
//{
// if (subElement.Name.ToString().ToLower() != "sprite") continue;

View File

@@ -88,17 +88,36 @@ namespace Subsurface.Items.Components
{
this.cam = cam;
if (reload>0.0f) reload -= deltaTime;
if (reload > 0.0f) reload -= deltaTime;
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
if (targetRotation < minRotation || targetRotation > maxRotation)
float targetMidDiff = MathHelper.WrapAngle(targetRotation - (minRotation + maxRotation) / 2.0f);
float maxDist = (maxRotation - minRotation) / 2.0f;
if (Math.Abs(targetMidDiff) > maxDist)
{
float diff = MathUtils.WrapAngleTwoPi(targetRotation - (minRotation + maxRotation) / 2.0f);
targetRotation = (diff > Math.PI) ? minRotation : maxRotation;
targetRotation = (targetMidDiff < 0.0f) ? minRotation : maxRotation;
}
float deltaRotation = MathHelper.WrapAngle(targetRotation-rotation);
deltaRotation = MathHelper.Clamp(deltaRotation, -0.5f, 0.5f) * 5.0f;
rotation += deltaRotation * deltaTime;
float rotMidDiff = MathHelper.WrapAngle(rotation - (minRotation + maxRotation) / 2.0f);
if (rotMidDiff < -maxDist)
{
rotation = minRotation;
}
else if (rotMidDiff > maxDist)
{
rotation = maxRotation;
}
rotation = MathUtils.CurveAngle(rotation, targetRotation, 0.05f);
}
public override bool Use(float deltaTime, Character character = null)

View File

@@ -173,6 +173,7 @@ namespace Subsurface
if (!unfixedFound)
{
item.Condition = 100.0f;
frame = null;
}
}
@@ -184,6 +185,9 @@ namespace Subsurface
}
UpdateGUIFrame(item, character);
if (frame == null) return;
frame.Update((float)Physics.step);
frame.Draw(spriteBatch);
}

View File

@@ -304,6 +304,8 @@ namespace Subsurface
Item item = FindEntityByID(itemId) as Item;
if (item == null) return;
System.Diagnostics.Debug.WriteLine("Inventory update: "+itemId+" - "+slotIndex);
if (slotIndex==-1)
{
if (item.inventory == this) item.Drop();

View File

@@ -718,8 +718,8 @@ namespace Subsurface
FixRequirement.DrawHud(spriteBatch, this, character);
}
}
public void SendSignal(string signal, string connectionName, float power=0.0f)
public void SendSignal(string signal, string connectionName, float power = 0.0f)
{
ConnectionPanel panel = GetComponent<ConnectionPanel>();
if (panel == null) return;
@@ -729,7 +729,6 @@ namespace Subsurface
c.SendSignal(signal, this, power);
}
}
/// <param name="position">Position of the character doing the pick, only items that are close enough to this are checked</param>

View File

@@ -51,13 +51,20 @@ namespace Subsurface
public void Explode(Vector2 simPosition)
{
Game1.ParticleManager.CreateParticle("shockwave", simPosition,
Vector2.Zero, 0.0f);
for (int i = 0; i < range * 10; i++)
{
Game1.ParticleManager.CreateParticle("explosionfire", simPosition,
Rand.Vector(Rand.Range(3.0f, 4.0f)), 0.0f);
Game1.ParticleManager.CreateParticle("spark", simPosition,
Rand.Vector(Rand.Range(5.0f, 8.0f)), 0.0f);
Game1.ParticleManager.CreateParticle("explosionfire", simPosition + Rand.Vector(0.5f),
Rand.Vector(Rand.Range(0.5f, 1.0f)), 0.0f);
}
Vector2 displayPosition = ConvertUnits.ToDisplayUnits(simPosition);
float displayRange = ConvertUnits.ToDisplayUnits(range);
@@ -127,7 +134,7 @@ namespace Subsurface
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
light.Range = startRange * currBrightness;
currBrightness -= 0.1f;
currBrightness -= 0.05f;
yield return CoroutineStatus.Running;
}

View File

@@ -8,8 +8,10 @@ namespace Subsurface.Lights
class ConvexHull
{
public static List<ConvexHull> list = new List<ConvexHull>();
static BasicEffect losEffect;
static BasicEffect shadowEffect;
static BasicEffect penumbraEffect;
private static VertexPositionTexture[] penumbraVertices;
private VertexPositionColor[] vertices;
private short[] indices;
@@ -33,6 +35,25 @@ namespace Subsurface.Lights
public ConvexHull(Vector2[] points, Color color)
{
if (shadowEffect == null)
{
shadowEffect = new BasicEffect(Game1.CurrGraphicsDevice);
shadowEffect.VertexColorEnabled = true;
}
if (penumbraEffect == null)
{
penumbraEffect = new BasicEffect(Game1.CurrGraphicsDevice);
penumbraEffect.TextureEnabled = true;
//shadowEffect.VertexColorEnabled = true;
penumbraEffect.LightingEnabled = false;
penumbraEffect.Texture = Game1.TextureLoader.FromFile("Content/Lights/penumbra.png");
}
if (penumbraVertices==null)
{
penumbraVertices = new VertexPositionTexture[6];
}
int vertexCount = points.Length;
vertices = new VertexPositionColor[vertexCount + 1];
Vector2 center = Vector2.Zero;
@@ -90,37 +111,9 @@ namespace Subsurface.Lights
}
}
//public void Draw(GameTime gameTime)
//{
// device.RasterizerState = RasterizerState.CullNone;
// device.BlendState = BlendState.Opaque;
// drawingEffect.World = Matrix.CreateTranslation(position.X, position.Y, 0);
// foreach (EffectPass pass in drawingEffect.CurrentTechnique.Passes)
// {
// pass.Apply();
// device.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, primitiveCount);
// }
//}
public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, Vector2 lightSourcePos, bool los = true)
{
if (!Enabled) return;
if (losEffect == null)
{
losEffect = new BasicEffect(graphicsDevice);
losEffect.VertexColorEnabled = true;
}
if (shadowEffect==null)
{
shadowEffect = new BasicEffect(graphicsDevice);
shadowEffect.TextureEnabled = true;
//shadowEffect.VertexColorEnabled = true;
shadowEffect.LightingEnabled = false;
shadowEffect.Texture = Game1.TextureLoader.FromFile("Content/Lights/penumbra.png");
}
//compute facing of each edge, using N*L
for (int i = 0; i < primitiveCount; i++)
@@ -155,8 +148,6 @@ namespace Subsurface.Lights
startingIndex = nextEdge;
}
VertexPositionTexture[] penumbraVertices = new VertexPositionTexture[6];
if (los)
{
for (int n = 0; n < 4; n+=3)
@@ -233,21 +224,19 @@ namespace Subsurface.Lights
currentIndex = (currentIndex + 1) % primitiveCount;
}
losEffect.World = cam.ShaderTransform
shadowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
losEffect.CurrentTechnique.Passes[0].Apply();
shadowEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2);
if (los)
{
shadowEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(Game1.GraphicsWidth, Game1.GraphicsHeight, -1, 1) * 0.5f;
shadowEffect.CurrentTechnique.Passes[0].Apply();
penumbraEffect.World = shadowEffect.World;
penumbraEffect.CurrentTechnique.Passes[0].Apply();
#if WINDOWS
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration);
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration);
#endif
}
}

View File

@@ -648,6 +648,13 @@ namespace Subsurface.Networking
public IEnumerable<object> EndGame(string endMessage)
{
var messageBox = new GUIMessageBox("The round has ended", endMessage);
Character.Controlled = null;
Game1.GameScreen.Cam.TargetPos = Vector2.Zero;
Game1.LightManager.LosEnabled = false;
gameStarted = false;
if (connectedClients.Count > 0)
@@ -685,6 +692,8 @@ namespace Subsurface.Networking
Game1.GameScreen.Cam.TargetPos = offset * 0.8f;
//Game1.GameScreen.Cam.MoveCamera((float)deltaTime);
messageBox.Text = endMessage + "\nReturning to lobby in " + (int)secondsLeft + " s";
yield return CoroutineStatus.Running;
} while (secondsLeft > 0.0f);
@@ -692,8 +701,6 @@ namespace Subsurface.Networking
Game1.NetLobbyScreen.Select();
DebugConsole.ThrowError(endMessage);
yield return CoroutineStatus.Success;
}

View File

@@ -26,19 +26,19 @@ namespace Subsurface
{
using (var game = new Game1())
{
//#if !DEBUG
#if !DEBUG
try
{
//#endif
#endif
game.Run();
//#if !DEBUG
#if !DEBUG
}
catch (Exception e)
{
CrashDump(game, "crashreport.txt", e);
}
//#endif
#endif
}
}
@@ -60,11 +60,11 @@ namespace Subsurface
if (Game1.Server != null)
{
sb.AppendLine("Server (" +(Game1.Server.GameStarted ? "Round had started" : "Round hand't been started"));
sb.AppendLine("Server (" +(Game1.Server.GameStarted ? "Round had started)" : "Round hand't been started)"));
}
else if (Game1.Client != null)
{
sb.AppendLine("Server (" +(Game1.Client.GameStarted ? "Round had started" : "Round hand't been started"));
sb.AppendLine("Client (" +(Game1.Client.GameStarted ? "Round had started)" : "Round hand't been started)"));
}
sb.AppendLine("\n");
@@ -85,7 +85,7 @@ namespace Subsurface
}
sw.WriteLine(sb.ToString());
sw.WriteLine(sb.ToString());
MessageBox.Show( "A crash report (''crashreport.txt'') was saved in the root folder of the game."+
" If you'd like to help fix this bug, please make a bug report on the Undertow Games forum with the report attached.",

View File

@@ -43,20 +43,19 @@ namespace Subsurface
cam = new Camera();
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), Color.DarkGray * 0.8f);
GUIpanel = new GUIFrame(new Rectangle(0, 0, 300, Game1.GraphicsHeight), GUI.style);
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
physicsButton = new GUIButton(new Rectangle(0, 50, 200, 25), "Physics", Alignment.Left, GUI.style, GUIpanel);
physicsButton.OnClicked += TogglePhysics;
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", Color.Transparent, Color.Black, Alignment.Left, null, GUIpanel);
new GUITextBlock(new Rectangle(0, 80, 0, 25), "Limbs:", GUI.style, GUIpanel);
limbList = new GUIListBox(new Rectangle(0, 110, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
limbList.OnSelected = SelectLimb;
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", Color.Transparent, Color.Black, Alignment.Left, null, GUIpanel);
new GUITextBlock(new Rectangle(0, 360, 0, 25), "Joints:", GUI.style, GUIpanel);
jointList = new GUIListBox(new Rectangle(0, 390, 0, 250), Color.White * 0.7f, GUI.style, GUIpanel);
while (Character.CharacterList.Count > 1)
{
Character.CharacterList.First().Remove();
@@ -226,7 +225,7 @@ namespace Subsurface
new Rectangle(0,0,0,25),
limb.type.ToString(),
Color.Transparent,
Color.Black,
Color.White,
Alignment.Left, null,
limbList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
@@ -243,7 +242,7 @@ namespace Subsurface
new Rectangle(0, 0, 0, 25),
limb1.type.ToString() + " - " + limb2.type.ToString(),
Color.Transparent,
Color.Black,
Color.White,
Alignment.Left, null,
jointList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);

View File

@@ -31,7 +31,7 @@ namespace Subsurface
selectedTab = -1;
GUIpanel = new GUIFrame(new Rectangle(0,0, 120, Game1.GraphicsHeight), Color.DarkGray*0.8f);
GUIpanel = new GUIFrame(new Rectangle(0, 0, 150, Game1.GraphicsHeight), GUI.style);
GUIpanel.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
//GUIListBox constructionList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUIpanel);
//constructionList.OnSelected = MapEntityPrefab.SelectPrefab;
@@ -50,13 +50,13 @@ namespace Subsurface
GUItabs = new GUIComponent[2];
int width = 400, height = 400;
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), Color.DarkGray*0.8f);
GUItabs[0] = new GUIFrame(new Rectangle(Game1.GraphicsWidth/2-width/2, Game1.GraphicsHeight/2-height/2, width, height), GUI.style);
GUItabs[0].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox itemList = new GUIListBox(new Rectangle(0, 0, 0, 0), Color.White * 0.7f, GUI.style, GUItabs[0]);
itemList.OnSelected = SelectPrefab;
itemList.CheckSelected = MapEntityPrefab.GetSelected;
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), Color.DarkGray * 0.8f);
GUItabs[1] = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), GUI.style);
GUItabs[1].Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox structureList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.style, GUItabs[1]);
structureList.OnSelected = SelectPrefab;
@@ -65,7 +65,7 @@ namespace Subsurface
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
{
GUIListBox parent = ((ep as ItemPrefab) == null) ? structureList : itemList;
Color color = ((parent.CountChildren % 2) == 0) ? Color.White : Color.LightGray;
Color color = ((parent.CountChildren % 2) == 0) ? Color.Transparent : Color.White * 0.1f;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, parent);
frame.UserData = ep;
@@ -77,7 +77,7 @@ namespace Subsurface
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(40, 0, 0, 25),
ep.Name,
Color.Transparent, Color.Black,
Color.Transparent, Color.White,
Alignment.Left, Alignment.Left,
null, frame);
textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f);
@@ -130,6 +130,8 @@ namespace Subsurface
private bool ToggleCharacterMode(GUIButton button, object obj)
{
selectedTab = 0;
characterMode = !characterMode;
button.Color = (characterMode) ? Color.Gold : Color.White;

View File

@@ -284,6 +284,7 @@ namespace Subsurface
if (infoFrame.children.Find(c => c.UserData as string == "playyourself") == null)
{
var playYourself = new GUITickBox(new Rectangle(0, -20, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
playYourself.Selected = Game1.Server.CharacterInfo != null;
playYourself.OnSelected = TogglePlayYourself;
playYourself.UserData = "playyourself";
}
@@ -373,6 +374,7 @@ namespace Subsurface
if (IsServer && Game1.Server != null)
{
Game1.Server.CharacterInfo = null;
Game1.Server.Character = null;
var playYourself = new GUITickBox(new Rectangle(0, -20, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame);
playYourself.OnSelected = TogglePlayYourself;
@@ -577,9 +579,14 @@ namespace Subsurface
{
if (string.IsNullOrEmpty(newName)) return false;
Game1.Client.CharacterInfo.Name = newName;
Game1.Client.Name = newName;
Game1.Client.SendCharacterData();
if (Game1.NetworkMember == null || Game1.NetworkMember.CharacterInfo == null) return true;
Game1.NetworkMember.CharacterInfo.Name = newName;
if (Game1.Client != null)
{
Game1.Client.Name = newName;
Game1.Client.SendCharacterData();
}
textBox.Text = newName;
textBox.Selected = false;

View File

@@ -15,6 +15,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launch
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "Lidgren.Network\Lidgren.Network.csproj", "{49BA1C69-6104-41AC-A5D8-B54FA9F696E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{30B01820-F0C0-4C31-8BE7-804EE61DBC8A}"
ProjectSection(SolutionItems) = preProject
Performance1.psess = Performance1.psess
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Android|Any CPU = Android|Any CPU
@@ -302,4 +307,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

Binary file not shown.