(6c8ca4a55) Tester's build, January 20th 2020

This commit is contained in:
Juan Pablo Arce
2020-01-20 11:35:15 -03:00
parent e6a08d715b
commit 4a58987eae
47 changed files with 852 additions and 248 deletions
@@ -1233,14 +1233,14 @@ namespace Barotrauma
LatchOntoAI?.DeattachFromBody();
Character.AnimController.ReleaseStuckLimbs();
if (attacker == null || attacker.AiTarget == null) { return; }
if (State == AIState.Flee)
{
SelectTarget(attacker.AiTarget);
return;
}
if (attacker == null || attacker.AiTarget == null) { return; }
if (attackResult.Damage > 0.0f && Character.Params.AI.AttackWhenProvoked)
{
if (attacker.Submarine == Character.Submarine && canAttackCharacters ||
@@ -1370,7 +1370,7 @@ namespace Barotrauma
if (human)
{
var variant = Rand.Range(0, job.Variants, Rand.RandSync.Server);
var variant = job != null ? Rand.Range(0, job.Variants, Rand.RandSync.Server) : 0;
CharacterInfo characterInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: job, variant: variant);
spawnedCharacter = Character.Create(characterInfo, spawnPosition, ToolBox.RandomSeed(8));
if (job != null)
@@ -2,9 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Barotrauma.Extensions;
using System.Linq;
namespace Barotrauma
{
@@ -71,6 +69,7 @@ namespace Barotrauma
for (int i = 0; i < prefabsWithContainer.Count; i++)
{
var itemPrefab = prefabsWithContainer[i];
if (itemPrefab == null) { continue; }
if (SpawnItems(itemPrefab))
{
removals.Add(itemPrefab);
@@ -341,7 +341,7 @@ namespace Barotrauma.Items.Components
//ignore sensors and items
if (fixture?.Body == null || fixture.IsSensor) { return -1; }
if (fixture.Body.UserData is Item) { return -1; }
if (fixture.Body.UserData is Item item && item.GetComponent<Door>() == null) { return -1; }
if (fixture.Body?.UserData as string == "ruinroom") { return -1; }
//ignore everything else than characters, sub walls and level walls
@@ -546,6 +546,8 @@ namespace Barotrauma
private void HandleLimbCollision(Impact collision, Limb limb)
{
if (limb?.body?.FarseerBody == null || limb.character == null) { return; }
if (limb.Mass > MinImpactLimbMass)
{
Vector2 normal =
@@ -565,18 +567,18 @@ namespace Barotrauma
//find all contacts between the limb and level walls
List<Contact> levelContacts = new List<Contact>();
ContactEdge contactEdge = limb.body.FarseerBody.ContactList;
while (contactEdge != null)
while (contactEdge?.Contact != null)
{
if (contactEdge.Contact.Enabled &&
contactEdge.Other.UserData is VoronoiCell &&
contactEdge.Contact.IsTouching)
contactEdge.Contact.IsTouching &&
contactEdge.Other?.UserData is VoronoiCell)
{
levelContacts.Add(contactEdge.Contact);
}
contactEdge = contactEdge.Next;
}
if (levelContacts.Count == 0) return;
if (levelContacts.Count == 0) { return; }
//if the limb is in contact with the level, apply an artifical impact to prevent the sub from bouncing on top of it
//not a very realistic way to handle the collisions (makes it seem as if the characters were made of reinforced concrete),
@@ -59,10 +59,10 @@ namespace Barotrauma.Networking
{
shutDown = true;
readCancellationToken?.Cancel();
readCancellationToken?.Dispose();
readCancellationToken = null;
readThread?.Join(); readThread = null;
writeThread?.Join(); writeThread = null;
readCancellationToken?.Dispose();
readCancellationToken = null;
readStream?.Dispose(); readStream = null;
writeStream?.Dispose(); writeStream = null;
}
@@ -71,11 +71,11 @@ namespace Barotrauma.Networking
{
while (!shutDown)
{
Task<int> readTask = readStream.ReadAsync(tempBytes, 0, tempBytes.Length, readCancellationToken.Token);
Task<int> readTask = readStream?.ReadAsync(tempBytes, 0, tempBytes.Length, readCancellationToken.Token);
TimeSpan ts = TimeSpan.FromMilliseconds(15000);
if (!readTask.Wait(ts))
if (readTask == null || !readTask.Wait(ts))
{
readCancellationToken.Cancel();
readCancellationToken?.Cancel();
shutDown = true;
return;
}
@@ -142,8 +142,8 @@ namespace Barotrauma.Networking
byte[] lengthBytes = new byte[2];
lengthBytes[0] = (byte)(msg.Length & 0xFF);
lengthBytes[1] = (byte)((msg.Length >> 8) & 0xFF);
writeStream.Write(lengthBytes, 0, 2);
writeStream.Write(msg, 0, msg.Length);
writeStream?.Write(lengthBytes, 0, 2);
writeStream?.Write(msg, 0, msg.Length);
if (shutDown) { break; }
@@ -29,7 +29,11 @@ namespace Barotrauma.Networking
//arbitrary extra data that will be passed to the Write method of the serializable entity
//(the index of an itemcomponent for example)
protected object[] Data;
public object[] Data
{
get;
private set;
}
public bool Sent;