Switch to Barotrauma & too many misc changes to remember

This commit is contained in:
Regalis
2015-10-16 18:11:58 +03:00
parent 2bb5d41836
commit 838022fcd5
203 changed files with 540 additions and 419 deletions

View File

@@ -2,7 +2,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
namespace Barotrauma
{
class AIController : ISteerable
{

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace Subsurface
namespace Barotrauma
{
class AITarget
{

View File

@@ -8,7 +8,7 @@ using Microsoft.Xna.Framework;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework.Graphics;
namespace Subsurface
namespace Barotrauma
{
class EnemyAIController : AIController

View File

@@ -1,6 +1,6 @@
using Microsoft.Xna.Framework;
namespace Subsurface
namespace Barotrauma
{
interface ISteerable
{

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
namespace Subsurface
namespace Barotrauma
{
class PathNode
{

View File

@@ -2,7 +2,7 @@
using Microsoft.Xna.Framework;
using FarseerPhysics.Dynamics;
namespace Subsurface
namespace Barotrauma
{
class SteeringManager
{

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace Subsurface
namespace Barotrauma
{
class SteeringPath
{

View File

@@ -1,12 +1,12 @@
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Subsurface.Networking;
using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
namespace Barotrauma
{
class AICharacter : Character
{
@@ -14,6 +14,11 @@ namespace Subsurface
private AIController aiController;
public override AIController AIController
{
get { return aiController; }
}
public AICharacter(string file) : this(file, Vector2.Zero, null)
{
}
@@ -37,7 +42,10 @@ namespace Subsurface
public AICharacter(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
: base(file, position, characterInfo, isNetworkPlayer)
{
aiController = new EnemyAIController(this, file);
aiController = new EnemyAIController(this, file);
if (GameMain.Client != null && GameMain.Server == null) Enabled = false;
}
public override void Update(Camera cam, float deltaTime)

View File

@@ -2,7 +2,7 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
namespace Subsurface
namespace Barotrauma
{
class AnimController : Ragdoll
{

View File

@@ -1,10 +1,10 @@
using Microsoft.Xna.Framework;
using Subsurface.Particles;
using Barotrauma.Particles;
using System;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
public enum DamageType { None, Blunt, Slash }

View File

@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class BackgroundSprite : ISteerable

View File

@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class BackgroundSpriteManager
{

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class BackgroundSpritePrefab
{

View File

@@ -5,15 +5,15 @@ using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Subsurface.Networking;
using Subsurface.Particles;
using Barotrauma.Networking;
using Barotrauma.Particles;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class Character : Entity, IDamageable, IPropertyObject
@@ -33,6 +33,12 @@ namespace Subsurface
set { controlled = value; }
}
public bool Enabled
{
get;
set;
}
public readonly bool IsNetworkPlayer;
private CharacterInventory inventory;
@@ -411,6 +417,8 @@ namespace Subsurface
AnimController.FindHull();
CharacterList.Add(this);
Enabled = true;
}
private static string humanConfigFile;
@@ -498,7 +506,7 @@ namespace Subsurface
public void Control(float deltaTime, Camera cam)
{
if (isDead) return;
if (isDead || AnimController.StunTimer>0.0f) return;
Vector2 targetMovement = Vector2.Zero;
if (GetInputState(InputType.Left)) targetMovement.X -= 1.0f;
@@ -741,17 +749,17 @@ namespace Subsurface
{
foreach (Character c in CharacterList)
{
if (c.isDead) continue;
if (c.isDead || !c.Enabled) continue;
c.AnimController.UpdateAnim(deltaTime);
}
}
public static void UpdateAll(Camera cam, float deltaTime)
{
if (NewCharacterQueue.Count>0)
{
new Character(NewCharacterQueue.Dequeue(), Vector2.Zero);
}
//if (NewCharacterQueue.Count>0)
//{
// new Character(NewCharacterQueue.Dequeue(), Vector2.Zero);
//}
foreach (Character c in CharacterList)
{
@@ -761,6 +769,8 @@ namespace Subsurface
public virtual void Update(Camera cam, float deltaTime)
{
if (!Enabled) return;
AnimController.SimplePhysicsEnabled = (Character.controlled!=this && Vector2.Distance(cam.WorldViewCenter, Position)>5000.0f);
if (isDead) return;
@@ -828,6 +838,8 @@ namespace Subsurface
public void Draw(SpriteBatch spriteBatch)
{
if (!Enabled) return;
AnimController.Draw(spriteBatch);
//GUI.DrawLine(spriteBatch, ConvertUnits.ToDisplayUnits(animController.limbs[0].SimPosition.X, animController.limbs[0].SimPosition.Y),
@@ -842,6 +854,8 @@ namespace Subsurface
public virtual void DrawFront(SpriteBatch spriteBatch)
{
if (!Enabled) return;
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
pos.Y = -pos.Y;
@@ -869,9 +883,6 @@ namespace Subsurface
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true);
}
public void PlaySound(AIController.AiState state)
{
if (sounds == null || !sounds.Any()) return;
@@ -931,6 +942,7 @@ namespace Subsurface
{
if (stunTimer <= 0.0f) return;
AnimController.ResetPullJoints();
AnimController.StunTimer = Math.Max(AnimController.StunTimer, stunTimer);
selectedConstruction = null;
@@ -1138,6 +1150,8 @@ namespace Subsurface
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
{
Enabled = true;
if (type == NetworkEventType.PickItem)
{
System.Diagnostics.Debug.WriteLine("**************** PickItem networkevent received");

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
namespace Barotrauma
{
class CharacterHUD
{

View File

@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
public enum Gender { None, Male, Female };

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class DelayedEffect : StatusEffect
{

View File

@@ -6,7 +6,7 @@ using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace Subsurface
namespace Barotrauma
{
class FishAnimController : AnimController
{

View File

@@ -3,9 +3,9 @@ using System.Linq;
using System.Xml.Linq;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Subsurface.Items.Components;
using Barotrauma.Items.Components;
namespace Subsurface
namespace Barotrauma
{
class HumanoidAnimController : AnimController
{
@@ -120,23 +120,24 @@ namespace Subsurface
{
onFloorTimer -= deltaTime;
}
IgnorePlatforms = (TargetMovement.Y < 0.0f);
//stun (= disable the animations) if the ragdoll receives a large enough impact
if (strongestImpact > 0.0f)
{
character.StartStun(MathHelper.Min(strongestImpact * 0.5f, 5.0f));
}
strongestImpact = 0.0f;
if (stunTimer > 0)
{
stunTimer -= deltaTime;
return;
}
IgnorePlatforms = (TargetMovement.Y < 0.0f);
if (Anim != Animation.UsingConstruction) ResetPullJoints();
if (TargetDir != dir) Flip();
@@ -228,30 +229,35 @@ namespace Subsurface
this.stepSize.Y * walkPosY * runningModifier * runningModifier);
float footMid = waist.SimPosition.X;// (leftFoot.SimPosition.X + rightFoot.SimPosition.X) / 2.0f;
int limbsInWater = 0;
foreach (Limb limb in Limbs)
if (Math.Abs(TargetMovement.X)>1.0f)
{
if (limb.inWater) limbsInWater++;
}
int limbsInWater = 0;
foreach (Limb limb in Limbs)
{
if (limb.inWater) limbsInWater++;
}
TargetMovement *= (1.0f - 0.5f * ((float)limbsInWater / (float)Limbs.Count()));
float slowdownFactor = (float)limbsInWater / (float)Limbs.Count();
TargetMovement = Vector2.Normalize(TargetMovement) * Math.Max(TargetMovement.Length() - slowdownFactor, 1.0f);
}
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
movement.Y = 0.0f;
bool legsUp = false;
for (int i = 0; i < 2; i++)
{
Limb leg = GetLimb((i == 0) ? LimbType.LeftThigh : LimbType.RightThigh);// : leftLeg;
if (leg.SimPosition.Y < torso.SimPosition.Y) continue;
leg.body.ApplyTorque(-Dir * leg.Mass * 10.0f);
leg.body.ApplyTorque(Dir * leg.Mass * 10.0f);
legsUp = true;
}
//place the anchors of the head and the torso to make the ragdoll stand
if (LowestLimb == null) return;
if (legsUp || LowestLimb == null) return;
if (!onGround || (LowestLimb.SimPosition.Y - floorY > 0.5f && stairs == null)) return;

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class Job
{

View File

@@ -4,7 +4,7 @@ using System.Globalization;
using System.Xml.Linq;
using System.Linq;
namespace Subsurface
namespace Barotrauma
{
class JobPrefab
{
@@ -20,13 +20,15 @@ namespace Subsurface
//(i.e. if one captain is required, one captain is chosen even if all the players have set captain to lowest preference)
private int minNumber;
private float commonness;
//if set to true, a client that has chosen this as their preferred job will get it no matter what
public bool AllowAlways
{
get;
private set;
}
//names of the items the character spawns with
public List<string> ItemNames;
public List<bool> EquipItem;
@@ -53,6 +55,11 @@ namespace Subsurface
get { return minNumber; }
}
public float Commonness
{
get { return commonness; }
}
public JobPrefab(XElement element)
{
name = ToolBox.GetAttributeString(element, "name", "name not found");
@@ -62,6 +69,8 @@ namespace Subsurface
minNumber = ToolBox.GetAttributeInt(element, "minnumber", 0);
maxNumber = ToolBox.GetAttributeInt(element, "maxnumber", 10);
commonness = ToolBox.GetAttributeInt(element, "commonness", 10);
AllowAlways = ToolBox.GetAttributeBool(element, "allowalways", false);
ItemNames = new List<string>();

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Subsurface
namespace Barotrauma
{
class Skill
{

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class SkillPrefab
{

View File

@@ -5,9 +5,9 @@ using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Items.Components;
using Barotrauma.Items.Components;
namespace Subsurface
namespace Barotrauma
{
public enum LimbType
{

View File

@@ -8,9 +8,9 @@ using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Subsurface.Networking;
using Barotrauma.Networking;
namespace Subsurface
namespace Barotrauma
{
class Ragdoll
{
@@ -491,8 +491,7 @@ namespace Subsurface
{
for (int i = 0; i < Limbs.Count(); i++)
{
if (Limbs[i] == null) continue;
if (Limbs[i].pullJoint == null) continue;
if (Limbs[i] == null || Limbs[i].pullJoint == null) continue;
Limbs[i].pullJoint.Enabled = false;
}
}
@@ -526,7 +525,7 @@ namespace Subsurface
Category collisionCategory = (ignorePlatforms) ?
wall | Physics.CollisionProjectile | Physics.CollisionStairs
: wall | Physics.CollisionPlatform | Physics.CollisionStairs;
: wall | Physics.CollisionProjectile | Physics.CollisionPlatform | Physics.CollisionStairs;
foreach (Limb limb in Limbs)
{
@@ -538,6 +537,8 @@ namespace Subsurface
public void Update(Camera cam, float deltaTime)
{
if (!character.Enabled) return;
UpdateNetplayerPosition();
Vector2 flowForce = Vector2.Zero;
@@ -605,7 +606,7 @@ namespace Subsurface
{
//create a splash particle
Subsurface.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash",
Barotrauma.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.Position.X, limbHull.Surface),
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 10.0f)),
0.0f);

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Subsurface
namespace Barotrauma
{
class StatusEffect
{
@@ -182,7 +182,8 @@ namespace Subsurface
ObjectProperty property;
foreach (IPropertyObject target in targets)
{
if (targetNames!=null && !targetNames.Contains(target.Name)) continue;
//if (targetNames!=null && !targetNames.Contains(target.Name)) continue;
if (!target.ObjectProperties.TryGetValue(propertyNames[i], out property)) continue;
ApplyToProperty(property, propertyEffects[i], deltaTime);