LimbSlot combinations for pickable items ("Any,RightHand+LeftHand"...)
This commit is contained in:
@@ -740,9 +740,6 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Content\Particles\blood.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Particles\bubbles.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<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
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<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">
|
||||
<Fire/>
|
||||
</StatusEffect>
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
<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="Waist" sourcerect="81,0,30,26" origin="0.5,0.45" hidelimb="true"/>
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
<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="Waist" sourcerect="81,77,30,26" origin="0.5,0.45" hidelimb="true"/>
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<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">
|
||||
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
|
||||
</StatusEffect>
|
||||
@@ -33,7 +30,12 @@
|
||||
<Wearable limbtype="Head" slots="Any,Head">
|
||||
<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="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>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="true">
|
||||
@@ -52,7 +54,7 @@
|
||||
|
||||
<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="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"/>
|
||||
|
||||
<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>
|
||||
|
||||
<ItemContainer capacity="1" hideitems="true">
|
||||
<Containable name="Oxygen Tank"/>
|
||||
<Containable name="Welding Fuel Tank"/>
|
||||
</ItemContainer>
|
||||
</Item>
|
||||
|
||||
@@ -86,9 +95,9 @@
|
||||
|
||||
<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">
|
||||
<RequiredItems name="Battery Cell" type="Contained" msg="Battery Cell required"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<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 -->
|
||||
<Holdable slots="Any,BothHands" controlpose="true"
|
||||
<Holdable slots="Any,RightHand+LeftHand" controlpose="true"
|
||||
aimpos="50,0" handle1="-17,0" handle2="8,0"/>
|
||||
|
||||
<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"/>
|
||||
|
||||
<Holdable slots="Any,BothHands" controlpose="true"
|
||||
<Holdable slots="Any,RightHand+LeftHand" controlpose="true"
|
||||
aimpos="50,0" handle1="-12,4"/>
|
||||
|
||||
<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"/>
|
||||
|
||||
<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">
|
||||
<Explosion range="500.0" structuredamage="100" damage="200" stun="5" force="3.0"/>
|
||||
</StatusEffect>
|
||||
@@ -113,7 +110,7 @@
|
||||
|
||||
<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"/>
|
||||
|
||||
<RepairTool extinquishamount="30.0" range="300" barrelpos="21,25" particles="extinguisher" particlespeed="650.0">
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
<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">
|
||||
<Attack damage="100" bleedingdamage="10" structuredamage="200" damagetype="Blunt"/>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<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"/>
|
||||
|
||||
<RangedWeapon barrelpos="49,10">
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.3 KiB |
@@ -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<LimbSlot> allowedSlots = new List<LimbSlot>(item.AllowedSlots);
|
||||
allowedSlots.Remove(LimbSlot.Any);
|
||||
|
||||
inventory.TryPutItem(item, allowedSlots, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||
/// </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++)
|
||||
{
|
||||
//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<LimbSlot> 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<LimbSlot>() {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;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<LimbSlot> allowedSlots;
|
||||
|
||||
public LimbSlot AllowedSlots
|
||||
public List<LimbSlot> AllowedSlots
|
||||
{
|
||||
get { return allowedSlots; }
|
||||
}
|
||||
@@ -22,11 +23,26 @@ namespace Barotrauma.Items.Components
|
||||
public Pickable(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
allowedSlots = new List<LimbSlot>();
|
||||
|
||||
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;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||
/// </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);
|
||||
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<items.Length);
|
||||
System.Diagnostics.Debug.Assert(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);
|
||||
|
||||
@@ -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<LimbSlot> AllowedSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
Pickable p = GetComponent<Pickable>();
|
||||
return (p==null) ? LimbSlot.Any : p.AllowedSlots;
|
||||
return (p==null) ? new List<LimbSlot>() { LimbSlot.Any } : p.AllowedSlots;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user