Character freezing + Misc fixes

This commit is contained in:
juanjp600
2016-09-21 16:46:12 -03:00
parent 3314c8501c
commit edab86f730
9 changed files with 70 additions and 9 deletions
@@ -62,6 +62,7 @@ namespace Barotrauma
public override void UpdateAnim(float deltaTime) public override void UpdateAnim(float deltaTime)
{ {
if (character.IsDead) return; if (character.IsDead) return;
if (Frozen) return;
Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition; Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition;
@@ -19,6 +19,10 @@ namespace Barotrauma
protected Hull currentHull; protected Hull currentHull;
public Limb[] Limbs; public Limb[] Limbs;
private bool isFrozen = false;
public bool Frozen = false;
private Dictionary<LimbType, Limb> limbDictionary; private Dictionary<LimbType, Limb> limbDictionary;
public RevoluteJoint[] limbJoints; public RevoluteJoint[] limbJoints;
@@ -320,7 +324,7 @@ namespace Barotrauma
public void AddLimb(Limb limb) public void AddLimb(Limb limb)
{ {
limb.body.FarseerBody.OnCollision += OnLimbCollision; limb.body.FarseerBody.OnCollision += OnLimbCollision;
Array.Resize(ref Limbs, Limbs.Length + 1); Array.Resize(ref Limbs, Limbs.Length + 1);
Limbs[Limbs.Length-1] = limb; Limbs[Limbs.Length-1] = limb;
@@ -684,6 +688,27 @@ namespace Barotrauma
{ {
if (!character.Enabled) return; if (!character.Enabled) return;
if (Frozen)
{
if (!isFrozen)
{
foreach (Limb l in Limbs)
{
l.body.PhysEnabled = false;
}
isFrozen = true;
}
return;
}
if (isFrozen)
{
for (int i=0;i < Limbs.Length;i++)
{
Limbs[i].body.PhysEnabled = true;
}
isFrozen = false;
}
UpdateNetPlayerPosition(); UpdateNetPlayerPosition();
Vector2 flowForce = Vector2.Zero; Vector2 flowForce = Vector2.Zero;
+10 -3
View File
@@ -27,7 +27,7 @@ namespace Barotrauma
get { return netStateID; } get { return netStateID; }
} }
List<char> memInput = new List<char>(); List<byte> memInput = new List<byte>();
List<float> memMouseX = new List<float>(); List<float> memMouseX = new List<float>();
List<float> memMouseY = new List<float>(); List<float> memMouseY = new List<float>();
@@ -1142,7 +1142,14 @@ namespace Barotrauma
if (isDead) return; if (isDead) return;
if (networkUpdateSent) if (this != Character.Controlled)
{
if (GameMain.Server != null)
{
}
}
/*if (networkUpdateSent)
{ {
foreach (Key key in keys) foreach (Key key in keys)
{ {
@@ -1151,7 +1158,7 @@ namespace Barotrauma
} }
networkUpdateSent = false; networkUpdateSent = false;
} }*/
DisableImpactDamageTimer -= deltaTime; DisableImpactDamageTimer -= deltaTime;
+3
View File
@@ -479,6 +479,9 @@ namespace Barotrauma
Character.Controlled.Revive(false); Character.Controlled.Revive(false);
} }
break; break;
case "freeze":
if (Character.Controlled != null) Character.Controlled.AnimController.Frozen = !Character.Controlled.AnimController.Frozen;
break;
case "freecamera": case "freecamera":
case "freecam": case "freecam":
Character.Controlled = null; Character.Controlled = null;
+2 -2
View File
@@ -461,8 +461,8 @@ namespace Barotrauma
DebugConsole.Draw(spriteBatch); DebugConsole.Draw(spriteBatch);
if (GUIComponent.MouseOn != null && !string.IsNullOrWhiteSpace(GUIComponent.MouseOn.ToolTip)) GUIComponent.MouseOn.DrawToolTip(spriteBatch); if (GUIComponent.MouseOn != null && !string.IsNullOrWhiteSpace(GUIComponent.MouseOn.ToolTip)) GUIComponent.MouseOn.DrawToolTip(spriteBatch);
cursor.Draw(spriteBatch, PlayerInput.MousePosition); cursor.Draw(spriteBatch, PlayerInput.LatestMousePosition);
} }
public static void Update(float deltaTime) public static void Update(float deltaTime)
+1
View File
@@ -295,6 +295,7 @@ namespace Barotrauma
double realDeltaTime = gameTime.ElapsedGameTime.TotalSeconds; double realDeltaTime = gameTime.ElapsedGameTime.TotalSeconds;
double deltaTime = 0.016; double deltaTime = 0.016;
updatesToMake += realDeltaTime; updatesToMake += realDeltaTime;
PlayerInput.UpdateVariable();
while (updatesToMake > 0.0) while (updatesToMake > 0.0)
{ {
@@ -136,6 +136,7 @@ namespace Barotrauma.Lights
{ {
if (Character.Controlled.ClosestItem != null) if (Character.Controlled.ClosestItem != null)
{ {
Character.Controlled.ClosestItem.IsHighlighted = true;
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true); Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
Character.Controlled.ClosestItem.IsHighlighted = true; Character.Controlled.ClosestItem.IsHighlighted = true;
} }
+11 -2
View File
@@ -118,10 +118,19 @@ namespace Barotrauma
set { dir = value; } set { dir = value; }
} }
private bool isEnabled = true;
private bool isPhysEnabled = true;
public bool Enabled public bool Enabled
{
get { return isEnabled; }
set { isEnabled = value; if (isEnabled) body.Enabled = isPhysEnabled; else body.Enabled = false; }
}
public bool PhysEnabled
{ {
get { return body.Enabled; } get { return body.Enabled; }
set { body.Enabled = value; } set { isPhysEnabled = value; if (Enabled) body.Enabled = value; }
} }
public Vector2 SimPosition public Vector2 SimPosition
@@ -350,7 +359,7 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null, float scale = 1.0f) public void Draw(SpriteBatch spriteBatch, Sprite sprite, Color color, float? depth = null, float scale = 1.0f)
{ {
if (!body.Enabled) return; if (!Enabled) return;
UpdateDrawPosition(); UpdateDrawPosition();
+15 -1
View File
@@ -204,6 +204,7 @@ namespace Barotrauma
public static class PlayerInput public static class PlayerInput
{ {
static MouseState mouseState, oldMouseState; static MouseState mouseState, oldMouseState;
static MouseState latestMouseState; //the absolute latest state, do NOT use for player interaction
static KeyboardState keyboardState, oldKeyboardState; static KeyboardState keyboardState, oldKeyboardState;
static double timeSinceClick; static double timeSinceClick;
@@ -219,6 +220,11 @@ namespace Barotrauma
get { return new Vector2(mouseState.Position.X, mouseState.Position.Y); } get { return new Vector2(mouseState.Position.X, mouseState.Position.Y); }
} }
public static Vector2 LatestMousePosition
{
get { return new Vector2(latestMouseState.Position.X, latestMouseState.Position.Y); }
}
//public static MouseState GetMouseState //public static MouseState GetMouseState
//{ //{
// get { return mouseState; } // get { return mouseState; }
@@ -334,7 +340,8 @@ namespace Barotrauma
timeSinceClick += deltaTime; timeSinceClick += deltaTime;
oldMouseState = mouseState; oldMouseState = mouseState;
mouseState = Mouse.GetState(); mouseState = latestMouseState;
UpdateVariable();
oldKeyboardState = keyboardState; oldKeyboardState = keyboardState;
keyboardState = Keyboard.GetState(); keyboardState = Keyboard.GetState();
@@ -346,5 +353,12 @@ namespace Barotrauma
timeSinceClick = 0.0; timeSinceClick = 0.0;
} }
} }
public static void UpdateVariable()
{
//do NOT use this for actual interaction with the game, this is to be used for debugging and rendering ONLY
latestMouseState = Mouse.GetState();
}
} }
} }