Setting ragdoll position without limbs going through walls, rotating entire ragdoll, using combined network messages client->server, fixed fabricators
This commit is contained in:
@@ -69,7 +69,10 @@ namespace Barotrauma
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message) { }
|
||||
public virtual void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
||||
{
|
||||
data = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find an entity based on the ID
|
||||
|
||||
@@ -479,8 +479,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message, out object data)
|
||||
{
|
||||
data = null;
|
||||
|
||||
float newVolume = this.volume;
|
||||
|
||||
try
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Barotrauma
|
||||
return new Level(seed, Rand.Range(30.0f,80.0f,false), 100000, 40000, 2000);
|
||||
}
|
||||
|
||||
public void Generate(float minWidth, bool mirror=false)
|
||||
public void Generate(bool mirror=false)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
@@ -230,6 +230,8 @@ namespace Barotrauma
|
||||
Debug.WriteLine("find cells: " + sw2.ElapsedMilliseconds + " ms");
|
||||
sw2.Restart();
|
||||
|
||||
float minWidth = Submarine.Loaded == null ? 3000.0f : Math.Max(Submarine.Borders.Width, Submarine.Borders.Height);
|
||||
|
||||
//generate a path from the left edge of the map to right edge
|
||||
Rectangle pathBorders = new Rectangle(
|
||||
borders.X + (int)minWidth * 2, borders.Y + (int)minWidth * 2,
|
||||
@@ -775,7 +777,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Item item in Item.itemList)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.body==null || item.CurrentHull != null) continue;
|
||||
item.body.LinearVelocity += simVelocity;
|
||||
@@ -815,7 +817,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Item item in Item.itemList)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.body == null || item.CurrentHull != null) continue;
|
||||
item.body.LinearVelocity -= prevVelocity;
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public static void UpdateAll(Camera cam, float deltaTime)
|
||||
{
|
||||
foreach (Item item in Item.itemList)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
item.Updated = false;
|
||||
}
|
||||
@@ -214,36 +214,12 @@ namespace Barotrauma
|
||||
gap.Update(cam, deltaTime);
|
||||
}
|
||||
|
||||
foreach (Item item in Item.itemList)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
item.Update(cam, deltaTime);
|
||||
}
|
||||
|
||||
//Stopwatch sw = new Stopwatch();
|
||||
|
||||
//for (int i = 0; i < mapEntityList.Count; i++)
|
||||
//{
|
||||
// sw.Restart();
|
||||
// mapEntityList[i].Update(cam, deltaTime);
|
||||
// sw.Stop();
|
||||
|
||||
// if (timeElapsed.ContainsKey(mapEntityList[i].Name))
|
||||
// {
|
||||
// float asd = 0.0f;
|
||||
// timeElapsed.TryGetValue(mapEntityList[i].Name, out asd);
|
||||
// asd += sw.ElapsedTicks;
|
||||
|
||||
// timeElapsed.Remove(mapEntityList[i].Name);
|
||||
// timeElapsed.Add(mapEntityList[i].Name, asd);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// timeElapsed.Add(mapEntityList[i].Name, sw.ElapsedTicks);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
Item.Spawner.Update();
|
||||
}
|
||||
|
||||
public virtual void Update(Camera cam, float deltaTime) { }
|
||||
|
||||
@@ -449,6 +449,8 @@ namespace Barotrauma
|
||||
if (Submarine.Loaded != null && Submarine.Loaded.GodMode) return;
|
||||
if (!prefab.HasBody) return;
|
||||
|
||||
if (!MathUtils.IsValid(damage)) return;
|
||||
|
||||
if (damage != sections[sectionIndex].damage && Math.Abs(sections[sectionIndex].lastSentDamage - damage)>5.0f)
|
||||
{
|
||||
new NetworkEvent(NetworkEventType.WallDamage, ID, false);
|
||||
@@ -640,9 +642,16 @@ namespace Barotrauma
|
||||
{
|
||||
message.Write((float)NetTime.Now);
|
||||
|
||||
for (int i = 0; i < sections.Length; i++)
|
||||
var updateSections = Array.FindAll(sections, s => s != null && Math.Abs(s.damage - s.lastSentDamage)/Health > 0.01f);
|
||||
|
||||
if (updateSections.Length == 0) return false;
|
||||
|
||||
Debug.Assert(updateSections.Length<255);
|
||||
|
||||
message.Write((byte)updateSections.Length);
|
||||
|
||||
for (int i = 0; i < updateSections.Length; i++)
|
||||
{
|
||||
if (Math.Abs(sections[i].damage - sections[i].lastSentDamage) < 0.1f) continue;
|
||||
message.Write((byte)i);
|
||||
message.WriteRangedSingle(sections[i].damage / Health, 0.0f, 1.0f, 8);
|
||||
|
||||
@@ -652,16 +661,22 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message, out object data)
|
||||
{
|
||||
data = null;
|
||||
|
||||
float updateTime = message.ReadFloat();
|
||||
if (updateTime < lastUpdate) return;
|
||||
|
||||
while (message.Position <= message.LengthBits-8)
|
||||
int sectionCount = message.ReadByte();
|
||||
|
||||
for (int i = 0; i<sectionCount; i++)
|
||||
{
|
||||
byte sectionIndex = message.ReadByte();
|
||||
float damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health;
|
||||
|
||||
if (sectionIndex < 0 || sectionIndex >= sections.Length) continue;
|
||||
|
||||
SetDamage(sectionIndex, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +254,6 @@ namespace Barotrauma
|
||||
|
||||
public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List<Body> ignoredBodies = null, Category? collisionCategory = null)
|
||||
{
|
||||
|
||||
|
||||
float closestFraction = 1.0f;
|
||||
Body closestBody = null;
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
@@ -302,7 +300,8 @@ namespace Barotrauma
|
||||
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
if (fixture == null || fixture.CollisionCategories != Physics.CollisionWall) return -1;
|
||||
if (fixture == null ||
|
||||
(fixture.CollisionCategories != Physics.CollisionWall && fixture.CollisionCategories != Physics.CollisionLevel)) return -1;
|
||||
|
||||
Structure structure = fixture.Body.UserData as Structure;
|
||||
if (structure != null)
|
||||
@@ -397,8 +396,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message)
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, NetIncomingMessage message, out object data)
|
||||
{
|
||||
data = null;
|
||||
|
||||
float sendingTime;
|
||||
Vector2 newTargetPosition, newSpeed;
|
||||
try
|
||||
@@ -630,7 +631,7 @@ namespace Barotrauma
|
||||
|
||||
MapEntity.MapLoaded();
|
||||
|
||||
foreach (Item item in Item.itemList)
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
foreach (ItemComponent ic in item.components)
|
||||
{
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace Barotrauma
|
||||
public WaterRenderer(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
#if WINDOWS
|
||||
byte[] bytecode = File.ReadAllBytes("Content/watershader.mgfx");
|
||||
byte[] bytecode = File.ReadAllBytes("Content/watershader.mgfx");
|
||||
#endif
|
||||
#if LINUX
|
||||
byte[] bytecode = File.ReadAllBytes("Content/effects_linux.mgfx");
|
||||
byte[] bytecode = File.ReadAllBytes("Content/watershader_opengl.mgfx");
|
||||
#endif
|
||||
|
||||
waterEffect = new Effect(graphicsDevice, bytecode);
|
||||
@@ -34,10 +34,15 @@ namespace Barotrauma
|
||||
waterTexture = TextureLoader.FromFile("Content/waterbump.png");
|
||||
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
|
||||
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
|
||||
|
||||
#if WINDOWS
|
||||
waterEffect.Parameters["xTexture"].SetValue(waterTexture);
|
||||
#endif
|
||||
#if LINUX
|
||||
waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);
|
||||
#endif
|
||||
|
||||
if (basicEffect==null)
|
||||
{
|
||||
if (basicEffect == null)
|
||||
{
|
||||
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
|
||||
basicEffect.VertexColorEnabled = false;
|
||||
|
||||
@@ -45,12 +50,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBack (SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f)
|
||||
{
|
||||
public void RenderBack(SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
|
||||
|
||||
waterEffect.CurrentTechnique = waterEffect.Techniques["WaterShader"];
|
||||
waterEffect.Parameters["xTexture"].SetValue(texture);
|
||||
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
|
||||
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
|
||||
waterEffect.CurrentTechnique.Passes[0].Apply();
|
||||
@@ -58,7 +62,13 @@ namespace Barotrauma
|
||||
wavePos.X += 0.0001f;
|
||||
wavePos.Y += 0.0001f;
|
||||
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0,0,GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
#if WINDOWS
|
||||
waterEffect.Parameters["xTexture"].SetValue(texture);
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
#elif LINUX
|
||||
|
||||
spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
#endif
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
@@ -73,7 +83,7 @@ namespace Barotrauma
|
||||
basicEffect.View = Matrix.Identity;
|
||||
basicEffect.World = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
|
||||
@@ -89,7 +99,7 @@ namespace Barotrauma
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing) return;
|
||||
|
||||
|
||||
if (waterEffect != null)
|
||||
{
|
||||
waterEffect.Dispose();
|
||||
@@ -100,7 +110,7 @@ namespace Barotrauma
|
||||
{
|
||||
basicEffect.Dispose();
|
||||
basicEffect = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user