WIP CrashReporter, misc refactoring

This commit is contained in:
Regalis
2015-09-19 15:14:47 +03:00
parent 16bf562837
commit f6966f06c3
86 changed files with 1616 additions and 631 deletions
+4 -4
View File
@@ -119,7 +119,7 @@ namespace Subsurface.Items.Components
(int)doorSprite.size.X,
(int)doorSprite.size.Y);
body = new PhysicsBody(BodyFactory.CreateRectangle(Game1.World,
body = new PhysicsBody(BodyFactory.CreateRectangle(GameMain.World,
ConvertUnits.ToSimUnits(Math.Max(doorRect.Width, 1)),
ConvertUnits.ToSimUnits(Math.Max(doorRect.Height, 1)),
1.5f));
@@ -282,8 +282,8 @@ namespace Subsurface.Items.Components
foreach (Character c in Character.CharacterList)
{
int dir = Math.Sign(c.AnimController.limbs[0].SimPosition.X - simPos.X);
foreach (Limb l in c.AnimController.limbs)
int dir = Math.Sign(c.AnimController.Limbs[0].SimPosition.X - simPos.X);
foreach (Limb l in c.AnimController.Limbs)
{
if (l.SimPosition.Y < simPos.Y || l.SimPosition.Y > simPos.Y - simSize.Y) continue;
if (Math.Abs(l.SimPosition.X - simPos.X) > simSize.X * 2.0f) continue;
@@ -299,7 +299,7 @@ namespace Subsurface.Items.Components
{
base.Remove();
Game1.World.RemoveBody(body.FarseerBody);
GameMain.World.RemoveBody(body.FarseerBody);
if (linkedGap!=null) linkedGap.Remove();
@@ -101,7 +101,7 @@ namespace Subsurface.Items.Components
Msg = "";
}
if (attachedByDefault || Screen.Selected == Game1.EditMapScreen) Use(1.0f);
if (attachedByDefault || Screen.Selected == GameMain.EditMapScreen) Use(1.0f);
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
@@ -51,7 +51,7 @@ namespace Subsurface.Items.Components
item.body.FarseerBody.CollidesWith = Physics.CollisionCharacter | Physics.CollisionWall;
item.body.FarseerBody.OnCollision += OnCollision;
foreach (Limb l in character.AnimController.limbs)
foreach (Limb l in character.AnimController.Limbs)
{
item.body.FarseerBody.IgnoreCollisionWith(l.body.FarseerBody);
@@ -153,7 +153,7 @@ namespace Subsurface.Items.Components
item.body.CollisionCategories = Physics.CollisionMisc;
item.body.CollidesWith = Physics.CollisionWall;
foreach (Limb l in picker.AnimController.limbs)
foreach (Limb l in picker.AnimController.Limbs)
{
item.body.FarseerBody.RestoreCollisionWith(l.body.FarseerBody);
}
@@ -60,7 +60,7 @@ namespace Subsurface.Items.Components
bool failed = DoesUseFail(character);
List<Body> limbBodies = new List<Body>();
foreach (Limb l in character.AnimController.limbs)
foreach (Limb l in character.AnimController.Limbs)
{
limbBodies.Add(l.body.FarseerBody);
}
@@ -116,7 +116,7 @@ namespace Subsurface.Items.Components
(float)Math.Sin(item.body.Rotation)) * range * item.body.Dir;
List<Body> ignoredBodies = new List<Body>();
foreach (Limb limb in character.AnimController.limbs)
foreach (Limb limb in character.AnimController.Limbs)
{
ignoredBodies.Add(limb.body.FarseerBody);
}
@@ -200,7 +200,7 @@ namespace Subsurface.Items.Components
if (!string.IsNullOrWhiteSpace(particles))
{
Game1.ParticleManager.CreateParticle(particles, ConvertUnits.ToDisplayUnits(TransformedBarrelPos),
GameMain.ParticleManager.CreateParticle(particles, ConvertUnits.ToDisplayUnits(TransformedBarrelPos),
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), 0.0f);
}
@@ -196,10 +196,10 @@ namespace Subsurface.Items.Components
break;
case "guiframe":
Vector4 rect = ToolBox.GetAttributeVector4(subElement, "rect", Vector4.One);
rect.X *= Game1.GraphicsWidth;
rect.Y *= Game1.GraphicsHeight;
rect.Z *= Game1.GraphicsWidth;
rect.W *= Game1.GraphicsHeight;
rect.X *= GameMain.GraphicsWidth;
rect.Y *= GameMain.GraphicsHeight;
rect.Z *= GameMain.GraphicsWidth;
rect.W *= GameMain.GraphicsHeight;
Vector4 color = ToolBox.GetAttributeVector4(subElement, "color", Vector4.One);
@@ -72,7 +72,7 @@ namespace Subsurface.Items.Components
for (int i = 0; i < 5; i++)
{
Game1.ParticleManager.CreateParticle("bubbles", item.Position,
GameMain.ParticleManager.CreateParticle("bubbles", item.Position,
-currForce/5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)));
}
}
@@ -74,7 +74,7 @@ namespace Subsurface.Items.Components
}
int width = 400, height = 300;
itemList = new GUIListBox(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, Game1.GraphicsHeight / 2 - height / 2, width, height), Color.White * 0.7f);
itemList = new GUIListBox(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), Color.White * 0.7f);
itemList.OnSelected = SelectItem;
//structureList.CheckSelected = MapEntityPrefab.GetSelected;
@@ -110,7 +110,7 @@ namespace Subsurface.Items.Components
if (targetItem == null) return false;
int width = 200, height = 150;
selectedItemFrame = new GUIFrame(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, itemList.Rect.Bottom+20, width, height), Color.Black*0.8f);
selectedItemFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, itemList.Rect.Bottom+20, width, height), Color.Black*0.8f);
//selectedItemFrame.Padding = GUI.style.smallPadding;
if (targetItem.TargetItem.sprite != null)
@@ -150,20 +150,20 @@ namespace Subsurface.Items.Components
screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X);
}
if (Game1.GameSession == null) return;
if (GameMain.GameSession == null) return;
DrawMarker(spriteBatch,
(Game1.GameSession.Map == null) ? "Start" : Game1.GameSession.Map.CurrentLocation.Name,
(GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
(Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
DrawMarker(spriteBatch,
(Game1.GameSession.Map == null) ? "End" : Game1.GameSession.Map.SelectedLocation.Name,
(GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
(Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f));
if (Game1.GameSession.Quest != null)
if (GameMain.GameSession.Quest != null)
{
var quest = Game1.GameSession.Quest;
var quest = GameMain.GameSession.Quest;
if (!string.IsNullOrWhiteSpace(quest.RadarLabel))
{
@@ -184,8 +184,8 @@ namespace Subsurface.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
int width = 300, height = 200;
int x = Game1.GraphicsWidth / 2 - width / 2;
int y = Game1.GraphicsHeight / 2 - height / 2;
int x = GameMain.GraphicsWidth / 2 - width / 2;
int y = GameMain.GraphicsHeight / 2 - height / 2;
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
@@ -65,7 +65,7 @@ namespace Subsurface.Items.Components
Vector2 baseVel = Rand.Vector(300.0f);
for (int i = 0; i < 10; i++)
{
var particle = Game1.ParticleManager.CreateParticle("spark", pt.item.Position,
var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position,
baseVel + Rand.Vector(100.0f), 0.0f);
if (particle != null) particle.Size *= Rand.Range(0.5f,1.0f);
@@ -106,7 +106,7 @@ namespace Subsurface.Items.Components
if (stickJoint != null && doesStick)
{
if (stickTarget!=null) item.body.FarseerBody.RestoreCollisionWith(stickTarget);
Game1.World.RemoveJoint(stickJoint);
GameMain.World.RemoveJoint(stickJoint);
stickJoint = null;
}
}
@@ -122,7 +122,7 @@ namespace Subsurface.Items.Components
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
Game1.World.RemoveJoint(stickJoint);
GameMain.World.RemoveJoint(stickJoint);
stickJoint = null;
isActive = false;
@@ -209,7 +209,7 @@ namespace Subsurface.Items.Components
item.body.FarseerBody.IgnoreCollisionWith(targetBody);
stickTarget = targetBody;
Game1.World.AddJoint(stickJoint);
GameMain.World.AddJoint(stickJoint);
isActive = true;
+7 -7
View File
@@ -90,7 +90,7 @@ namespace Subsurface.Items.Components
Vertices box = PolygonTools.CreateRectangle(sectionLength, 0.05f);
PolygonShape shape = new PolygonShape(box, 5);
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(Game1.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(GameMain.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
ropeBodies = new PhysicsBody[ropeList.Count()];
for (int i = 0; i<ropeBodies.Length; i++)
@@ -104,14 +104,14 @@ namespace Subsurface.Items.Components
ropeBodies[i] = new PhysicsBody(ropeList[i]);
}
List<RevoluteJoint> joints = PathManager.AttachBodiesWithRevoluteJoint(Game1.World, ropeList,
List<RevoluteJoint> joints = PathManager.AttachBodiesWithRevoluteJoint(GameMain.World, ropeList,
new Vector2(-sectionLength/2, 0.0f), new Vector2(sectionLength/2, 0.0f), false, false);
ropeJoints = new RevoluteJoint[joints.Count+1];
//ropeJoints[0] = JointFactory.CreateRevoluteJoint(Game1.world, item.body, ropeList[0], new Vector2(0f, -0.0f));
for (int i = 0; i < joints.Count; i++)
{
var distanceJoint = JointFactory.CreateDistanceJoint(Game1.World, ropeList[i], ropeList[i + 1]);
var distanceJoint = JointFactory.CreateDistanceJoint(GameMain.World, ropeList[i], ropeList[i + 1]);
distanceJoint.Length = sectionLength;
distanceJoint.DampingRatio = 1.0f;
@@ -299,8 +299,8 @@ namespace Subsurface.Items.Components
ropeBodies[ropeBodies.Length - 1].SetTransform(projectile.body.SimPosition, projectile.body.Rotation);
//attach projectile to the last section of the rope
if (ropeJoints[ropeJoints.Length-1] != null) Game1.World.RemoveJoint(ropeJoints[ropeJoints.Length-1]);
ropeJoints[ropeJoints.Length - 1] = JointFactory.CreateRevoluteJoint(Game1.World,
if (ropeJoints[ropeJoints.Length-1] != null) GameMain.World.RemoveJoint(ropeJoints[ropeJoints.Length-1]);
ropeJoints[ropeJoints.Length - 1] = JointFactory.CreateRevoluteJoint(GameMain.World,
projectile.body.FarseerBody, ropeBodies[ropeBodies.Length - 1].FarseerBody,
projectileAnchor, new Vector2(sectionLength / 2, 0.0f));
@@ -315,7 +315,7 @@ namespace Subsurface.Items.Components
body.SetTransform(TransformedBarrelPos, rotation);
//Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
if (gunJoint != null) Game1.World.RemoveJoint(gunJoint);
if (gunJoint != null) GameMain.World.RemoveJoint(gunJoint);
gunJoint = new DistanceJoint(item.body.FarseerBody, body, BarrelPos,
new Vector2(sectionLength / 2, 0.0f));
@@ -328,7 +328,7 @@ namespace Subsurface.Items.Components
//gunJoint.LimitEnabled = true;
//gunJoint.ReferenceAngle = 0.0f;
Game1.World.AddJoint(gunJoint);
GameMain.World.AddJoint(gunJoint);
}
}
@@ -172,7 +172,7 @@ namespace Subsurface.Items.Components
{
int width = 400, height = 200;
int x = Game1.GraphicsWidth/2 - width/2, y = Game1.GraphicsHeight - height;
int x = GameMain.GraphicsWidth/2 - width/2, y = GameMain.GraphicsHeight - height;
Rectangle panelRect = new Rectangle(x, y, width, height);
@@ -290,7 +290,7 @@ namespace Subsurface.Items.Components
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 3, (int)-Nodes[i].Y - 3, 6, 6), Color.Red, true, 0.0f);
if (GUIComponent.MouseOn == null &&
Vector2.Distance(Game1.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) < 20.0f)
Vector2.Distance(GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Nodes[i]) < 20.0f)
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)Nodes[i].X - 10, (int)-Nodes[i].Y - 10, 20, 20), Color.Red, false, 0.0f);
@@ -315,7 +315,7 @@ namespace Subsurface.Items.Components
if (selectedNodeIndex!=null && item.IsSelected)
{
MapEntity.DisableSelect = true;
Nodes[(int)selectedNodeIndex] = Game1.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
Vector2 pos = Nodes[(int)selectedNodeIndex];