plenty of new things

This commit is contained in:
Evil Factory
2021-08-15 17:17:49 -03:00
parent 06f40fa368
commit a2cb256aa6
10 changed files with 109 additions and 18 deletions
@@ -1,13 +1,13 @@
namespace Barotrauma.Items.Components
{
public struct Signal
struct Signal
{
internal string value;
internal int stepsTaken;
internal Character sender;
internal Item source;
internal float power;
internal float strength;
public string value;
public int stepsTaken;
public Character sender;
public Item source;
public float power;
public float strength;
internal Signal(string value, int stepsTaken = 0, Character sender = null,
Item source = null, float power = 0.0f, float strength = 1.0f)
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml.Linq;
using MoonSharp.Interpreter;
namespace Barotrauma.Items.Components
{
@@ -185,6 +186,13 @@ namespace Barotrauma.Items.Components
var senderComponent = signal.source?.GetComponent<WifiComponent>();
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;
var receivers = GetReceiversInRange();
@@ -243,6 +251,7 @@ namespace Barotrauma.Items.Components
Client recipientClient = GameMain.Server.ConnectedClients.Find(c => c.Character == wifiComp.item.ParentInventory.Owner);
if (recipientClient != null)
{
GameMain.Server.SendDirectChatMessage(
ChatMessage.Create(signal.source?.Name ?? "", chatMsg, ChatMessageType.Radio, null), recipientClient);
}