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
@@ -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)