wifi wiring
This commit is contained in:
@@ -75,12 +75,28 @@ namespace Barotrauma
|
|||||||
client.SpectatePos = pos;
|
client.SpectatePos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetRadioRange(Character character, float range)
|
||||||
|
{
|
||||||
|
if(character.Inventory == null) { return; }
|
||||||
|
|
||||||
|
foreach(Item item in character.Inventory.AllItems)
|
||||||
|
{
|
||||||
|
if(item == null) { continue; }
|
||||||
|
|
||||||
|
if(item.Name == "Headset")
|
||||||
|
{
|
||||||
|
item.GetComponent<Items.Components.WifiComponent>().Range = range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LuaGame
|
public class LuaGame
|
||||||
{
|
{
|
||||||
LuaSetup env;
|
LuaSetup env;
|
||||||
|
|
||||||
|
public bool allowWifiChat = false;
|
||||||
public bool overrideTraitors = false;
|
public bool overrideTraitors = false;
|
||||||
public bool overrideRespawnSub = false;
|
public bool overrideRespawnSub = false;
|
||||||
|
|
||||||
@@ -119,6 +135,11 @@ namespace Barotrauma
|
|||||||
overrideRespawnSub = o;
|
overrideRespawnSub = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AllowWifiChat(bool o)
|
||||||
|
{
|
||||||
|
allowWifiChat = o;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Log(string message, ServerLog.MessageType type)
|
public static void Log(string message, ServerLog.MessageType type)
|
||||||
{
|
{
|
||||||
GameServer.Log(message, type);
|
GameServer.Log(message, type);
|
||||||
|
|||||||
@@ -62,8 +62,16 @@ namespace Barotrauma.Items.Components
|
|||||||
"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 LinkToChat;
|
||||||
|
#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. " +
|
||||||
@@ -167,9 +175,23 @@ 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,
|
|
||||||
power: 0.0f, strength: sentSignalStrength);
|
if (sentFromChat && wifiComp.LinkToChat)
|
||||||
|
{
|
||||||
|
|
||||||
|
//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