Update WifiComponent.cs
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -58,22 +58,13 @@ namespace Barotrauma.Items.Components
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConditionallyEditable(ConditionallyEditable.ConditionType.AllowLinkingWifiToChat)]
|
||||||
|
[Serialize(false, false, description: "If enabled, any signals received from another chat-linked wifi component are displayed " +
|
||||||
[Editable, Serialize(false, false, description: "If enabled, any signals received from another chat-linked wifi component are displayed " +
|
|
||||||
"as chat messages in the chatbox of the player holding the item.", alwaysUseInstanceValues: true)]
|
"as chat messages in the chatbox of the player holding the item.", alwaysUseInstanceValues: true)]
|
||||||
public bool LinkToChat
|
public bool LinkToChat
|
||||||
{
|
{
|
||||||
get
|
get;
|
||||||
{
|
set;
|
||||||
#if SERVER
|
|
||||||
return GameMain.Lua.game.allowWifiChat;
|
|
||||||
#endif
|
|
||||||
#if CLIENT
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
set { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Editable, Serialize(1.0f, true, description: "How many seconds have to pass between signals for a message to be displayed in the chatbox. " +
|
[Editable, Serialize(1.0f, true, description: "How many seconds have to pass between signals for a message to be displayed in the chatbox. " +
|
||||||
@@ -93,7 +84,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WifiComponent(Item item, XElement element)
|
public WifiComponent(Item item, XElement element)
|
||||||
: base(item, element)
|
: base (item, element)
|
||||||
{
|
{
|
||||||
list.Add(this);
|
list.Add(this);
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
@@ -177,23 +168,9 @@ namespace Barotrauma.Items.Components
|
|||||||
//signal strength diminishes by distance
|
//signal strength diminishes by distance
|
||||||
float sentSignalStrength = signal.strength *
|
float sentSignalStrength = signal.strength *
|
||||||
MathHelper.Clamp(1.0f - (Vector2.Distance(item.WorldPosition, wifiComp.item.WorldPosition) / wifiComp.range), 0.0f, 1.0f);
|
MathHelper.Clamp(1.0f - (Vector2.Distance(item.WorldPosition, wifiComp.item.WorldPosition) / wifiComp.range), 0.0f, 1.0f);
|
||||||
|
Signal s = new Signal(signal.value, signal.stepsTaken, sender: signal.sender, source: signal.source,
|
||||||
if (sentFromChat && wifiComp.LinkToChat)
|
power: 0.0f, strength: sentSignalStrength);
|
||||||
{
|
|
||||||
|
|
||||||
//Signal s = new Signal(signal.value, signal.stepsTaken, sender: null, source: null, power: 0.0f, strength: sentSignalStrength);
|
|
||||||
|
|
||||||
signal.source = null;
|
|
||||||
|
|
||||||
wifiComp.item.SendSignal(signal, "signal_out");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Signal s = new Signal(signal.value, signal.stepsTaken, sender: signal.sender, source: signal.source, power: 0.0f, strength: sentSignalStrength);
|
|
||||||
|
|
||||||
wifiComp.item.SendSignal(s, "signal_out");
|
wifiComp.item.SendSignal(s, "signal_out");
|
||||||
}
|
|
||||||
|
|
||||||
if (signal.source != null)
|
if (signal.source != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user