diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index eaf9142f9..0316478b6 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -740,9 +740,6 @@ PreserveNewest Designer - - PreserveNewest - PreserveNewest diff --git a/Subsurface/Content/Items/Artifacts/artifacts.xml b/Subsurface/Content/Items/Artifacts/artifacts.xml index 39eac13db..c283a20f7 100644 --- a/Subsurface/Content/Items/Artifacts/artifacts.xml +++ b/Subsurface/Content/Items/Artifacts/artifacts.xml @@ -8,7 +8,7 @@ - + - + diff --git a/Subsurface/Content/Items/Clothes/clothes.xml b/Subsurface/Content/Items/Clothes/clothes.xml index 59e3f8d2c..f614a4835 100644 --- a/Subsurface/Content/Items/Clothes/clothes.xml +++ b/Subsurface/Content/Items/Clothes/clothes.xml @@ -92,7 +92,7 @@ - + @@ -118,7 +118,7 @@ - + diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index fd67f56e7..f4d2d2caf 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -11,9 +11,6 @@ - - - @@ -33,7 +30,12 @@ - + + + + + + @@ -52,7 +54,7 @@ - + @@ -70,10 +72,17 @@ + + + + + + + @@ -86,9 +95,9 @@ - + - + diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index d26e8214c..3aa2621ff 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -12,7 +12,7 @@ - @@ -56,7 +56,7 @@ - @@ -94,9 +94,6 @@ - - - @@ -113,7 +110,7 @@ - diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml index 5c9680dfe..5a4579d94 100644 --- a/Subsurface/Content/Items/Weapons/railgun.xml +++ b/Subsurface/Content/Items/Weapons/railgun.xml @@ -68,7 +68,7 @@ - + diff --git a/Subsurface/Content/Items/Weapons/weapons.xml b/Subsurface/Content/Items/Weapons/weapons.xml index fa95d3ecc..4e52c7076 100644 --- a/Subsurface/Content/Items/Weapons/weapons.xml +++ b/Subsurface/Content/Items/Weapons/weapons.xml @@ -26,7 +26,7 @@ - diff --git a/Subsurface/Content/Particles/blood.png b/Subsurface/Content/Particles/blood.png deleted file mode 100644 index e5ad8cfdb..000000000 Binary files a/Subsurface/Content/Particles/blood.png and /dev/null differ diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index a78f5f2cc..a4f5c360f 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -481,8 +481,10 @@ namespace Barotrauma if (info.Job.EquipSpawnItem[i]) { - inventory.TryPutItem(item, - item.AllowedSlots.HasFlag(LimbSlot.Any) ? item.AllowedSlots & ~LimbSlot.Any : item.AllowedSlots, false); + List allowedSlots = new List(item.AllowedSlots); + allowedSlots.Remove(LimbSlot.Any); + + inventory.TryPutItem(item, allowedSlots, false); } else { diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index cc32ed0a0..9e722f7d1 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -11,7 +11,7 @@ namespace Barotrauma [Flags] public enum LimbSlot { - Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, BothHands = 64 + None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32 }; class CharacterInventory : Inventory @@ -100,56 +100,69 @@ namespace Barotrauma /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public override bool TryPutItem(Item item, LimbSlot allowedSlots, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, List allowedSlots, bool createNetworkEvent = true) { - for (int i = 0; i < capacity; i++) - { - //item is already in the inventory! - if (items[i] == item) return true; - } + //for (int i = 0; i < capacity; i++) + //{ + // //item is already in the inventory! + // if (items[i] == item) return true; + //} - if (allowedSlots.HasFlag(LimbSlot.Any)) + //try to place the item in LimBlot.Any slot if that's allowed + if (allowedSlots.Contains(LimbSlot.Any)) { for (int i = 0; i < capacity; i++) { - if (items[i] != null) continue; - if (limbSlots[i] != LimbSlot.Any) continue; + if (items[i] != null || limbSlots[i] != LimbSlot.Any) continue; PutItem(item, i, createNetworkEvent); item.Unequip(character); return true; } } - for (int i = 0; i < capacity; i++) - { - if (allowedSlots.HasFlag(limbSlots[i]) && items[i]!=null) return false; - } - bool placed = false; - for (int i = 0; i < capacity; i++) + foreach (LimbSlot allowedSlot in allowedSlots) { - if (allowedSlots.HasFlag(limbSlots[i]) && items[i] == null) + //check if all the required slots are free + bool free = true; + for (int i = 0; i < capacity; i++) { - PutItem(item, i, createNetworkEvent, !placed); - item.Equip(character); - placed = true; + if (allowedSlot.HasFlag(limbSlots[i]) && items[i]!=null && items[i]!=item) + { + free = false; + break; + } } + + if (!free) continue; + + for (int i = 0; i < capacity; i++) + { + if (allowedSlot.HasFlag(limbSlots[i]) && items[i] == null) + { + PutItem(item, i, createNetworkEvent, !placed); + item.Equip(character); + placed = true; + } + } + + if (placed) return true; + + //if (allowedSlots.HasFlag(LimbSlot.BothHands)) TryPutItem(item, 3, createNetworkEvent); + } - if (placed) return true; - if (allowedSlots.HasFlag(LimbSlot.BothHands)) TryPutItem(item, 3, createNetworkEvent); - - return false; + return placed; } - public override bool TryPutItem(Item item, int i, bool createNetworkEvent) + public override bool TryPutItem(Item item, int index, bool createNetworkEvent) { - LimbSlot usedSlots = item.AllowedSlots; - //there's already an item in the slot - if (items[i] != null) + if (items[index] != null) { + if (items[index] == item) return false; + bool combined = false; //if (item.Combine(items[i])) //{ @@ -157,11 +170,16 @@ namespace Barotrauma // combined = true; //} //else - if (items[i].Combine(item)) + if (items[index].Combine(item)) { //PutItem(items[i], i, false, false); - Inventory otherInventory = items[i].inventory; - if (otherInventory!=null && createNetworkEvent) + if (items[index]==null) + { + System.Diagnostics.Debug.Assert(false); + return false; + } + Inventory otherInventory = items[index].inventory; + if (otherInventory != null && createNetworkEvent) { new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true); } @@ -169,65 +187,157 @@ namespace Barotrauma combined = true; } - if (!combined) return false; + return combined; + } - if (usedSlots.HasFlag(LimbSlot.BothHands)) - { - if (limbSlots[i] == LimbSlot.LeftHand) - { - PutItem(item, FindLimbSlot(LimbSlot.RightHand), createNetworkEvent, false); - } - else if (limbSlots[i] == LimbSlot.RightHand) - { - PutItem(item, FindLimbSlot(LimbSlot.LeftHand), createNetworkEvent, false); - } - } - if (limbSlots[i] == LimbSlot.Any) item.Unequip(character); + if (limbSlots[index] == LimbSlot.Any) + { + if (!item.AllowedSlots.Contains(LimbSlot.Any)) return false; + if (items[index] != null) return items[index] == item; + PutItem(item, index, createNetworkEvent, true); return true; } + + LimbSlot placeToSlots = LimbSlot.None; + + bool slotsFree = true; + List allowedSlots = item.AllowedSlots; + foreach (LimbSlot allowedSlot in allowedSlots) + { + if (!allowedSlot.HasFlag(limbSlots[index])) continue; + + for (int i = 0; i < capacity; i++) + { + if (allowedSlot.HasFlag(limbSlots[i]) && items[i] != null && items[i] != item) + { + slotsFree = false; + break; + } + + placeToSlots = allowedSlot; + } + } + + if (!slotsFree) return false; - if (limbSlots[i]==LimbSlot.Any) - { - if (usedSlots.HasFlag(LimbSlot.Any)) - { - item.Unequip(character); - PutItem(item, i, createNetworkEvent); - return true; - } - else - { - return false; - } - } - else - { + return TryPutItem(item, new List() {placeToSlots}, createNetworkEvent); - if (limbSlots[i] != LimbSlot.Any && usedSlots.HasFlag(limbSlots[i]) && items[i] == null) - { - item.Unequip(character); - PutItem(item, i, createNetworkEvent); - item.Equip(character); - return true; - } + + ////there's already an item in the slot + //if (items[i] != null) + //{ + // bool combined = false; + // //if (item.Combine(items[i])) + // //{ + // // //PutItem(item, i, false, false); + // // combined = true; + // //} + // //else + // if (items[i].Combine(item)) + // { + // //PutItem(items[i], i, false, false); + // Inventory otherInventory = items[i].inventory; + // if (otherInventory!=null && createNetworkEvent) + // { + // new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true); + // } + + // combined = true; + // } + + // if (!combined) return false; + + // //if (usedSlots.HasFlag(LimbSlot.BothHands)) + // //{ + // // if (limbSlots[i] == LimbSlot.LeftHand) + // // { + // // PutItem(item, FindLimbSlot(LimbSlot.RightHand), createNetworkEvent, false); + // // } + // // else if (limbSlots[i] == LimbSlot.RightHand) + // // { + // // PutItem(item, FindLimbSlot(LimbSlot.LeftHand), createNetworkEvent, false); + // // } + // //} + // if (limbSlots[i] == LimbSlot.Any) + // { + // item.Unequip(character); + // return true; + // } + //} + + + //bool placed = false; + //foreach (LimbSlot allowedSlot in usedSlots) + //{ + // if () + //} + + //foreach (LimbSlot allowedSlot in usedSlots) + //{ + // //check if all the required slots are free + // for (int n = 0; n < capacity; i++) + // { + // if (allowedSlot.HasFlag(limbSlots[n]) && items[n] != null && items[n] != item) continue; + // } + + // for (int n = 0; n < capacity; n++) + // { + // if (allowedSlot.HasFlag(limbSlots[i]) && items[i] == null) + // { + // PutItem(item, i, createNetworkEvent, !placed); + // item.Equip(character); + // placed = true; + // } + // } + + // if (placed) return true; + + // //if (allowedSlots.HasFlag(LimbSlot.BothHands)) TryPutItem(item, 3, createNetworkEvent); + + //} + + //if (limbSlots[i]==LimbSlot.Any) + //{ + // if (usedSlots.HasFlag(LimbSlot.Any)) + // { + // item.Unequip(character); + // PutItem(item, i, createNetworkEvent); + // return true; + // } + // else + // { + // return false; + // } + //} + //else + //{ + + // if (limbSlots[i] != LimbSlot.Any && usedSlots.HasFlag(limbSlots[i]) && items[i] == null) + // { + // item.Unequip(character); + // PutItem(item, i, createNetworkEvent); + // item.Equip(character); + // return true; + // } - if (usedSlots.HasFlag(LimbSlot.BothHands) && (limbSlots[i]==LimbSlot.LeftHand || limbSlots[i]==LimbSlot.RightHand)) - { - int rightHandSlot = FindLimbSlot(LimbSlot.LeftHand); - int leftHandSlot = FindLimbSlot(LimbSlot.RightHand); + // if (usedSlots.HasFlag(LimbSlot.BothHands) && (limbSlots[i]==LimbSlot.LeftHand || limbSlots[i]==LimbSlot.RightHand)) + // { + // int rightHandSlot = FindLimbSlot(LimbSlot.LeftHand); + // int leftHandSlot = FindLimbSlot(LimbSlot.RightHand); - if (items[rightHandSlot] != null) return false; - if (items[leftHandSlot] != null) return false; + // if (items[rightHandSlot] != null) return false; + // if (items[leftHandSlot] != null) return false; - PutItem(item, rightHandSlot, createNetworkEvent, true); - PutItem(item, leftHandSlot, createNetworkEvent, false); - item.Equip(character); - return true; - } + // PutItem(item, rightHandSlot, createNetworkEvent, true); + // PutItem(item, leftHandSlot, createNetworkEvent, false); + // item.Equip(character); + // return true; + // } - return false; - } + // return false; + //} } diff --git a/Subsurface/Source/Items/Components/Holdable/Pickable.cs b/Subsurface/Source/Items/Components/Holdable/Pickable.cs index 6b383140f..d3b3ebd5d 100644 --- a/Subsurface/Source/Items/Components/Holdable/Pickable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Pickable.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Xml.Linq; namespace Barotrauma.Items.Components @@ -7,9 +8,9 @@ namespace Barotrauma.Items.Components { protected Character picker; - protected LimbSlot allowedSlots; + protected List allowedSlots; - public LimbSlot AllowedSlots + public List AllowedSlots { get { return allowedSlots; } } @@ -22,11 +23,26 @@ namespace Barotrauma.Items.Components public Pickable(Item item, XElement element) : base(item, element) { + allowedSlots = new List(); + string slotString = ToolBox.GetAttributeString(element, "slots", "Any"); - string[] slots = slotString.Split(','); - foreach (string slot in slots) + string[] slotCombinations = slotString.Split(','); + foreach (string slotCombination in slotCombinations) { - allowedSlots = allowedSlots | (LimbSlot)Enum.Parse(typeof(LimbSlot), slot.Trim()); + string[] slots = slotCombination.Split('+'); + LimbSlot allowedSlot = LimbSlot.None; + foreach (string slot in slots) + { + if (slot.ToLower()=="bothhands") + { + allowedSlot = LimbSlot.LeftHand | LimbSlot.RightHand; + } + else + { + allowedSlot = allowedSlot | (LimbSlot)Enum.Parse(typeof(LimbSlot), slot.Trim()); + } + } + allowedSlots.Add(allowedSlot); } canBePicked = true; diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index 41420f01b..cc4121ed7 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -89,7 +89,7 @@ namespace Barotrauma /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public virtual bool TryPutItem(Item item, LimbSlot allowedSlots = 0, bool createNetworkEvent = true) + public virtual bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) { int slot = FindAllowedSlot(item); if (slot < 0) return false; @@ -238,48 +238,46 @@ namespace Barotrauma if (selectedSlot == slotIndex && !isSubSlot) { - System.Diagnostics.Debug.WriteLine("sdfg: "+selectedSlot+" - "+slotIndex); - selectedSlot = -1; - if (item == null) return; - - - int itemCapacity = item.Capacity; - if (itemCapacity == 0) return; + int itemCapacity = item==null ? 0 : item.Capacity; + if (itemCapacity > 0) + { #if DEBUG - System.Diagnostics.Debug.Assert(slotIndex>=0 && slotIndex= 0 && slotIndex < items.Length); #else if (slotIndex<0 || slotIndex>=items.Length) return; #endif - Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5, - rect.Width + 10, rect.Height + (40 + 10) * itemCapacity + 10); + Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5, + rect.Width + 10, rect.Height + (40 + 10) * itemCapacity + 10); - Rectangle subRect = rect; - subRect.Height = 40; + Rectangle subRect = rect; + subRect.Height = 40; - selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1; - System.Diagnostics.Debug.WriteLine(selectedSlot); + selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1; + System.Diagnostics.Debug.WriteLine(selectedSlot); - GUI.DrawRectangle(spriteBatch, containerRect, Color.Black*0.8f, true); - GUI.DrawRectangle(spriteBatch, containerRect, Color.White); + GUI.DrawRectangle(spriteBatch, containerRect, Color.Black * 0.8f, true); + GUI.DrawRectangle(spriteBatch, containerRect, Color.White); - Item[] containedItems = null; - if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems; + Item[] containedItems = null; + if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems; - if (containedItems != null) - { - for (int i = 0; i < itemCapacity; i++) + if (containedItems != null) { - subRect.Y = subRect.Y - subRect.Height - 10; - UpdateSlot(spriteBatch, subRect, selectedSlot, i < containedItems.Count() ? containedItems[i] : null, true); + for (int i = 0; i < itemCapacity; i++) + { + subRect.Y = subRect.Y - subRect.Height - 10; + UpdateSlot(spriteBatch, subRect, selectedSlot, i < containedItems.Count() ? containedItems[i] : null, true); + } } } + } DrawSlot(spriteBatch, rect, (draggingItem == item && !mouseOn) ? null : item, mouseOn, isSubSlot, drawItem); diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 1212000c3..99f0188b9 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -186,12 +186,12 @@ namespace Barotrauma } //which type of inventory slots (head, torso, any, etc) the item can be placed in - public LimbSlot AllowedSlots + public List AllowedSlots { get { Pickable p = GetComponent(); - return (p==null) ? LimbSlot.Any : p.AllowedSlots; + return (p==null) ? new List() { LimbSlot.Any } : p.AllowedSlots; } } diff --git a/Subsurface/Source/Map/Map.cs b/Subsurface/Source/Map/Map.cs index 2ec229a53..9e7e68a5e 100644 --- a/Subsurface/Source/Map/Map.cs +++ b/Subsurface/Source/Map/Map.cs @@ -257,7 +257,8 @@ namespace Barotrauma Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y); Vector2 offset = -currentLocation.MapPosition; - iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), offset, Color.White); + iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), Vector2.Zero, Color.White); + GUI.DrawRectangle(spriteBatch, rect, Color.White); //spriteBatch.Draw(iceTexture, offset, rect, null, null, 0f, null, Color.White, SpriteEffects.None, 0.0f); //Vector2 scale = new Vector2((float)rect.Width/ size, (float)rect.Height/size); diff --git a/Subsurface/Source/Particles/Particle.cs b/Subsurface/Source/Particles/Particle.cs index 63ada622c..cfb65921d 100644 --- a/Subsurface/Source/Particles/Particle.cs +++ b/Subsurface/Source/Particles/Particle.cs @@ -270,16 +270,6 @@ namespace Barotrauma.Particles prefab.Sprites[spriteIndex].origin, drawRotation, drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth); - //spriteBatch.Draw( - // prefab.sprite.Texture, - // drawPosition, - // null, - // color*alpha, - // drawRotation, - // prefab.sprite.origin, - // size, - // SpriteEffects.None, prefab.sprite.Depth); - prevPosition = position; prevRotation = rotation; } diff --git a/Subsurface/Source/Program.cs b/Subsurface/Source/Program.cs index 41400c501..dd2d14c37 100644 --- a/Subsurface/Source/Program.cs +++ b/Subsurface/Source/Program.cs @@ -28,19 +28,19 @@ namespace Barotrauma { using (var game = new GameMain()) { -//#if !DEBUG +#if !DEBUG try { -//#endif +#endif game.Run(); -//#if !DEBUG +#if !DEBUG } catch (Exception e) { CrashDump(game, "crashreport.txt", e); } -//#endif +#endif } } diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index dce192bf7..89da7d9ce 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -203,7 +203,7 @@ namespace Barotrauma spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, - BlendState.NonPremultiplied, + BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.Default, null, null, cam.Transform); @@ -249,7 +249,7 @@ namespace Barotrauma spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, - BlendState.NonPremultiplied, + BlendState.AlphaBlend, null, DepthStencilState.Default, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend); @@ -272,7 +272,7 @@ namespace Barotrauma spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, - BlendState.NonPremultiplied, + BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 0ee4a6faa..2bad0af0a 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