LimbSlot combinations for pickable items ("Any,RightHand+LeftHand"...)

This commit is contained in:
Regalis
2015-11-19 21:24:49 +02:00
parent a46f724f1f
commit 8ec7fd44ff
18 changed files with 272 additions and 152 deletions
-3
View File
@@ -740,9 +740,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Content> </Content>
<Content Include="Content\Particles\blood.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Particles\bubbles.png"> <Content Include="Content\Particles\bubbles.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -8,7 +8,7 @@
<Body width="36" height="60" density="5"/> <Body width="36" height="60" density="5"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,10" handle2="0,-10"/> <Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
</Item> </Item>
<Item <Item
@@ -19,7 +19,7 @@
<Body radius="20" height="20" density="5"/> <Body radius="20" height="20" density="5"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,10" handle2="0,-10"> <Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
<StatusEffect type="OnActive"> <StatusEffect type="OnActive">
<Fire/> <Fire/>
</StatusEffect> </StatusEffect>
+2 -2
View File
@@ -92,7 +92,7 @@
<Body width="50" height="17"/> <Body width="50" height="17"/>
<Wearable slots="Any,Torso,Legs"> <Wearable slots="Any,Torso+Legs">
<sprite texture="engigear.png" limb="Torso" sourcerect="0,0,32,51" origin="0.5,0.48" depth="0.01"/> <sprite texture="engigear.png" limb="Torso" sourcerect="0,0,32,51" origin="0.5,0.48" depth="0.01"/>
<sprite texture="engigear.png" limb="Waist" sourcerect="81,0,30,26" origin="0.5,0.45" hidelimb="true"/> <sprite texture="engigear.png" limb="Waist" sourcerect="81,0,30,26" origin="0.5,0.45" hidelimb="true"/>
@@ -118,7 +118,7 @@
<Body width="50" height="17"/> <Body width="50" height="17"/>
<Wearable slots="Any,Torso,Legs"> <Wearable slots="Any,Torso+Legs">
<sprite texture="engigear.png" limb="Torso" sourcerect="0,77,32,51" origin="0.5,0.48" depth="0.01"/> <sprite texture="engigear.png" limb="Torso" sourcerect="0,77,32,51" origin="0.5,0.48" depth="0.01"/>
<sprite texture="engigear.png" limb="Waist" sourcerect="81,77,30,26" origin="0.5,0.45" hidelimb="true"/> <sprite texture="engigear.png" limb="Waist" sourcerect="81,77,30,26" origin="0.5,0.45" hidelimb="true"/>
+16 -7
View File
@@ -11,9 +11,6 @@
<Body radius="6" height="22" density="5"/> <Body radius="6" height="22" density="5"/>
<Pickable holdpos="30,-15" handle1="0,1" slots="RightHand,LeftHand,Any"> <Pickable holdpos="30,-15" handle1="0,1" slots="RightHand,LeftHand,Any">
<StatusEffect type="OnWearing" target="This" Condition="-0.5"/>
<StatusEffect type="OnWearing" target="Character" Oxygen="20.0"/>
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true"> <StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/> <Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
</StatusEffect> </StatusEffect>
@@ -33,7 +30,12 @@
<Wearable limbtype="Head" slots="Any,Head"> <Wearable limbtype="Head" slots="Any,Head">
<sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/> <sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" setvalue="true" disabledeltatime="true"/> <StatusEffect type="OnWearing" target="Character" ObstructVision="true" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="20.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-30.0" Condition="-0.5">
<RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect>
</Wearable> </Wearable>
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
@@ -52,7 +54,7 @@
<Body width="37" height="113" density="5"/> <Body width="37" height="113" density="5"/>
<Wearable slots="Head,Torso,Legs" armorvalue="10.0"> <Wearable slots="Head+Torso+Legs" armorvalue="10.0">
<sprite texture="DivingSuit.png" limb="Head" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/> <sprite texture="DivingSuit.png" limb="Head" sourcerect="0,0,1,1" origin="0.5,0.5" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="Torso" sourcerect="40,0,42,97" origin="0.5,0.55" depthlimb="Head" hidelimb="true"/> <sprite texture="DivingSuit.png" limb="Torso" sourcerect="40,0,42,97" origin="0.5,0.55" depthlimb="Head" hidelimb="true"/>
@@ -70,10 +72,17 @@
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/> <sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/> <StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="20.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-30.0" Condition="-0.5">
<RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect>
</Wearable> </Wearable>
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
<Containable name="Oxygen Tank"/> <Containable name="Oxygen Tank"/>
<Containable name="Welding Fuel Tank"/>
</ItemContainer> </ItemContainer>
</Item> </Item>
@@ -86,9 +95,9 @@
<Sprite texture ="DivingSuit.png" depth="0.5" sourcerect="22,98,59,32" origin="0.6,0.66"/> <Sprite texture ="DivingSuit.png" depth="0.5" sourcerect="22,98,59,32" origin="0.6,0.66"/>
<Body radius="7" height="20" density="5"/> <Body width="55" height="30" density="5"/>
<Holdable slots="Any,BothHands" aimpos="100,0" handle1="0,11" handle2="2,11"/> <Holdable slots="Any,RightHand+LeftHand" aimpos="100,0" handle1="0,11" handle2="2,11"/>
<Propulsion force="80" usablein="water" particles="bubbles"> <Propulsion force="80" usablein="water" particles="bubbles">
<RequiredItems name="Battery Cell" type="Contained" msg="Battery Cell required"/> <RequiredItems name="Battery Cell" type="Contained" msg="Battery Cell required"/>
+3 -6
View File
@@ -12,7 +12,7 @@
<Body width="39" height="18" density="5"/> <Body width="39" height="18" density="5"/>
<!-- the character will hold the item 50 pixels in front of him, with his hands at the handle1 and handle2 positions --> <!-- the character will hold the item 50 pixels in front of him, with his hands at the handle1 and handle2 positions -->
<Holdable slots="Any,BothHands" controlpose="true" <Holdable slots="Any,RightHand+LeftHand" controlpose="true"
aimpos="50,0" handle1="-17,0" handle2="8,0"/> aimpos="50,0" handle1="-17,0" handle2="8,0"/>
<RepairTool structurefixamount="5.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="weld"> <RepairTool structurefixamount="5.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="weld">
@@ -56,7 +56,7 @@
<Body width="39" height="18" density="5"/> <Body width="39" height="18" density="5"/>
<Holdable slots="Any,BothHands" controlpose="true" <Holdable slots="Any,RightHand+LeftHand" controlpose="true"
aimpos="50,0" handle1="-12,4"/> aimpos="50,0" handle1="-12,4"/>
<RepairTool structurefixamount="-2.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="plasma"> <RepairTool structurefixamount="-2.0" limbfixamount="-0.5" range="100" barrelpos="19,8" particles="plasma">
@@ -94,9 +94,6 @@
<Body radius="6" height="22" density="5"/> <Body radius="6" height="22" density="5"/>
<Holdable slots="RightHand,Any" holdpos="30,-15" handle1="0,5" handle2="0,-5"> <Holdable slots="RightHand,Any" holdpos="30,-15" handle1="0,5" handle2="0,-5">
<StatusEffect type="OnWearing" target="This" Condition="-0.5"/>
<StatusEffect type="OnWearing" target="Character" Oxygen="-40.0"/>
<StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true"> <StatusEffect type="OnFire" target="This" Condition="-100.0" sound="Content/Items/Reactor/explosion.ogg" disabledeltatime="true">
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/> <Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
</StatusEffect> </StatusEffect>
@@ -113,7 +110,7 @@
<Body radius="10" height="45" density="5"/> <Body radius="10" height="45" density="5"/>
<Holdable slots="Any,BothHands" controlpose="false" <Holdable slots="Any,RightHand+LeftHand" controlpose="false"
aimpos="40,-20" handle1="-2,30"/> aimpos="40,-20" handle1="-2,30"/>
<RepairTool extinquishamount="30.0" range="300" barrelpos="21,25" particles="extinguisher" particlespeed="650.0"> <RepairTool extinquishamount="30.0" range="300" barrelpos="21,25" particles="extinguisher" particlespeed="650.0">
+1 -1
View File
@@ -68,7 +68,7 @@
<Body width="87" height="18"/> <Body width="87" height="18"/>
<Holdable slots="BothHands" holdpos="0,-50" handle1="-10,0" handle2="10,0" aimable="false"/> <Holdable slots="RightHand+LeftHand" holdpos="0,-50" handle1="-10,0" handle2="10,0" aimable="false"/>
<Projectile launchimpulse="80.0"> <Projectile launchimpulse="80.0">
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/> <Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
+1 -1
View File
@@ -26,7 +26,7 @@
<Body width="90" height="30" density="10"/> <Body width="90" height="30" density="10"/>
<Holdable slots="Any,BothHands" controlpose="true" <Holdable slots="Any,RightHand+LeftHand" controlpose="true"
holdpos="35,-10" aimpos="35,-10" handle1="-15,-6" handle2="26,7"/> holdpos="35,-10" aimpos="35,-10" handle1="-15,-6" handle2="26,7"/>
<RangedWeapon barrelpos="49,10"> <RangedWeapon barrelpos="49,10">
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

