plenty of new things
This commit is contained in:
@@ -5,6 +5,7 @@ using MoonSharp.Interpreter;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Barotrauma.Items.Components;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -125,18 +126,24 @@ namespace Barotrauma
|
|||||||
public bool allowWifiChat = false;
|
public bool allowWifiChat = false;
|
||||||
public bool overrideTraitors = false;
|
public bool overrideTraitors = false;
|
||||||
public bool overrideRespawnSub = false;
|
public bool overrideRespawnSub = false;
|
||||||
|
public bool overrideSignalRadio = false;
|
||||||
|
public bool disableSpamFilter = false;
|
||||||
|
|
||||||
public LuaGame(LuaSetup e)
|
public LuaGame(LuaSetup e)
|
||||||
{
|
{
|
||||||
env = e;
|
env = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendMessage(string msg, ChatMessageType messageType = ChatMessageType.Server, Client sender = null, Character character = null)
|
public static void SendMessage(string msg, ChatMessageType? messageType = null, Client sender = null, Character character = null)
|
||||||
{
|
{
|
||||||
GameMain.Server.SendChatMessage(msg, messageType, sender, character);
|
GameMain.Server.SendChatMessage(msg, messageType, sender, character);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SendMessage(string msg, int messageType, Client sender = null, Character character = null)
|
||||||
|
{
|
||||||
|
GameMain.Server.SendChatMessage(msg, (ChatMessageType)messageType, sender, character);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SendTraitorMessage(Client client, string msg, string missionid, TraitorMessageType type)
|
public static void SendTraitorMessage(Client client, string msg, string missionid, TraitorMessageType type)
|
||||||
{
|
{
|
||||||
GameMain.Server.SendTraitorMessage(client, msg, missionid, type);
|
GameMain.Server.SendTraitorMessage(client, msg, missionid, type);
|
||||||
@@ -152,6 +159,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SendDirectChatMessage(ChatMessage chatMessage, Client client)
|
||||||
|
{
|
||||||
|
GameMain.Server.SendDirectChatMessage(chatMessage, client);
|
||||||
|
}
|
||||||
|
|
||||||
public void OverrideTraitors(bool o)
|
public void OverrideTraitors(bool o)
|
||||||
{
|
{
|
||||||
overrideTraitors = o;
|
overrideTraitors = o;
|
||||||
@@ -167,6 +179,16 @@ namespace Barotrauma
|
|||||||
allowWifiChat = o;
|
allowWifiChat = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OverrideSignalRadio(bool o)
|
||||||
|
{
|
||||||
|
overrideSignalRadio = o;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableSpamFilter(bool o)
|
||||||
|
{
|
||||||
|
disableSpamFilter = 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);
|
||||||
@@ -259,6 +281,16 @@ namespace Barotrauma
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WifiComponent GetWifiComponent(Item item)
|
||||||
|
{
|
||||||
|
return item.GetComponent<WifiComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LightComponent GetLightComponent(Item item)
|
||||||
|
{
|
||||||
|
return item.GetComponent<LightComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
public static void DispatchRespawnSub()
|
public static void DispatchRespawnSub()
|
||||||
{
|
{
|
||||||
GameMain.Server.RespawnManager.DispatchShuttle();
|
GameMain.Server.RespawnManager.DispatchShuttle();
|
||||||
@@ -279,6 +311,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
GameMain.Server.StartGame();
|
GameMain.Server.StartGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Signal CreateSignal(string value, int stepsTaken = 1, Character sender = null, Item source = null, float power = 0, float strength = 1)
|
||||||
|
{
|
||||||
|
return new Signal(value, stepsTaken, sender, source, power, strength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Barotrauma.Networking;
|
|||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Barotrauma.Items.Components;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -139,9 +140,18 @@ namespace Barotrauma
|
|||||||
UserData.RegisterType<MapEntity>();
|
UserData.RegisterType<MapEntity>();
|
||||||
UserData.RegisterType<CauseOfDeath>();
|
UserData.RegisterType<CauseOfDeath>();
|
||||||
UserData.RegisterType<CharacterTeamType>();
|
UserData.RegisterType<CharacterTeamType>();
|
||||||
|
UserData.RegisterType<Signal>();
|
||||||
|
UserData.RegisterType<Connection>();
|
||||||
|
UserData.RegisterType<ItemComponent>();
|
||||||
|
UserData.RegisterType<WifiComponent>();
|
||||||
|
UserData.RegisterType<LightComponent>();
|
||||||
|
UserData.RegisterType<Inventory>();
|
||||||
|
UserData.RegisterType<CharacterInventory>();
|
||||||
|
UserData.RegisterType<Hull>();
|
||||||
|
UserData.RegisterType<Gap>();
|
||||||
|
|
||||||
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);
|
lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods);
|
||||||
|
|
||||||
lua.Options.DebugPrint = PrintMessage;
|
lua.Options.DebugPrint = PrintMessage;
|
||||||
|
|
||||||
lua.Options.ScriptLoader = luaScriptLoader;
|
lua.Options.ScriptLoader = luaScriptLoader;
|
||||||
@@ -169,14 +179,14 @@ namespace Barotrauma
|
|||||||
lua.Globals["TraitorMessageType"] = UserData.CreateStatic<TraitorMessageType>();
|
lua.Globals["TraitorMessageType"] = UserData.CreateStatic<TraitorMessageType>();
|
||||||
lua.Globals["CauseOfDeathType"] = UserData.CreateStatic<CauseOfDeathType>();
|
lua.Globals["CauseOfDeathType"] = UserData.CreateStatic<CauseOfDeathType>();
|
||||||
lua.Globals["AfflictionPrefab"] = UserData.CreateStatic<AfflictionPrefab>();
|
lua.Globals["AfflictionPrefab"] = UserData.CreateStatic<AfflictionPrefab>();
|
||||||
lua.Globals["CharacterTeamType"] = UserData.CreateStatic<CharacterTeamType>();
|
lua.Globals["CharacterTeamType"] = UserData.CreateStatic<CharacterTeamType>();
|
||||||
|
|
||||||
lua.Globals["Vector2"] = UserData.CreateStatic<Vector2>();
|
lua.Globals["Vector2"] = UserData.CreateStatic<Vector2>();
|
||||||
lua.Globals["Vector3"] = UserData.CreateStatic<Vector3>();
|
lua.Globals["Vector3"] = UserData.CreateStatic<Vector3>();
|
||||||
lua.Globals["Vector4"] = UserData.CreateStatic<Vector3>();
|
lua.Globals["Vector4"] = UserData.CreateStatic<Vector3>();
|
||||||
lua.Globals["CreateVector2"] = (Func<float, float, Vector2>)CreateVector2;
|
lua.Globals["CreateVector2"] = (Func<float, float, Vector2>)CreateVector2;
|
||||||
lua.Globals["CreateVector3"] = (Func<float, float, float, Vector3>)CreateVector3;
|
lua.Globals["CreateVector3"] = (Func<float, float, float, Vector3>)CreateVector3;
|
||||||
lua.Globals["CreateVector4"] = (Func<float, float, float, float, Vector4>)CreateVector4;
|
lua.Globals["CreateVector4"] = (Func<float, float, float, float, Vector4>)CreateVector4;
|
||||||
|
lua.Globals["ChatMessage"] = UserData.CreateStatic<ChatMessage>();
|
||||||
|
|
||||||
foreach (string d in Directory.GetDirectories("Mods"))
|
foreach (string d in Directory.GetDirectories("Mods"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
bool isOwner = GameMain.Server.OwnerConnection != null && c.Connection == GameMain.Server.OwnerConnection;
|
bool isOwner = GameMain.Server.OwnerConnection != null && c.Connection == GameMain.Server.OwnerConnection;
|
||||||
|
|
||||||
if (similarity + c.ChatSpamSpeed > 5.0f && !isOwner)
|
if (similarity + c.ChatSpamSpeed > 5.0f && !isOwner && !GameMain.Lua.game.disableSpamFilter)
|
||||||
{
|
{
|
||||||
GameMain.Server.KarmaManager.OnSpamFilterTriggered(c);
|
GameMain.Server.KarmaManager.OnSpamFilterTriggered(c);
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma.Networking
|
namespace Barotrauma.Networking
|
||||||
{
|
{
|
||||||
@@ -3095,13 +3096,20 @@ namespace Barotrauma.Networking
|
|||||||
senderName = null;
|
senderName = null;
|
||||||
senderCharacter = null;
|
senderCharacter = null;
|
||||||
}
|
}
|
||||||
else if (type == ChatMessageType.Radio)
|
else if (type == ChatMessageType.Radio && !GameMain.Lua.game.overrideSignalRadio)
|
||||||
{
|
{
|
||||||
//send to chat-linked wifi components
|
//send to chat-linked wifi components
|
||||||
Signal s = new Signal(message, sender: senderCharacter, source: senderRadio.Item);
|
Signal s = new Signal(message, sender: senderCharacter, source: senderRadio.Item);
|
||||||
senderRadio.TransmitSignal(s, sentFromChat: true);
|
senderRadio.TransmitSignal(s, sentFromChat: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hookChatMsg = ChatMessage.Create(senderName, message, (ChatMessageType)type, senderCharacter, senderClient, changeType);
|
||||||
|
|
||||||
|
var should = GameMain.Lua.hook.Call("modifyChatMessage", new DynValue[] { UserData.Create(hookChatMsg), LuaSetup.CreateUserDataSafe(senderRadio) });
|
||||||
|
|
||||||
|
if (should != null && should.CastToBool())
|
||||||
|
return;
|
||||||
|
|
||||||
//check which clients can receive the message and apply distance effects
|
//check which clients can receive the message and apply distance effects
|
||||||
foreach (Client client in ConnectedClients)
|
foreach (Client client in ConnectedClients)
|
||||||
{
|
{
|
||||||
@@ -3134,6 +3142,7 @@ namespace Barotrauma.Networking
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var chatMsg = ChatMessage.Create(
|
var chatMsg = ChatMessage.Create(
|
||||||
senderName,
|
senderName,
|
||||||
modifiedMessage,
|
modifiedMessage,
|
||||||
@@ -3141,7 +3150,7 @@ namespace Barotrauma.Networking
|
|||||||
senderCharacter,
|
senderCharacter,
|
||||||
senderClient,
|
senderClient,
|
||||||
changeType);
|
changeType);
|
||||||
|
|
||||||
SendDirectChatMessage(chatMsg, client);
|
SendDirectChatMessage(chatMsg, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma.Networking
|
namespace Barotrauma.Networking
|
||||||
{
|
{
|
||||||
@@ -93,6 +94,11 @@ namespace Barotrauma.Networking
|
|||||||
ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
|
ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
|
||||||
ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
|
ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
|
||||||
{
|
{
|
||||||
|
var should = GameMain.Lua.hook.Call("canUseVoiceRadio", new DynValue[] { UserData.Create(sender), LuaSetup.CreateUserDataSafe(recipient) });
|
||||||
|
|
||||||
|
if (should != null)
|
||||||
|
return should.CastToBool();
|
||||||
|
|
||||||
if (recipientRadio.CanReceive(senderRadio)) { return true; }
|
if (recipientRadio.CanReceive(senderRadio)) { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Barotrauma.Extensions;
|
using Barotrauma.Extensions;
|
||||||
|
using Barotrauma;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Barotrauma.Sounds;
|
using Barotrauma.Sounds;
|
||||||
@@ -432,8 +434,18 @@ namespace Barotrauma.Items.Components
|
|||||||
//called then the item is dropped or dragged out of a "limbslot"
|
//called then the item is dropped or dragged out of a "limbslot"
|
||||||
public virtual void Unequip(Character character) { }
|
public virtual void Unequip(Character character) { }
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<string, string> lastSignal = new Dictionary<string, string>();
|
||||||
public virtual void ReceiveSignal(Signal signal, Connection connection)
|
public virtual void ReceiveSignal(Signal signal, Connection connection)
|
||||||
{
|
{
|
||||||
|
#if SERVER
|
||||||
|
if (!lastSignal.ContainsValue(connection.Name) || lastSignal[connection.Name] != signal.value)
|
||||||
|
{
|
||||||
|
GameMain.Lua.hook.Call("signalReceived", new DynValue[] { UserData.Create(signal), UserData.Create(connection) });
|
||||||
|
|
||||||
|
lastSignal[connection.Name] = signal.value;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
switch (connection.Name)
|
switch (connection.Name)
|
||||||
{
|
{
|
||||||
case "activate":
|
case "activate":
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
public struct Signal
|
struct Signal
|
||||||
{
|
{
|
||||||
internal string value;
|
public string value;
|
||||||
internal int stepsTaken;
|
public int stepsTaken;
|
||||||
internal Character sender;
|
public Character sender;
|
||||||
internal Item source;
|
public Item source;
|
||||||
internal float power;
|
public float power;
|
||||||
internal float strength;
|
public float strength;
|
||||||
|
|
||||||
internal Signal(string value, int stepsTaken = 0, Character sender = null,
|
internal Signal(string value, int stepsTaken = 0, Character sender = null,
|
||||||
Item source = null, float power = 0.0f, float strength = 1.0f)
|
Item source = null, float power = 0.0f, float strength = 1.0f)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -185,6 +186,13 @@ namespace Barotrauma.Items.Components
|
|||||||
var senderComponent = signal.source?.GetComponent<WifiComponent>();
|
var senderComponent = signal.source?.GetComponent<WifiComponent>();
|
||||||
if (senderComponent != null && !CanReceive(senderComponent)) { return; }
|
if (senderComponent != null && !CanReceive(senderComponent)) { return; }
|
||||||
|
|
||||||
|
#if SERVER
|
||||||
|
var should = GameMain.Lua.hook.Call("wifiSignalTransmitted", new DynValue[] { UserData.Create(this), UserData.Create(signal), DynValue.NewBoolean(sentFromChat) });
|
||||||
|
|
||||||
|
if (should != null && should.CastToBool())
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool chatMsgSent = false;
|
bool chatMsgSent = false;
|
||||||
|
|
||||||
var receivers = GetReceiversInRange();
|
var receivers = GetReceiversInRange();
|
||||||
@@ -243,6 +251,7 @@ namespace Barotrauma.Items.Components
|
|||||||
Client recipientClient = GameMain.Server.ConnectedClients.Find(c => c.Character == wifiComp.item.ParentInventory.Owner);
|
Client recipientClient = GameMain.Server.ConnectedClients.Find(c => c.Character == wifiComp.item.ParentInventory.Owner);
|
||||||
if (recipientClient != null)
|
if (recipientClient != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
GameMain.Server.SendDirectChatMessage(
|
GameMain.Server.SendDirectChatMessage(
|
||||||
ChatMessage.Create(signal.source?.Name ?? "", chatMsg, ChatMessageType.Radio, null), recipientClient);
|
ChatMessage.Create(signal.source?.Name ?? "", chatMsg, ChatMessageType.Radio, null), recipientClient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -648,6 +649,13 @@ namespace Barotrauma
|
|||||||
if (Math.Max(hull1.WorldSurface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.WorldSurface + hull2.WaveY[0]) > WorldRect.Y) { return; }
|
if (Math.Max(hull1.WorldSurface + hull1.WaveY[hull1.WaveY.Length - 1], hull2.WorldSurface + hull2.WaveY[0]) > WorldRect.Y) { return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SERVER
|
||||||
|
var should = GameMain.Lua.hook.Call("gapOxygenUpdate", new DynValue[] { UserData.Create(this), UserData.Create(hull1), UserData.Create(hull2) });
|
||||||
|
|
||||||
|
if (should != null && should.CastToBool())
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
float totalOxygen = hull1.Oxygen + hull2.Oxygen;
|
float totalOxygen = hull1.Oxygen + hull2.Oxygen;
|
||||||
float totalVolume = (hull1.Volume + hull2.Volume);
|
float totalVolume = (hull1.Volume + hull2.Volume);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Barotrauma.Networking
|
|||||||
new Color(255, 128, 0) //order
|
new Color(255, 128, 0) //order
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly string Text;
|
public string Text;
|
||||||
|
|
||||||
private string translatedText;
|
private string translatedText;
|
||||||
public string TranslatedText
|
public string TranslatedText
|
||||||
@@ -74,8 +74,8 @@ namespace Barotrauma.Networking
|
|||||||
public PlayerConnectionChangeType ChangeType;
|
public PlayerConnectionChangeType ChangeType;
|
||||||
public string IconStyle;
|
public string IconStyle;
|
||||||
|
|
||||||
public readonly Character Sender;
|
public Character Sender;
|
||||||
public readonly Client SenderClient;
|
public Client SenderClient;
|
||||||
|
|
||||||
public readonly string SenderName;
|
public readonly string SenderName;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user