Unequipped headsets can't be used and don't consume batteries. Closes #272

This commit is contained in:
Joonas Rikkonen
2018-02-22 15:08:38 +02:00
parent 1fe2a1916f
commit 671f59e984
2 changed files with 7 additions and 10 deletions

View File

@@ -16,15 +16,12 @@
</WifiComponent>
<ItemContainer capacity="1" hideitems="true">
<Containable name="Battery Cell">
<StatusEffect type="OnContaining" target="Contained" Condition="-0.05"/>
</Containable>
<Containable name="Fulgurium Battery Cell">
<StatusEffect type="OnContaining" target="Contained" Condition="-0.05"/>
</Containable>
<Containable name="Battery Cell"/>
<Containable name="Fulgurium Battery Cell"/>
</ItemContainer>
<Wearable limbtype="Head" slots="Any,Face">
<StatusEffect type="OnWearing" target="Contained" Condition="-0.05"/>
<sprite texture="headset.png" limb="Head" origin="0.5,0.5"/>
</Wearable>
</Item>

View File

@@ -1777,7 +1777,7 @@ namespace Barotrauma.Networking
//return if senderCharacter doesn't have a working radio
var radio = senderCharacter.Inventory.Items.FirstOrDefault(i => i != null && i.GetComponent<WifiComponent>() != null);
if (radio == null) return;
if (radio == null || !senderCharacter.HasEquippedItem(radio)) return;
senderRadio = radio.GetComponent<WifiComponent>();
if (!senderRadio.CanTransmit()) return;
@@ -1866,10 +1866,10 @@ namespace Barotrauma.Networking
{
var receiverItem = receiver.Inventory.Items.FirstOrDefault(i => i?.GetComponent<WifiComponent>() != null);
//client doesn't have a radio -> don't send
if (receiverItem == null) return "";
if (receiverItem == null || !receiver.HasEquippedItem(receiverItem)) return "";
var senderItem = sender.Inventory.Items.FirstOrDefault(i => i?.GetComponent<WifiComponent>() != null);
if (senderItem == null) return "";
if (senderItem == null || !sender.HasEquippedItem(senderItem)) return "";
var receiverRadio = receiverItem.GetComponent<WifiComponent>();
var senderRadio = senderItem.GetComponent<WifiComponent>();