+4 -2
View File
@@ -481,8 +481,10 @@ namespace Barotrauma
if (info.Job.EquipSpawnItem[i]) if (info.Job.EquipSpawnItem[i])
{ {
inventory.TryPutItem(item, List<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
item.AllowedSlots.HasFlag(LimbSlot.Any) ? item.AllowedSlots & ~LimbSlot.Any : item.AllowedSlots, false); allowedSlots.Remove(LimbSlot.Any);
inventory.TryPutItem(item, allowedSlots, false);
} }
else else
{ {
+187 -77
View File
@@ -11,7 +11,7 @@ namespace Barotrauma
[Flags] [Flags]
public enum LimbSlot 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 class CharacterInventory : Inventory
@@ -100,56 +100,69 @@ namespace Barotrauma
/// <summary> /// <summary>
/// If there is room, puts the item in the inventory and returns true, otherwise returns false /// If there is room, puts the item in the inventory and returns true, otherwise returns false
/// </summary> /// </summary>
public override bool TryPutItem(Item item, LimbSlot allowedSlots, bool createNetworkEvent = true) public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots, bool createNetworkEvent = true)
{ {
for (int i = 0; i < capacity; i++) //for (int i = 0; i < capacity; i++)
{ //{
//item is already in the inventory! // //item is already in the inventory!
if (items[i] == item) return true; // 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++) for (int i = 0; i < capacity; i++)
{ {
if (items[i] != null) continue; if (items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
if (limbSlots[i] != LimbSlot.Any) continue;
PutItem(item, i, createNetworkEvent); PutItem(item, i, createNetworkEvent);
item.Unequip(character); item.Unequip(character);
return true; return true;
} }
} }
for (int i = 0; i < capacity; i++)
{
if (allowedSlots.HasFlag(limbSlots[i]) && items[i]!=null) return false;
}
bool placed = 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); if (allowedSlot.HasFlag(limbSlots[i]) && items[i]!=null && items[i]!=item)
item.Equip(character); {
placed = true; 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 placed;
return false;
} }
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 //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; bool combined = false;
//if (item.Combine(items[i])) //if (item.Combine(items[i]))
//{ //{
@@ -157,11 +170,16 @@ namespace Barotrauma
// combined = true; // combined = true;
//} //}
//else //else
if (items[i].Combine(item)) if (items[index].Combine(item))
{ {
//PutItem(items[i], i, false, false); //PutItem(items[i], i, false, false);
Inventory otherInventory = items[i].inventory; if (items[index]==null)
if (otherInventory!=null && createNetworkEvent) {
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); new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true);
} }
@@ -169,65 +187,157 @@ namespace Barotrauma
combined = true; combined = true;
} }
if (!combined) return false; return combined;
}
if (usedSlots.HasFlag(LimbSlot.BothHands)) if (limbSlots[index] == LimbSlot.Any)
{ {
if (limbSlots[i] == LimbSlot.LeftHand) if (!item.AllowedSlots.Contains(LimbSlot.Any)) return false;
{ if (items[index] != null) return items[index] == item;
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);
PutItem(item, index, createNetworkEvent, true);
return true; return true;
} }
if (limbSlots[i]==LimbSlot.Any) LimbSlot placeToSlots = LimbSlot.None;
bool slotsFree = true;
List<LimbSlot> allowedSlots = item.AllowedSlots;
foreach (LimbSlot allowedSlot in allowedSlots)
{ {
if (usedSlots.HasFlag(LimbSlot.Any)) if (!allowedSlot.HasFlag(limbSlots[index])) continue;
for (int i = 0; i < capacity; i++)
{ {
item.Unequip(character); if (allowedSlot.HasFlag(limbSlots[i]) && items[i] != null && items[i] != item)
PutItem(item, i, createNetworkEvent); {
return true; slotsFree = false;
} break;
else }
{
return false; placeToSlots = allowedSlot;
} }
} }
else
{
if (limbSlots[i] != LimbSlot.Any && usedSlots.HasFlag(limbSlots[i]) && items[i] == null) if (!slotsFree) return false;
{
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)) return TryPutItem(item, new List<LimbSlot>() {placeToSlots}, createNetworkEvent);
{
int rightHandSlot = FindLimbSlot(LimbSlot.LeftHand);
int leftHandSlot = FindLimbSlot(LimbSlot.RightHand);
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;
}
return false; ////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 (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;
// }
// return false;
//}
} }
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
@@ -7,9 +8,9 @@ namespace Barotrauma.Items.Components
{ {
protected Character picker; protected Character picker;
protected LimbSlot allowedSlots; protected List<LimbSlot> allowedSlots;
public LimbSlot AllowedSlots public List<LimbSlot> AllowedSlots
{ {
get { return allowedSlots; } get { return allowedSlots; }
} }
@@ -22,11 +23,26 @@ namespace Barotrauma.Items.Components
public Pickable(Item item, XElement element) public Pickable(Item item, XElement element)
: base(item, element) : base(item, element)
{ {
allowedSlots = new List<LimbSlot>();
string slotString = ToolBox.GetAttributeString(element, "slots", "Any"); string slotString = ToolBox.GetAttributeString(element, "slots", "Any");
string[] slots = slotString.Split(','); string[] slotCombinations = slotString.Split(',');
foreach (string slot in slots) 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; canBePicked = true;
+22 -24
View File
@@ -89,7 +89,7 @@ namespace Barotrauma
/// <summary> /// <summary>
/// If there is room, puts the item in the inventory and returns true, otherwise returns false /// If there is room, puts the item in the inventory and returns true, otherwise returns false
/// </summary> /// </summary>
public virtual bool TryPutItem(Item item, LimbSlot allowedSlots = 0, bool createNetworkEvent = true) public virtual bool TryPutItem(Item item, List<LimbSlot> allowedSlots = null, bool createNetworkEvent = true)
{ {
int slot = FindAllowedSlot(item); int slot = FindAllowedSlot(item);
if (slot < 0) return false; if (slot < 0) return false;
@@ -238,48 +238,46 @@ namespace Barotrauma
if (selectedSlot == slotIndex && !isSubSlot) if (selectedSlot == slotIndex && !isSubSlot)
{ {
System.Diagnostics.Debug.WriteLine("sdfg: "+selectedSlot+" - "+slotIndex);
selectedSlot = -1; selectedSlot = -1;
if (item == null) return; int itemCapacity = item==null ? 0 : item.Capacity;
if (itemCapacity > 0)
{
int itemCapacity = item.Capacity;
if (itemCapacity == 0) return;
#if DEBUG #if DEBUG
System.Diagnostics.Debug.Assert(slotIndex>=0 && slotIndex<items.Length); System.Diagnostics.Debug.Assert(slotIndex >= 0 && slotIndex < items.Length);
#else #else
if (slotIndex<0 || slotIndex>=items.Length) return; if (slotIndex<0 || slotIndex>=items.Length) return;
#endif #endif
Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5, Rectangle containerRect = new Rectangle(rect.X - 5, rect.Y - (40 + 10) * itemCapacity - 5,
rect.Width + 10, rect.Height + (40 + 10) * itemCapacity + 10); rect.Width + 10, rect.Height + (40 + 10) * itemCapacity + 10);
Rectangle subRect = rect; Rectangle subRect = rect;
subRect.Height = 40; subRect.Height = 40;
selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1; selectedSlot = containerRect.Contains(PlayerInput.MousePosition) ? slotIndex : -1;
System.Diagnostics.Debug.WriteLine(selectedSlot); System.Diagnostics.Debug.WriteLine(selectedSlot);
GUI.DrawRectangle(spriteBatch, containerRect, Color.Black*0.8f, true); GUI.DrawRectangle(spriteBatch, containerRect, Color.Black * 0.8f, true);
GUI.DrawRectangle(spriteBatch, containerRect, Color.White); GUI.DrawRectangle(spriteBatch, containerRect, Color.White);
Item[] containedItems = null; Item[] containedItems = null;
if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems; if (items[slotIndex] != null) containedItems = items[slotIndex].ContainedItems;
if (containedItems != null) if (containedItems != null)
{
for (int i = 0; i < itemCapacity; i++)
{ {
subRect.Y = subRect.Y - subRect.Height - 10; for (int i = 0; i < itemCapacity; i++)
UpdateSlot(spriteBatch, subRect, selectedSlot, i < containedItems.Count() ? containedItems[i] : null, true); {
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); DrawSlot(spriteBatch, rect, (draggingItem == item && !mouseOn) ? null : item, mouseOn, isSubSlot, drawItem);
+2 -2
View File
@@ -186,12 +186,12 @@ namespace Barotrauma
} }
//which type of inventory slots (head, torso, any, etc) the item can be placed in //which type of inventory slots (head, torso, any, etc) the item can be placed in
public LimbSlot AllowedSlots public List<LimbSlot> AllowedSlots
{ {
get get
{ {
Pickable p = GetComponent<Pickable>(); Pickable p = GetComponent<Pickable>();
return (p==null) ? LimbSlot.Any : p.AllowedSlots; return (p==null) ? new List<LimbSlot>() { LimbSlot.Any } : p.AllowedSlots;
} }
} }
+2 -1
View File
@@ -257,7 +257,8 @@ namespace Barotrauma
Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y); Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
Vector2 offset = -currentLocation.MapPosition; 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); //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); //Vector2 scale = new Vector2((float)rect.Width/ size, (float)rect.Height/size);
-10
View File
@@ -270,16 +270,6 @@ namespace Barotrauma.Particles
prefab.Sprites[spriteIndex].origin, drawRotation, prefab.Sprites[spriteIndex].origin, drawRotation,
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth); 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; prevPosition = position;
prevRotation = rotation; prevRotation = rotation;
} }
+4 -4
View File
@@ -28,19 +28,19 @@ namespace Barotrauma
{ {
using (var game = new GameMain()) using (var game = new GameMain())
{ {
//#if !DEBUG #if !DEBUG
try try
{ {
//#endif #endif
game.Run(); game.Run();
//#if !DEBUG #if !DEBUG
} }
catch (Exception e) catch (Exception e)
{ {
CrashDump(game, "crashreport.txt", e); CrashDump(game, "crashreport.txt", e);
} }
//#endif #endif
} }
} }
+3 -3
View File
@@ -203,7 +203,7 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.NonPremultiplied, BlendState.AlphaBlend,
SamplerState.LinearWrap, DepthStencilState.Default, null, null, SamplerState.LinearWrap, DepthStencilState.Default, null, null,
cam.Transform); cam.Transform);
@@ -249,7 +249,7 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied, BlendState.AlphaBlend,
null, DepthStencilState.Default, null, null, null, DepthStencilState.Default, null, null,
cam.Transform); cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend);
@@ -272,7 +272,7 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied, BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null, null, DepthStencilState.DepthRead, null, null,
cam.Transform); cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend);
Binary file not shown.