fix signalReceived hook not working correctly

This commit is contained in:
Evil Factory
2022-03-24 13:33:01 -03:00
parent d4dd6afec9
commit 61b8c132eb
2 changed files with 4 additions and 12 deletions

View File

@@ -473,20 +473,8 @@ namespace Barotrauma.Items.Components
//called then the item is dropped or dragged out of a "limbslot"
public virtual void Unequip(Character character) { }
Dictionary<string, string> lastSignal = new Dictionary<string, string>();
public virtual void ReceiveSignal(Signal signal, Connection connection)
{
#if SERVER
if (!lastSignal.ContainsValue(connection.Name) || lastSignal[connection.Name] != signal.value)
{
object[] obj = new object[] { signal, connection };
GameMain.Lua.hook.Call("signalReceived", obj);
GameMain.Lua.hook.Call("signalReceived." + item.prefab.Identifier, obj);
lastSignal[connection.Name] = signal.value;
}
#endif
switch (connection.Name)
{
case "activate":

View File

@@ -267,6 +267,10 @@ namespace Barotrauma.Items.Components
Connection connection = recipient;
object[] obj = new object[] { signal, connection };
GameMain.Lua.hook.Call("signalReceived", obj);
GameMain.Lua.hook.Call("signalReceived." + recipient.item.prefab.Identifier, obj);
foreach (ItemComponent ic in recipient.item.Components)
{
ic.ReceiveSignal(signal, connection);