Spectating, fire, damaged limb sprites, water detector, engineer jumpsuit, new signal comp sprites, resharper cleanup (god knows what else, commit more often)

This commit is contained in:
Regalis
2015-11-10 22:22:26 +02:00
parent cd48d12be6
commit 4d949e3be1
89 changed files with 977 additions and 622 deletions
@@ -37,13 +37,13 @@ namespace Barotrauma
//the duration is determined by the attackDuration of the attacking limb
private float attackTimer;
//a "cooldown time" after an attack during which the character doesn't try to attack again
//a "cooldown time" after an attack during which the Character doesn't try to attack again
private float attackCoolDown;
private float coolDownTimer;
//a point in a wall which the character is currently targeting
//a point in a wall which the Character is currently targeting
private Vector2 wallAttackPos;
//the entity (a wall) which the character is targeting
//the entity (a wall) which the Character is targeting
private IDamageable targetEntity;
//the limb selected for the current attack
@@ -226,7 +226,7 @@ namespace Barotrauma
private void GetTargetEntity()
{
targetEntity = null;
//check if there's a wall between the target and the character
//check if there's a wall between the target and the Character
Vector2 rayStart = Character.AnimController.Limbs[0].SimPosition;
Vector2 rayEnd = selectedAiTarget.Position;
Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd);
@@ -313,7 +313,7 @@ namespace Barotrauma
}
else
{
//limb.body.ApplyTorque(limb.Mass * -20.0f * character.animController.Dir * dir);
//limb.body.ApplyTorque(limb.Mass * -20.0f * Character.animController.Dir * dir);
}
Vector2 diff = attackPosition - limb.SimPosition;
@@ -341,7 +341,7 @@ namespace Barotrauma
}
//goes through all the AItargets, evaluates how preferable it is to attack the target,
//whether the character can see/hear the target and chooses the most preferable target within
//whether the Character can see/hear the target and chooses the most preferable target within
//sight/hearing range
public void UpdateTargets(Character character)
{
@@ -370,7 +370,7 @@ namespace Barotrauma
Character targetCharacter = target.Entity as Character;
//ignore the aitarget if it is the character itself
//ignore the aitarget if it is the Character itself
if (targetCharacter == character) continue;
if (targetCharacter!=null)
@@ -381,7 +381,7 @@ namespace Barotrauma
}
else if (target.Entity!=null && attackRooms!=0.0f)
{
//skip the target if it's the room the character is inside of
//skip the target if it's the room the Character is inside of
if (character.AnimController.CurrentHull != null && character.AnimController.CurrentHull == target.Entity as Hull) continue;
valueModifier = attackRooms;
@@ -407,7 +407,7 @@ namespace Barotrauma
//if (targetCharacter != null)
//{
// //if target is a character that isn't visible, ignore
// //if target is a Character that isn't visible, ignore
// if (closestStructure != null) continue;
// //prefer targets with low health
@@ -542,11 +542,6 @@ namespace Barotrauma
AiState newState = AiState.None;
Vector2 newWallAttackPos = Vector2.Zero;
float wanderAngle;
float updateTargetsTimer, raycastTimer, coolDownTimer;
Vector2 newVelocity = Vector2.Zero;
Vector2 targetPosition = Vector2.Zero;
ushort targetID;
@@ -590,10 +585,10 @@ namespace Barotrauma
}
}
//the "memory" of the character
//the "memory" of the Character
//keeps track of how preferable it is to attack a specific target
//(if the character can't inflict much damage the target, the priority decreases
//and if the target attacks the character, the priority increases)
//(if the Character can't inflict much damage the target, the priority decreases
//and if the target attacks the Character, the priority increases)
class AITargetMemory
{
//private AITarget target;
@@ -141,7 +141,7 @@ namespace Barotrauma
if (startNode==null || endNode==null)
{
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
return new SteeringPath();;
return new SteeringPath();
}
}
@@ -17,7 +17,7 @@ namespace Barotrauma
protected float walkSpeed, swimSpeed;
//how large impacts the character can take before being stunned
//how large impacts the Character can take before being stunned
//protected float impactTolerance;
protected float stunTimer;
@@ -25,7 +25,7 @@ namespace Barotrauma
prefabs = new List<BackgroundSpritePrefab>();
XDocument doc = ToolBox.TryLoadXml(configPath);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
foreach (XElement element in doc.Root.Elements())
{
@@ -78,7 +78,7 @@ namespace Barotrauma
}
if (amount > 0)
{
Swarm swarm = new Swarm(swarmMembers, prefab.SwarmRadius);
new Swarm(swarmMembers, prefab.SwarmRadius);
}
}
}
+17 -18
View File
@@ -5,12 +5,10 @@ using FarseerPhysics.Dynamics.Joints;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Barotrauma.Networking;
using Barotrauma.Particles;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
@@ -27,7 +25,7 @@ namespace Barotrauma
public static bool DisableControls;
//the character that the player is currently controlling
//the Character that the player is currently controlling
private static Character controlled;
public static Character Controlled
@@ -43,7 +41,6 @@ namespace Barotrauma
}
public readonly bool IsNetworkPlayer;
private int importantUpdateTimer;
private CharacterInventory inventory;
@@ -116,7 +113,7 @@ namespace Barotrauma
{
get
{
return (info != null && !string.IsNullOrWhiteSpace(info.Name)) ? info.Name : SpeciesName;
return info != null && !string.IsNullOrWhiteSpace(info.Name) ? info.Name : SpeciesName;
}
}
@@ -334,7 +331,7 @@ namespace Barotrauma
Info = characterInfo==null ? new CharacterInfo(file) : characterInfo;
XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown");
@@ -516,7 +513,7 @@ namespace Barotrauma
if (IsKeyDown(InputType.Down)) targetMovement.Y -= 1.0f;
//the vertical component is only used for falling through platforms and climbing ladders when not in water,
//so the movement can't be normalized or the character would walk slower when pressing down/up
//so the movement can't be normalized or the Character would walk slower when pressing down/up
if (AnimController.InWater)
{
float length = targetMovement.Length();
@@ -693,7 +690,7 @@ namespace Barotrauma
}
/// <summary>
/// Control the character according to player input
/// Control the Character according to player input
/// </summary>
public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true)
{
@@ -753,7 +750,7 @@ namespace Barotrauma
}
//find the closest item if selectkey has been hit, or if the character is being
//find the closest item if selectkey has been hit, or if the Character is being
//controlled by the player (in order to highlight it)
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
@@ -921,13 +918,13 @@ namespace Barotrauma
aiTarget.SightRange = 0.0f;
//distance is approximated based on the mass of the character
//distance is approximated based on the mass of the Character
//(which corresponds to size because all the characters have the same limb density)
foreach (Limb limb in AnimController.Limbs)
{
aiTarget.SightRange += limb.Mass * 1000.0f;
}
//the faster the character is moving, the easier it is to see it
//the faster the Character is moving, the easier it is to see it
Limb torso = AnimController.GetLimb(LimbType.Torso);
if (torso !=null)
{
@@ -1060,6 +1057,8 @@ namespace Barotrauma
foreach (Limb limb in AnimController.Limbs)
{
limb.AddDamage(limb.SimPosition, DamageType.Blunt, 500.0f, 0.0f, false);
Vector2 diff = centerOfMass - limb.SimPosition;
if (diff == Vector2.Zero) continue;
limb.body.ApplyLinearImpulse(diff * 10.0f);
@@ -1138,7 +1137,7 @@ namespace Barotrauma
if (GameMain.NetworkMember != null)
{
//if the character is controlled by this client/server, let others know that the character has died
//if the Character is controlled by this client/server, let others know that the Character has died
if (Character.controlled == this)
{
string chatMessage = "You have " + DeathMsg[(int)causeOfDeath] + ".";
@@ -1149,12 +1148,12 @@ namespace Barotrauma
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
}
//if it's an ai character, only let the server kill it
//if it's an ai Character, only let the server kill it
else if (GameMain.Server != null && this is AICharacter)
{
new NetworkEvent(NetworkEventType.KillCharacter, ID, true, causeOfDeath);
}
//otherwise don't kill the character unless received a message about the character dying
//otherwise don't kill the Character unless received a message about the Character dying
else if (!isNetworkMessage)
{
return;
@@ -1350,9 +1349,9 @@ namespace Barotrauma
case NetworkEventType.KillCharacter:
if (GameMain.Server != null)
{
Client sender =GameMain.Server.connectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender ==null || sender.character != this)
throw new Exception("Received a KillCharacter message from someone else than the client controlling the character!");
Client sender =GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender ==null || sender.Character != this)
throw new Exception("Received a KillCharacter message from someone else than the client controlling the Character!");
}
CauseOfDeath causeOfDeath = CauseOfDeath.Damage;
@@ -1505,7 +1504,7 @@ namespace Barotrauma
catch
{
//failed to read position, character may be further than NetConfig.CharacterIgnoreDistance
//failed to read position, Character may be further than NetConfig.CharacterIgnoreDistance
pos = SimPosition;
}
@@ -45,8 +45,6 @@ namespace Barotrauma
if (character.Inventory != null) character.Inventory.DrawOwn(spriteBatch);
Color color = Color.Orange;
if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory!=null)
{
character.SelectedCharacter.Inventory.Draw(spriteBatch);
@@ -274,7 +274,7 @@ namespace Barotrauma
public virtual XElement Save(XElement parentElement)
{
XElement charElement = new XElement("character");
XElement charElement = new XElement("Character");
charElement.Add(
new XAttribute("name", Name),
@@ -178,7 +178,7 @@ namespace Barotrauma
//headMovement *= movement.Length();
//the movement angle is between direction of the head and the direction
//where the character is actually trying to go
//where the Character is actually trying to go
//current * (float)alpha + previous * (1.0f - (float)alpha);
@@ -685,7 +685,7 @@ namespace Barotrauma
leftLeg.body.ApplyTorque(Dir * -8.0f);
rightLeg.body.ApplyTorque(Dir * -8.0f);
//apply forces to the head and the torso to move the character up/down
//apply forces to the head and the torso to move the Character up/down
float movementFactor = (handPos.Y / stepHeight) * (float)Math.PI;
movementFactor = 0.8f + (float)Math.Abs(Math.Sin(movementFactor));
@@ -727,7 +727,7 @@ namespace Barotrauma
// Limb rightHand = GetLimb(LimbType.RightHand);
// Limb head = GetLimb(LimbType.Head);
// Vector2 diff = Vector2.Normalize(character.CursorPosition - RefLimb.Position);
// Vector2 diff = Vector2.Normalize(Character.CursorPosition - RefLimb.Position);
// rightHand.body.ApplyLinearImpulse(diff * 20.0f);
// head.body.ApplyLinearImpulse(diff * 5.0f);
@@ -863,8 +863,6 @@ namespace Barotrauma
transformedHoldPos += Vector2.Transform(itemPos, torsoTransform);
}
Vector2 bodyVelocity = torso.body.LinearVelocity / 60.0f;
item.body.ResetDynamics();
Vector2 currItemPos = (character.SelectedItems[0]==item) ?
@@ -29,7 +29,7 @@ namespace Barotrauma
private set;
}
//names of the items the character spawns with
//names of the items the Character spawns with
public List<string> ItemNames;
public List<bool> EquipItem;
+37 -5
View File
@@ -34,7 +34,7 @@ namespace Barotrauma
protected readonly Vector2 stepOffset;
public Sprite sprite;
public Sprite sprite, damagedSprite;
public bool inWater;
@@ -50,6 +50,8 @@ namespace Barotrauma
public readonly float impactTolerance;
private float damage;
private readonly Vector2 armorSector;
private readonly float armorValue;
@@ -142,7 +144,7 @@ namespace Barotrauma
// set
// {
// damage = Math.Max(value, 0.0f);
// if (damage >=maxHealth) character.Kill();
// if (damage >=maxHealth) Character.Kill();
// }
//}
@@ -246,7 +248,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString())
switch (subElement.Name.ToString().ToLower())
{
case "sprite":
string spritePath = subElement.Attribute("texture").Value;
@@ -260,6 +262,18 @@ namespace Barotrauma
sprite = new Sprite(subElement, "", spritePath);
break;
case "damagedsprite":
string damagedSpritePath = subElement.Attribute("texture").Value;
if (character.Info != null)
{
damagedSpritePath = damagedSpritePath.Replace("[GENDER]", (character.Info.Gender == Gender.Female) ? "f" : "");
damagedSpritePath = damagedSpritePath.Replace("[HEADID]", character.Info.HeadSpriteId.ToString());
}
damagedSprite = new Sprite(subElement, "", damagedSpritePath);
break;
case "attack":
attack = new Attack(subElement);
break;
@@ -313,10 +327,9 @@ namespace Barotrauma
damageSoundType = DamageSoundType.LimbArmor;
amount = Math.Max(0.0f, amount - totalArmorValue);
bleedingAmount = Math.Max(0.0f, bleedingAmount - totalArmorValue); ;
bleedingAmount = Math.Max(0.0f, bleedingAmount - totalArmorValue);
}
if (playSound)
{
SoundPlayer.PlayDamageSound(damageSoundType, amount, ConvertUnits.ToDisplayUnits(simPosition));
@@ -342,6 +355,9 @@ namespace Barotrauma
GameMain.ParticleManager.CreateParticle("waterblood", Position, Vector2.Zero);
}
damage += Math.Max(amount,bleedingAmount) / character.MaxHealth * 100.0f;
return new AttackResult(amount, bleedingAmount, hitArmor);
}
@@ -362,6 +378,9 @@ namespace Barotrauma
public void Update(float deltaTime)
{
if (!character.IsDead) damage = Math.Max(0.0f, damage-deltaTime*0.1f);
if (LinearVelocity.X>100.0f)
{
//DebugConsole.ThrowError("CHARACTER EXPLODED");
@@ -454,6 +473,19 @@ namespace Barotrauma
1.0f, spriteEffect, depth);
}
if (damage>0.0f && damagedSprite!=null)
{
SpriteEffects spriteEffect = (dir == Direction.Right) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
float depth = sprite.Depth - 0.0000015f;
damagedSprite.Draw(spriteBatch,
new Vector2(body.DrawPosition.X, -body.DrawPosition.Y),
color*Math.Min(damage/50.0f,1.0f), sprite.origin,
-body.DrawRotation,
1.0f, spriteEffect, depth);
}
if (!GameMain.DebugDraw) return;
if (pullJoint!=null)
+3 -3
View File
@@ -41,7 +41,7 @@ namespace Barotrauma
private Vector2 targetMovement;
//a movement vector that overrides targetmovement if trying to steer
//a character to the position sent by server in multiplayer mode
//a Character to the position sent by server in multiplayer mode
protected Vector2 correctionMovement;
protected float floorY;
@@ -616,7 +616,7 @@ namespace Barotrauma
{
//create a splash particle
Barotrauma.Particles.Particle splash = GameMain.ParticleManager.CreateParticle("watersplash",
GameMain.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.Position.X, limbHull.Surface),
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 10.0f)),
0.0f);
@@ -633,7 +633,7 @@ namespace Barotrauma
//if the character dropped into water, create a wave
//if the Character dropped into water, create a wave
if (limb.LinearVelocity.Y<0.0f)
{
//1.0 when the limb is parallel to the surface of the water
+4 -4
View File
@@ -162,9 +162,9 @@ namespace Barotrauma
}
//public virtual void Apply(ActionType type, float deltaTime, Item item, Character character = null)
//public virtual void Apply(ActionType type, float deltaTime, Item item, Character Character = null)
//{
// if (this.type == type) Apply(deltaTime, character, item);
// if (this.type == type) Apply(deltaTime, Character, item);
//}
private bool HasRequiredItems(Entity entity)
@@ -225,7 +225,7 @@ namespace Barotrauma
}
}
//protected virtual void Apply(float deltaTime, Character character, Item item)
//protected virtual void Apply(float deltaTime, Character Character, Item item)
//{
// if (explosion != null) explosion.Explode(item.SimPosition);
@@ -235,7 +235,7 @@ namespace Barotrauma
// {
// ObjectProperty property;
// if (character!=null && character.properties.TryGetValue(propertyNames[i], out property))
// if (Character!=null && Character.properties.TryGetValue(propertyNames[i], out property))
// {
// ApplyToProperty(property, propertyEffects[i], deltaTime);
// }