Setting ragdoll position without limbs going through walls, rotating entire ragdoll, using combined network messages client->server, fixed fabricators

This commit is contained in:
Regalis
2015-11-08 22:20:29 +02:00
parent 5a21d64b3a
commit cd48d12be6
31 changed files with 551 additions and 313 deletions
@@ -73,34 +73,23 @@ namespace Barotrauma.Items.Components
}
int width = 400, height = 300;
itemList = new GUIListBox(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), Color.White * 0.7f);
int width = 500, height = 300;
itemList = new GUIListBox(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
itemList.OnSelected = SelectItem;
//structureList.CheckSelected = MapEntityPrefab.GetSelected;
foreach (FabricableItem fi in fabricableItems)
{
Color color = ((itemList.CountChildren % 2) == 0) ? Color.White : Color.LightGray;
//GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, itemList);
//frame.UserData = fi;
//frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
//frame.Color = color;
//frame.HoverColor = Color.Gold * 0.2f;
//frame.SelectedColor = Color.Gold * 0.5f;
Color color = ((itemList.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.3f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), fi.TargetItem.Name,
color, Color.Black,
color, Color.White,
Alignment.Left, Alignment.Left, null, itemList);
textBlock.UserData = fi;
textBlock.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
//if (fi.TargetItem.sprite != null)
//{
// GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), fi.TargetItem.sprite, Alignment.Left, frame);
// img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f);
//}
textBlock.HoverColor = Color.Gold * 0.2f;
textBlock.SelectedColor = Color.Gold * 0.5f;
}
}
@@ -110,7 +99,7 @@ namespace Barotrauma.Items.Components
if (targetItem == null) return false;
int width = 200, height = 150;
selectedItemFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, itemList.Rect.Bottom+20, width, height), Color.Black*0.8f);
selectedItemFrame = new GUIFrame(new Rectangle(itemList.Rect.Right - width - 20, GameMain.GraphicsHeight/2-height/2, width, height), Color.Black*0.8f);
//selectedItemFrame.Padding = GUI.style.smallPadding;
if (targetItem.TargetItem.sprite != null)
@@ -177,7 +166,7 @@ namespace Barotrauma.Items.Components
container.inventory.RemoveItem(requiredItem);
}
new Item(fabricatedItem.TargetItem, item.Position);
Item.Spawner.QueueItem(fabricatedItem.TargetItem, item.Position);
IsActive = false;
fabricatedItem = null;
@@ -199,7 +188,6 @@ namespace Barotrauma.Items.Components
}
}
itemList.Update(0.016f);
itemList.Draw(spriteBatch);
@@ -131,10 +131,14 @@ namespace Barotrauma.Items.Components
float cellDot = Vector2.Dot(cell.Center + Level.Loaded.Position, (edge.point1 + edge.point2) / 2.0f - cell.Center);
if (cellDot > 0) continue;
float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center + Level.Loaded.Position));
facingDot = MathHelper.Clamp(facingDot, -1.0f, 1.0f);
Vector2 point1 = (edge.point1 + Level.Loaded.Position);
Vector2 point2 = (edge.point2 + Level.Loaded.Position);
for (float x=0; x<(point1-point2).Length(); x+=Rand.Range(600.0f, 800.0f))
float length = (point1 - point2).Length();
for (float x=0; x<length; x+=Rand.Range(600.0f, 800.0f))
{
Vector2 point = point1 + Vector2.Normalize(point2 - point1) * x;
@@ -144,15 +148,18 @@ namespace Barotrauma.Items.Components
if (pointDist < prevPingRadius || pointDist > pingRadius) continue;
float step = 4.0f;
float step = 5.0f * (Math.Abs(facingDot)+1.0f);
float alpha = Rand.Range(1.5f, 2.0f);
for (float z = 0; z<radius-pointDist;z+=step)
{
var blip = new RadarBlip(
point + Rand.Vector(150.0f) - Level.Loaded.Position + Vector2.Normalize(point) * z / displayScale,
Rand.Range(0.8f, 1.0f) / (step-4.0f));
alpha);
radarBlips.Add(blip);
step += 0.5f;
alpha -= (z == 0) ? 0.5f : 0.1f;
}
}
@@ -199,7 +206,7 @@ namespace Barotrauma.Items.Components
foreach (RadarBlip radarBlip in radarBlips)
{
DrawBlip(spriteBatch, center, radarBlip.Position, Color.Green * radarBlip.FadeTimer);
DrawBlip(spriteBatch,radarBlip, center, Color.Green * radarBlip.FadeTimer, radius);
}
prevPingRadius = pingRadius;
@@ -262,17 +269,18 @@ namespace Barotrauma.Items.Components
voltage = 0.0f;
}
private void DrawBlip(SpriteBatch spriteBatch, Vector2 center, Vector2 pos, Color color)
private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius)
{
pos = (pos + Level.Loaded.Position) * displayScale;
Vector2 pos = (blip.Position + Level.Loaded.Position) * displayScale;
pos.Y = -pos.Y;
//spriteBatch.Draw(radarBlipSprite, center+pos,
// new Rectangle((int)(radarBlip.SpriteIndex % 4 * 32), (int)(Math.Floor(radarBlip.SpriteIndex / 4.0f) * 32), 32, 32),
// Color.White * radarBlip.FadeTimer, 0.0f, new Vector2(16.0f, 16.0f), 0.5f, SpriteEffects.None, 0.0f);
if (pos.Length() > radius)
{
blip.FadeTimer = 0.0f;
return;
}
pos.X = MathUtils.Round(pos.X, 4);
pos.Y = MathUtils.Round(pos.Y, 2);
GUI.DrawRectangle(spriteBatch, center + pos, new Vector2(4, 2), color, true);