Character freezing + Misc fixes
This commit is contained in:
@@ -62,6 +62,7 @@ namespace Barotrauma
|
||||
public override void UpdateAnim(float deltaTime)
|
||||
{
|
||||
if (character.IsDead) return;
|
||||
if (Frozen) return;
|
||||
|
||||
Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition;
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace Barotrauma
|
||||
protected Hull currentHull;
|
||||
|
||||
public Limb[] Limbs;
|
||||
|
||||
private bool isFrozen = false;
|
||||
public bool Frozen = false;
|
||||
|
||||
private Dictionary<LimbType, Limb> limbDictionary;
|
||||
public RevoluteJoint[] limbJoints;
|
||||
|
||||
@@ -320,7 +324,7 @@ namespace Barotrauma
|
||||
public void AddLimb(Limb limb)
|
||||
{
|
||||
limb.body.FarseerBody.OnCollision += OnLimbCollision;
|
||||
|
||||
|
||||
Array.Resize(ref Limbs, Limbs.Length + 1);
|
||||
|
||||
Limbs[Limbs.Length-1] = limb;
|
||||
@@ -684,6 +688,27 @@ namespace Barotrauma
|
||||
{
|
||||
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();
|
||||
|
||||
Vector2 flowForce = Vector2.Zero;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Barotrauma
|
||||
get { return netStateID; }
|
||||
}
|
||||
|
||||
List<char> memInput = new List<char>();
|
||||
List<byte> memInput = new List<byte>();
|
||||
List<float> memMouseX = new List<float>();
|
||||
List<float> memMouseY = new List<float>();
|
||||
|
||||
@@ -1142,7 +1142,14 @@ namespace Barotrauma
|
||||
|
||||
if (isDead) return;
|
||||
|
||||
if (networkUpdateSent)
|
||||
if (this != Character.Controlled)
|
||||
{
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/*if (networkUpdateSent)
|
||||
{
|
||||
foreach (Key key in keys)
|
||||
{
|
||||
@@ -1151,7 +1158,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
networkUpdateSent = false;
|
||||
}
|
||||
}*/
|
||||
|
||||
DisableImpactDamageTimer -= deltaTime;
|
||||
|
||||
|
||||
@@ -479,6 +479,9 @@ namespace Barotrauma
|
||||
Character.Controlled.Revive(false);
|
||||
}
|
||||
break;
|
||||
case "freeze":
|
||||
if (Character.Controlled != null) Character.Controlled.AnimController.Frozen = !Character.Controlled.AnimController.Frozen;
|
||||
break;
|
||||
case "freecamera":
|
||||
case "freecam":
|
||||
Character.Controlled = null;
|
||||
|
||||
@@ -461,8 +461,8 @@ namespace Barotrauma
|
||||
DebugConsole.Draw(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)
|
||||
|
||||
@@ -295,6 +295,7 @@ namespace Barotrauma
|
||||
double realDeltaTime = gameTime.ElapsedGameTime.TotalSeconds;
|
||||
double deltaTime = 0.016;
|
||||
updatesToMake += realDeltaTime;
|
||||
PlayerInput.UpdateVariable();
|
||||
|
||||
while (updatesToMake > 0.0)
|
||||
{
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (Character.Controlled.ClosestItem != null)
|
||||
{
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
}
|
||||
|
||||
@@ -118,10 +118,19 @@ namespace Barotrauma
|
||||
set { dir = value; }
|
||||
}
|
||||
|
||||
private bool isEnabled = true;
|
||||
private bool isPhysEnabled = true;
|
||||
|
||||
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; }
|
||||
set { body.Enabled = value; }
|
||||
set { isPhysEnabled = value; if (Enabled) body.Enabled = value; }
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!body.Enabled) return;
|
||||
if (!Enabled) return;
|
||||
|
||||
UpdateDrawPosition();
|
||||
|
||||
|
||||
@@ -204,6 +204,7 @@ namespace Barotrauma
|
||||
public static class PlayerInput
|
||||
{
|
||||
static MouseState mouseState, oldMouseState;
|
||||
static MouseState latestMouseState; //the absolute latest state, do NOT use for player interaction
|
||||
static KeyboardState keyboardState, oldKeyboardState;
|
||||
|
||||
static double timeSinceClick;
|
||||
@@ -219,6 +220,11 @@ namespace Barotrauma
|
||||
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
|
||||
//{
|
||||
// get { return mouseState; }
|
||||
@@ -334,7 +340,8 @@ namespace Barotrauma
|
||||
timeSinceClick += deltaTime;
|
||||
|
||||
oldMouseState = mouseState;
|
||||
mouseState = Mouse.GetState();
|
||||
mouseState = latestMouseState;
|
||||
UpdateVariable();
|
||||
|
||||
oldKeyboardState = keyboardState;
|
||||
keyboardState = Keyboard.GetState();
|
||||
@@ -346,5 +353,12 @@ namespace Barotrauma
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user