Player characters arent AICharacters in multiplayer, lighting optimization
This commit is contained in:
Binary file not shown.
@@ -297,19 +297,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
return Create(file, position, null);
|
return Create(file, position, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Character Create(CharacterInfo characterInfo, WayPoint spawnPoint, bool isNetworkPlayer = false)
|
public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false, bool hasAi=true)
|
||||||
{
|
|
||||||
return Create(characterInfo.File, spawnPoint.WorldPosition, characterInfo, isNetworkPlayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false)
|
|
||||||
{
|
{
|
||||||
return Create(characterInfo.File, position, characterInfo, isNetworkPlayer);
|
return Create(characterInfo.File, position, characterInfo, isNetworkPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Character Create(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
|
public static Character Create(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false, bool hasAi=true)
|
||||||
{
|
{
|
||||||
if (file != humanConfigFile)
|
if (file != humanConfigFile)
|
||||||
{
|
{
|
||||||
@@ -321,11 +315,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isNetworkPlayer)
|
if (hasAi)
|
||||||
{
|
{
|
||||||
var netCharacter = new Character(file, position, characterInfo, isNetworkPlayer);
|
return new Character(file, position, characterInfo, isNetworkPlayer);
|
||||||
|
|
||||||
return netCharacter;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ namespace Barotrauma
|
|||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
Vector2 position = (randomWayPoint == null) ? Vector2.Zero : FarseerPhysics.ConvertUnits.ToSimUnits(randomWayPoint.Position);
|
Vector2 position = (randomWayPoint == null) ? Vector2.Zero : FarseerPhysics.ConvertUnits.ToSimUnits(randomWayPoint.Position);
|
||||||
|
|
||||||
//!!!!!!!!!!!!!!!!!!
|
//!!!!!!!!!!!!!!!!!!
|
||||||
//if (spawnDeep)
|
if (spawnDeep)
|
||||||
//{
|
{
|
||||||
// position.Y = FarseerPhysics.ConvertUnits.ToSimUnits(Level.Loaded.Position.Y);
|
position.Y -= 100.0f;
|
||||||
//}
|
}
|
||||||
|
|
||||||
position.X += Rand.Range(-0.5f, 0.5f);
|
position.X += Rand.Range(-0.5f, 0.5f);
|
||||||
position.Y += Rand.Range(-0.5f, 0.5f);
|
position.Y += Rand.Range(-0.5f, 0.5f);
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ namespace Barotrauma
|
|||||||
//WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Human);
|
//WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||||
//Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition;
|
//Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition;
|
||||||
|
|
||||||
Character character = Character.Create(characterInfos[i], waypoints[i]);
|
Character character = Character.Create(characterInfos[i], waypoints[i].WorldPosition);
|
||||||
Character.Controlled = character;
|
Character.Controlled = character;
|
||||||
|
|
||||||
if (!character.Info.StartItemsGiven)
|
if (!character.Info.StartItemsGiven)
|
||||||
|
|||||||
@@ -125,6 +125,18 @@ namespace Barotrauma.Lights
|
|||||||
vertices = points;
|
vertices = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Intersects(Rectangle rect)
|
||||||
|
{
|
||||||
|
Rectangle transformedBounds = boundingBox;
|
||||||
|
if (parentEntity != null && parentEntity.Submarine != null)
|
||||||
|
{
|
||||||
|
transformedBounds.X += (int)parentEntity.Submarine.Position.X;
|
||||||
|
transformedBounds.Y += (int)parentEntity.Submarine.Position.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return transformedBounds.Intersects(rect);
|
||||||
|
}
|
||||||
|
|
||||||
private void CalculateShadowVertices(Vector2 lightSourcePos, bool los = true)
|
private void CalculateShadowVertices(Vector2 lightSourcePos, bool los = true)
|
||||||
{
|
{
|
||||||
//compute facing of each edge, using N*L
|
//compute facing of each edge, using N*L
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
foreach (ConvexHull convexHull in ConvexHull.list)
|
foreach (ConvexHull convexHull in ConvexHull.list)
|
||||||
{
|
{
|
||||||
|
if (!convexHull.Intersects(camView)) continue;
|
||||||
//if (!camView.Intersects(convexHull.BoundingBox)) continue;
|
//if (!camView.Intersects(convexHull.BoundingBox)) continue;
|
||||||
|
|
||||||
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
|
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
|
||||||
@@ -109,7 +110,7 @@ namespace Barotrauma.Lights
|
|||||||
foreach (LightSource light in lights)
|
foreach (LightSource light in lights)
|
||||||
{
|
{
|
||||||
if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
|
if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
|
||||||
//if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
|
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
|
||||||
|
|
||||||
//clear alpha to 1
|
//clear alpha to 1
|
||||||
ClearAlphaToOne(graphics, spriteBatch);
|
ClearAlphaToOne(graphics, spriteBatch);
|
||||||
@@ -121,7 +122,7 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
foreach (ConvexHull ch in light.hullsInRange)
|
foreach (ConvexHull ch in light.hullsInRange)
|
||||||
{
|
{
|
||||||
//if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
|
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
|
||||||
//draw shadow
|
//draw shadow
|
||||||
ch.DrawShadows(graphics, cam, light, shadowTransform, false);
|
ch.DrawShadows(graphics, cam, light, shadowTransform, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,8 +507,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (MapEntity e in mapEntityList)
|
for (int i = 0; i<mapEntityList.Count; i++)
|
||||||
{
|
{
|
||||||
|
MapEntity e = mapEntityList[i];
|
||||||
|
|
||||||
e.OnMapLoaded();
|
e.OnMapLoaded();
|
||||||
|
|
||||||
if (e.Submarine != null) e.Move(Submarine.HiddenSubPosition);
|
if (e.Submarine != null) e.Move(Submarine.HiddenSubPosition);
|
||||||
@@ -516,10 +518,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
mapEntityList.Sort((x, y) =>
|
//mapEntityList.Sort((x, y) =>
|
||||||
{
|
//{
|
||||||
return x.Name.CompareTo(y.Name);
|
// return x.Name.CompareTo(y.Name);
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -757,13 +757,13 @@ namespace Barotrauma.Networking
|
|||||||
for (int i = 0; i < ConnectedClients.Count; i++)
|
for (int i = 0; i < ConnectedClients.Count; i++)
|
||||||
{
|
{
|
||||||
ConnectedClients[i].Character = Character.Create(
|
ConnectedClients[i].Character = Character.Create(
|
||||||
ConnectedClients[i].characterInfo, assignedWayPoints[i], true);
|
ConnectedClients[i].characterInfo, assignedWayPoints[i].WorldPosition, true);
|
||||||
ConnectedClients[i].Character.GiveJobItems(assignedWayPoints[i]);
|
ConnectedClients[i].Character.GiveJobItems(assignedWayPoints[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (characterInfo != null)
|
if (characterInfo != null)
|
||||||
{
|
{
|
||||||
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1]);
|
myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition);
|
||||||
Character.Controlled = myCharacter;
|
Character.Controlled = myCharacter;
|
||||||
|
|
||||||
myCharacter.GiveJobItems(assignedWayPoints[assignedWayPoints.Length - 1]);
|
myCharacter.GiveJobItems(assignedWayPoints[assignedWayPoints.Length - 1]);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using FarseerPhysics;
|
using Microsoft.Xna.Framework;
|
||||||
using FarseerPhysics.Dynamics;
|
|
||||||
using FarseerPhysics.Factories;
|
|
||||||
using Microsoft.Xna.Framework;
|
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -362,7 +359,7 @@ namespace Barotrauma
|
|||||||
UpdateCharacterLists();
|
UpdateCharacterLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.Clear(Color.CornflowerBlue);
|
graphics.Clear(Color.Black);
|
||||||
|
|
||||||
//GameMain.GameScreen.DrawMap(graphics, spriteBatch);
|
//GameMain.GameScreen.DrawMap(graphics, spriteBatch);
|
||||||
|
|
||||||
@@ -370,7 +367,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Sprite backGround = GameMain.GameSession.Map.CurrentLocation.Type.Background;
|
Sprite backGround = GameMain.GameSession.Map.CurrentLocation.Type.Background;
|
||||||
spriteBatch.Draw(backGround.Texture, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero,
|
spriteBatch.Draw(backGround.Texture, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero,
|
||||||
Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Width), SpriteEffects.None, 0.0f);
|
Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Height), SpriteEffects.None, 0.0f);
|
||||||
|
|
||||||
|
|
||||||
topPanel.Draw(spriteBatch);
|
topPanel.Draw(spriteBatch);
|
||||||
|
|||||||
Reference in New Issue
Block a user