refactor: no more dynvalues or userdatas
This commit is contained in:
@@ -441,7 +441,7 @@ namespace Barotrauma.Items.Components
|
||||
#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) });
|
||||
GameMain.Lua.hook.Call("signalReceived", new object[] { signal, connection });
|
||||
|
||||
lastSignal[connection.Name] = signal.value;
|
||||
}
|
||||
|
||||
@@ -187,10 +187,18 @@ namespace Barotrauma.Items.Components
|
||||
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) });
|
||||
var should = GameMain.Lua.hook.Call("wifiSignalTransmitted", new object[] { this, signal, sentFromChat });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
return;
|
||||
if (should != null)
|
||||
{
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool chatMsgSent = false;
|
||||
|
||||
@@ -2226,11 +2226,17 @@ namespace Barotrauma
|
||||
if (condition == 0.0f) { return; }
|
||||
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemUse", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(character), LuaSetup.CreateUserDataSafe(targetLimb) });
|
||||
var should = GameMain.Lua.hook.Call("itemUse", new object[] { this, character, targetLimb });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2268,11 +2274,17 @@ namespace Barotrauma
|
||||
if (condition == 0.0f) { return; }
|
||||
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemSecondaryUse", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(character)});
|
||||
var should = GameMain.Lua.hook.Call("itemSecondaryUse", new object[] { this, character});
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2308,11 +2320,17 @@ namespace Barotrauma
|
||||
public void ApplyTreatment(Character user, Character character, Limb targetLimb)
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemApplyTreatment", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(user), LuaSetup.CreateUserDataSafe(character), LuaSetup.CreateUserDataSafe(targetLimb) });
|
||||
var should = GameMain.Lua.hook.Call("itemApplyTreatment", new object[] { this, user, character, targetLimb });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2373,11 +2391,17 @@ namespace Barotrauma
|
||||
public void Drop(Character dropper, bool createNetworkEvent = true)
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemDrop", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(dropper)});
|
||||
var should = GameMain.Lua.hook.Call("itemDrop", new object[] { this, dropper});
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2432,11 +2456,17 @@ namespace Barotrauma
|
||||
public void Equip(Character character)
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemEquip", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(character)});
|
||||
var should = GameMain.Lua.hook.Call("itemEquip", new object[] { this, character});
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2452,11 +2482,17 @@ namespace Barotrauma
|
||||
public void Unequip(Character character)
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("itemUnequip", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(character)});
|
||||
var should = GameMain.Lua.hook.Call("itemUnequip", new object[] { this, character });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user