Progress on tutorial, misc bugfixes

This commit is contained in:
Regalis
2015-08-20 00:42:24 +03:00
parent e19ac600ff
commit 8c559f716f
19 changed files with 356 additions and 85 deletions
@@ -43,7 +43,7 @@ namespace Subsurface
steeringManager = new SteeringManager(this);
}
public virtual void SelectTarget(IDamageable target) { }
public virtual void SelectTarget(AITarget target) { }
public virtual void Update(float deltaTime) { }
@@ -82,11 +82,10 @@ namespace Subsurface
state = AiState.None;
}
public override void SelectTarget(IDamageable target)
public override void SelectTarget(AITarget target)
{
targetEntity = target;
selectedAiTarget = target.AiTarget;
selectedTargetMemory = FindTargetMemory(target.AiTarget);
selectedAiTarget = target;
selectedTargetMemory = FindTargetMemory(target);
targetValue = 100.0f;
}
@@ -31,7 +31,11 @@ namespace Subsurface
public float StunTimer
{
get { return stunTimer; }
set { stunTimer = value; }
set
{
if (float.IsNaN(value) || float.IsInfinity(value)) return;
stunTimer = value;
}
}
public AnimController(Character character, XElement element)
+19 -8
View File
@@ -1024,6 +1024,10 @@ namespace Subsurface
{
return;
}
else if (type== NetworkEventType.NotMoving)
{
return;
}
//if (type == Networking.NetworkEventType.KeyHit)
@@ -1057,11 +1061,11 @@ namespace Subsurface
message.Write(limb.body.Position.X);
message.Write(limb.body.Position.Y);
message.Write(limb.body.LinearVelocity.X);
message.Write(limb.body.LinearVelocity.Y);
//message.Write(limb.body.LinearVelocity.X);
//message.Write(limb.body.LinearVelocity.Y);
message.Write(limb.body.Rotation);
message.Write(limb.body.AngularVelocity);
//message.WriteRangedSingle(MathHelper.Clamp(limb.body.AngularVelocity, -10.0f, 10.0f), -10.0f, 10.0f, 8);
i++;
}
@@ -1118,6 +1122,13 @@ namespace Subsurface
}
return;
}
else if (type == NetworkEventType.NotMoving)
{
AnimController.TargetMovement = Vector2.Zero;
actionKeyDown.State = false;
secondaryKeyDown.State = false;
return;
}
bool actionKeyState = false;
bool secondaryKeyState = false;
@@ -1176,11 +1187,11 @@ namespace Subsurface
pos.X = message.ReadFloat();
pos.Y = message.ReadFloat();
vel.X = message.ReadFloat();
vel.Y = message.ReadFloat();
//vel.X = message.ReadFloat();
//vel.Y = message.ReadFloat();
rotation = message.ReadFloat();
angularVel = message.ReadFloat();
//angularVel = message.ReadFloat();
}
catch
{
@@ -1189,10 +1200,10 @@ namespace Subsurface
if (limb.body != null)
{
limb.body.TargetVelocity = vel;
limb.body.TargetVelocity = limb.body.LinearVelocity;
limb.body.TargetPosition = pos;// +vel * (float)(deltaTime / 60.0);
limb.body.TargetRotation = rotation;// +angularVel * (float)(deltaTime / 60.0);
limb.body.TargetAngularVelocity = angularVel;
limb.body.TargetAngularVelocity = limb.body.AngularVelocity;
}
}
@@ -3,6 +3,7 @@ using System.Linq;
using System.Xml.Linq;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Subsurface.Items.Components;
namespace Subsurface
{
@@ -542,7 +543,7 @@ namespace Subsurface
void UpdateClimbing()
{
if (character.SelectedConstruction == null)
if (character.SelectedConstruction == null || character.SelectedConstruction.GetComponent<Ladder>()==null)
{
Anim = Animation.None;
return;
@@ -623,7 +624,12 @@ namespace Subsurface
torso.body.ApplyForce(climbForce * 40.0f * torso.Mass);
head.body.SmoothRotate(0.0f);
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.First();
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.FirstOrDefault();
if (trigger == null)
{
character.SelectedConstruction = null;
return;
}
trigger = character.SelectedConstruction.TransformTrigger(trigger);
//stop climbing if:
+3 -3
View File
@@ -472,7 +472,7 @@ namespace Subsurface
inWater = false;
headInWater = false;
if (currentHull.Volume>currentHull.FullVolume*0.95f || ConvertUnits.ToSimUnits(currentHull.Surface)-floorY> HeadPosition*0.95f)
if (currentHull.Volume > currentHull.FullVolume * 0.95f || ConvertUnits.ToSimUnits(currentHull.Surface) - floorY > HeadPosition * 0.95f)
inWater = true;
}
@@ -562,7 +562,7 @@ namespace Subsurface
private void UpdateNetplayerPosition()
{
Limb refLimb = GetLimb(LimbType.Torso);
if (refLimb== null) refLimb = GetLimb(LimbType.Head);
if (refLimb == null) refLimb = GetLimb(LimbType.Head);
if (refLimb.body.TargetPosition == Vector2.Zero) return;
@@ -603,7 +603,7 @@ namespace Subsurface
if (resetAll)
{
System.Diagnostics.Debug.WriteLine("resetall");
System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions");
foreach (Limb limb in limbs)
{