Mid-round chat messages have a limited range, headset item which can be used to communicate with players further away, new inventory slot for items like masks and headsets
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Barotrauma
|
||||
[Flags]
|
||||
public enum LimbSlot
|
||||
{
|
||||
None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32
|
||||
None = 0, Any = 1, RightHand = 2, LeftHand = 4, Head = 8, Torso = 16, Legs = 32, Face=64
|
||||
};
|
||||
|
||||
class CharacterInventory : Inventory
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma
|
||||
private Character character;
|
||||
|
||||
public static LimbSlot[] limbSlots = new LimbSlot[] {
|
||||
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand,
|
||||
LimbSlot.Head, LimbSlot.Torso, LimbSlot.Legs, LimbSlot.LeftHand, LimbSlot.RightHand, LimbSlot.Face,
|
||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any,
|
||||
LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any, LimbSlot.Any};
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Barotrauma
|
||||
case 3:
|
||||
case 4:
|
||||
SlotPositions[i] = new Vector2(
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 3),
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 2),
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight)*3);
|
||||
|
||||
useOnSelfButton[i - 3] = new GUIButton(
|
||||
@@ -70,11 +70,17 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
|
||||
break;
|
||||
case 5:
|
||||
SlotPositions[i] = new Vector2(
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * (i - 5),
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight) * 3);
|
||||
|
||||
break;
|
||||
default:
|
||||
SlotPositions[i] = new Vector2(
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 3)%5),
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight) * ((i>9) ? 2 : 1));
|
||||
spacing * 2 + rectWidth + (spacing + rectWidth) * ((i - 6)%5),
|
||||
GameMain.GraphicsHeight - (spacing + rectHeight) * ((i>10) ? 2 : 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -298,6 +304,13 @@ namespace Barotrauma
|
||||
new Vector2(18.0f, 20.0f), Vector2.One,
|
||||
SpriteEffects.None, 0.1f);
|
||||
}
|
||||
else if (i==5)
|
||||
{
|
||||
spriteBatch.Draw(icons, new Vector2(slotRect.Center.X, slotRect.Center.Y),
|
||||
new Rectangle(57,0,31,32), Color.White * 0.7f, 0.0f,
|
||||
new Vector2(15.0f, 16.0f), Vector2.One,
|
||||
SpriteEffects.None, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
@@ -334,7 +347,7 @@ namespace Barotrauma
|
||||
highlightedSlot = slotRect;
|
||||
}
|
||||
|
||||
UpdateSlot(spriteBatch, slotRect, i, Items[i], false, i>4 ? 0.2f : 0.4f);
|
||||
UpdateSlot(spriteBatch, slotRect, i, Items[i], false, i>5 ? 0.2f : 0.4f);
|
||||
|
||||
if (draggingItem!=null && draggingItem == Items[i]) draggingItemSlot = slotRect;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -6,11 +8,19 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class WifiComponent : ItemComponent
|
||||
{
|
||||
|
||||
private static List<WifiComponent> list = new List<WifiComponent>();
|
||||
|
||||
private float range;
|
||||
|
||||
private int channel;
|
||||
|
||||
[HasDefaultValue(20000.0f, false)]
|
||||
public float Range
|
||||
{
|
||||
get { return range; }
|
||||
set { range = Math.Max(value, 0.0f); }
|
||||
}
|
||||
|
||||
[InGameEditable, HasDefaultValue(1, true)]
|
||||
public int Channel
|
||||
{
|
||||
@@ -21,24 +31,66 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
[Editable, HasDefaultValue(false, false)]
|
||||
public bool LinkToChat
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public WifiComponent(Item item, XElement element)
|
||||
: base (item, element)
|
||||
{
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
public void Transmit(string signal)
|
||||
{
|
||||
if (!HasRequiredContainedItems(true)) return;
|
||||
|
||||
var receivers = GetReceiversInRange();
|
||||
foreach (WifiComponent w in receivers)
|
||||
{
|
||||
var connections = w.item.Connections;
|
||||
|
||||
w.ReceiveSignal(1, signal, connections == null ? null : connections.Find(c => c.Name == "signal_in"), item);
|
||||
}
|
||||
}
|
||||
|
||||
private List<WifiComponent> GetReceiversInRange()
|
||||
{
|
||||
return list.FindAll(w =>
|
||||
w != this && w.channel == channel &&
|
||||
Vector2.Distance(item.WorldPosition, w.item.WorldPosition) <= Range);
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f)
|
||||
{
|
||||
//prevent an ininite loop of wificomponents sending messages between each other
|
||||
if (sender.GetComponent<WifiComponent>()!=null) return;
|
||||
if (!HasRequiredContainedItems(false)) return;
|
||||
|
||||
if (LinkToChat)
|
||||
{
|
||||
if (item.ParentInventory != null &&
|
||||
item.ParentInventory.Owner != null &&
|
||||
item.ParentInventory.Owner == Character.Controlled &&
|
||||
GameMain.NetworkMember != null)
|
||||
{
|
||||
signal = ChatMessage.ApplyDistanceEffect(item, sender, signal, range);
|
||||
|
||||
GameMain.NetworkMember.AddChatMessage(signal, ChatMessageType.Radio);
|
||||
}
|
||||
}
|
||||
|
||||
if (connection == null) return;
|
||||
|
||||
switch (connection.Name)
|
||||
{
|
||||
case "signal_in":
|
||||
foreach (WifiComponent wifiComp in list)
|
||||
var receivers = GetReceiversInRange();
|
||||
|
||||
foreach (WifiComponent wifiComp in receivers)
|
||||
{
|
||||
if (wifiComp == this || wifiComp.channel != channel) continue;
|
||||
wifiComp.item.SendSignal(stepsTaken, signal, "signal_out");
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user