END WORM, fixed camera pos "twitching" when exiting/entering the sub, character scaling

This commit is contained in:
Regalis
2015-12-19 02:05:10 +02:00
parent eb0e08c8ee
commit 4234aa2094
16 changed files with 144 additions and 28 deletions
+5 -1
View File
@@ -117,7 +117,11 @@ namespace Barotrauma
public Vector2 TargetPos
{
get { return targetPos; }
set { targetPos = value; }
set {
targetPos = value;
System.Diagnostics.Debug.WriteLine(value);
}
}
// Auxiliary function to move the camera
@@ -29,6 +29,7 @@ namespace Barotrauma
protected override void Act(float deltaTime)
{
if (character.AnimController.CurrentHull == null) return;
currenthullSafety = OverrideCurrentHullSafety == null ?
GetHullSafety(character.AnimController.CurrentHull) : (float)OverrideCurrentHullSafety;
@@ -36,7 +37,6 @@ namespace Barotrauma
if (character.AnimController.CurrentHull == null || currenthullSafety > MinSafety)
{
character.AIController.SteeringManager.SteeringSeek(character.AnimController.CurrentHull.SimPosition);
character.AIController.SelectTarget(null);
goToObjective = null;
+1 -1
View File
@@ -42,7 +42,7 @@ namespace Barotrauma
public AICharacter(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
: base(file, position, characterInfo, isNetworkPlayer)
{
soundInterval = Rand.Range(0.0f, soundInterval);
soundTimer = Rand.Range(0.0f, soundInterval);
}
public void SetAI(AIController aiController)
@@ -196,6 +196,8 @@ namespace Barotrauma
this.character = character;
dir = Direction.Right;
float scale = ToolBox.GetAttributeFloat(element, "scale", 1.0f);
//int limbAmount = ;
Limbs = new Limb[element.Elements("limb").Count()];
@@ -217,7 +219,7 @@ namespace Barotrauma
case "limb":
byte ID = Convert.ToByte(subElement.Attribute("id").Value);
Limb limb = new Limb(character, subElement);
Limb limb = new Limb(character, subElement, scale);
limb.body.FarseerBody.OnCollision += OnLimbCollision;
@@ -229,10 +231,10 @@ namespace Barotrauma
Byte limb1ID = Convert.ToByte(subElement.Attribute("limb1").Value);
Byte limb2ID = Convert.ToByte(subElement.Attribute("limb2").Value);
Vector2 limb1Pos = ToolBox.GetAttributeVector2(subElement, "limb1anchor", Vector2.Zero);
Vector2 limb1Pos = ToolBox.GetAttributeVector2(subElement, "limb1anchor", Vector2.Zero) * scale;
limb1Pos = ConvertUnits.ToSimUnits(limb1Pos);
Vector2 limb2Pos = ToolBox.GetAttributeVector2(subElement, "limb2anchor", Vector2.Zero);
Vector2 limb2Pos = ToolBox.GetAttributeVector2(subElement, "limb2anchor", Vector2.Zero) * scale;
limb2Pos = ConvertUnits.ToSimUnits(limb2Pos);
RevoluteJoint joint = new RevoluteJoint(Limbs[limb1ID].body.FarseerBody, Limbs[limb2ID].body.FarseerBody, limb1Pos, limb2Pos);
@@ -296,6 +298,8 @@ namespace Barotrauma
public bool OnLimbCollision(Fixture f1, Fixture f2, Contact contact)
{
Structure structure = f2.Body.UserData as Structure;
if (f2.Body.UserData as SubmarineBody != null) return true;
//always collides with bodies other than structures
if (structure == null)
+10 -2
View File
@@ -869,8 +869,16 @@ namespace Barotrauma
Submarine = AnimController.CurrentHull == null ? null : Submarine.Loaded;
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
AnimController.SimplePhysicsEnabled = (Character.controlled != this && Vector2.Distance(cam.WorldViewCenter, WorldPosition) > 5000.0f);
float dist = Vector2.Distance(cam.WorldViewCenter, WorldPosition);
if (dist > 8000.0f)
{
AnimController.SimplePhysicsEnabled = true;
}
else if (dist < 7000.0f)
{
AnimController.SimplePhysicsEnabled = false;
}
if (isDead) return;
+10 -6
View File
@@ -149,6 +149,8 @@ namespace Barotrauma
set { burnt = MathHelper.Clamp(value,0.0f,100.0f); }
}
private float scale;
//public float Damage
//{
// get { return damage; }
@@ -182,7 +184,7 @@ namespace Barotrauma
set { wearingItemSprite = value; }
}
public Limb (Character character, XElement element)
public Limb (Character character, XElement element, float scale = 1.0f)
{
this.character = character;
@@ -190,7 +192,9 @@ namespace Barotrauma
doesFlip = ToolBox.GetAttributeBool(element, "flip", false);
body = new PhysicsBody(element);
this.scale = scale;
body = new PhysicsBody(element, scale);
if (ToolBox.GetAttributeBool(element, "ignorecollisions", false))
{
@@ -225,10 +229,10 @@ namespace Barotrauma
}
Vector2 jointPos = ToolBox.GetAttributeVector2(element, "pullpos", Vector2.Zero);
Vector2 jointPos = ToolBox.GetAttributeVector2(element, "pullpos", Vector2.Zero) * scale;
jointPos = ConvertUnits.ToSimUnits(jointPos);
stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.Zero);
stepOffset = ToolBox.GetAttributeVector2(element, "stepoffset", Vector2.Zero) * scale;
stepOffset = ConvertUnits.ToSimUnits(stepOffset);
refJointIndex = ToolBox.GetAttributeInt(element, "refjoint", -1);
@@ -455,7 +459,7 @@ namespace Barotrauma
if (wearingItem == null || !wearingItemSprite.HideLimb)
{
body.Draw(spriteBatch, sprite, color);
body.Draw(spriteBatch, sprite, color, null, scale);
}
else
{
@@ -484,7 +488,7 @@ namespace Barotrauma
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color, origin,
-body.DrawRotation,
1.0f, spriteEffect, depth);
scale, spriteEffect, depth);
}
if (damage>0.0f && damagedSprite!=null)
+8 -8
View File
@@ -178,8 +178,8 @@ namespace Barotrauma
set { body.CollidesWith = value; }
}
public PhysicsBody(XElement element)
: this(element, Vector2.Zero)
public PhysicsBody(XElement element, float scale = 1.0f)
: this(element, Vector2.Zero, scale)
{
}
@@ -194,11 +194,11 @@ namespace Barotrauma
list.Add(this);
}
public PhysicsBody(XElement element, Vector2 position)
public PhysicsBody(XElement element, Vector2 position, float scale=1.0f)
{
float radius = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "radius", 0.0f));
float height = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "height", 0.0f));
float width = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "width", 0.0f));
float radius = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "radius", 0.0f)) * scale;
float height = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "height", 0.0f)) * scale;
float width = ConvertUnits.ToSimUnits(ToolBox.GetAttributeFloat(element, "width", 0.0f)) * scale;
density = ToolBox.GetAttributeFloat(element, "density", 10.0f);
@@ -307,7 +307,7 @@ namespace Barotrauma
drawRotation = Physics.Interpolate(prevRotation, body.Rotation);
}
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null)
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null, float scale = 1.0f)
{
if (!body.Enabled) return;
@@ -320,7 +320,7 @@ namespace Barotrauma
color = Color.Blue;
}
sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, -drawRotation, 1.0f, spriteEffect, depth);
sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, -drawRotation, scale, spriteEffect, depth);
}
+5 -5
View File
@@ -74,7 +74,7 @@ namespace Barotrauma
if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
GameMain.GameSession.Submarine.ApplyForce(targetMovement * 1000000.0f);
GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f);
}
#endif
@@ -134,10 +134,10 @@ namespace Barotrauma
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{
if (Character.Controlled != null)
{
cam.TargetPos = Character.Controlled.WorldPosition;
}
//if (Character.Controlled != null)
//{
// cam.TargetPos = Character.Controlled.WorldPosition;
//}
cam.UpdateTransform();
+1 -1
View File
@@ -228,7 +228,7 @@ namespace Barotrauma
}
List<BackgroundMusic> suitableMusic = null;
if (Submarine.Loaded!=null && Submarine.Loaded.Position.Y<0.0f)
if (Submarine.Loaded!=null && Submarine.Loaded.Position.Y<SubmarineBody.DamageDepth+10000.0f)
{
suitableMusic = musicClips.Where(x => x != null && x.type == "deep").ToList();
}