refactor: no more dynvalues or userdatas
This commit is contained in:
@@ -714,11 +714,14 @@ namespace Barotrauma
|
||||
|
||||
#if SERVER
|
||||
|
||||
var should = GameMain.Lua.hook.Call("changeFallDamage", new DynValue[] { DynValue.NewNumber(impactDamage), LuaSetup.CreateUserDataSafe(character), LuaSetup.CreateUserDataSafe(impactPos), LuaSetup.CreateUserDataSafe(velocity) });
|
||||
var should = GameMain.Lua.hook.Call("changeFallDamage", new object[] { impactDamage, character, impactPos, velocity });
|
||||
|
||||
if (should != null)
|
||||
{
|
||||
impactDamage = (float)should.CastToNumber();
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
impactDamage = (float)dyn.CastToNumber();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3810,7 +3810,7 @@ namespace Barotrauma
|
||||
|
||||
|
||||
#if SERVER
|
||||
GameMain.Lua.hook.Call("characterDeath", new MoonSharp.Interpreter.DynValue[] { MoonSharp.Interpreter.UserData.Create(this) });
|
||||
GameMain.Lua.hook.Call("characterDeath", new object[] { this });
|
||||
#endif
|
||||
}
|
||||
partial void KillProjSpecific(CauseOfDeathType causeOfDeath, Affliction causeOfDeathAffliction, bool log);
|
||||
|
||||
@@ -410,11 +410,17 @@ namespace Barotrauma
|
||||
if (targetLimb == null)
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(affliction) });
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new object[] { this, affliction });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -428,11 +434,17 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { UserData.Create(this), UserData.Create(affliction), UserData.Create(targetLimb) });
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new object[] { this, affliction, targetLimb });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -442,11 +454,17 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { UserData.Create(this), UserData.Create(affliction)});
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new object[] { this, affliction });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -527,11 +545,17 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new DynValue[] { LuaSetup.CreateUserDataSafe(this), LuaSetup.CreateUserDataSafe(attackResult), LuaSetup.CreateUserDataSafe(hitLimb) });
|
||||
var should = GameMain.Lua.hook.Call("afflictionApplied", new object[] { this, attackResult, hitLimb });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
if (should != null)
|
||||
{
|
||||
return;
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma
|
||||
CrewManager?.Update(deltaTime);
|
||||
|
||||
#if SERVER
|
||||
GameMain.Lua.hook.Call("update", new DynValue[] { DynValue.NewNumber(deltaTime) });
|
||||
GameMain.Lua.hook.Call("update", new object[] { deltaTime });
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -651,10 +651,18 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
#if SERVER
|
||||
var should = GameMain.Lua.hook.Call("gapOxygenUpdate", new DynValue[] { UserData.Create(this), UserData.Create(hull1), UserData.Create(hull2) });
|
||||
var should = GameMain.Lua.hook.Call("gapOxygenUpdate", new object[] { this, hull1, hull2 });
|
||||
|
||||
if (should != null && should.CastToBool())
|
||||
return;
|
||||
if (should != null)
|
||||
{
|
||||
if (should is DynValue dyn)
|
||||
{
|
||||
if (dyn.CastToBool())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
float totalOxygen = hull1.Oxygen + hull2.Oxygen;
|
||||
|
||||
Reference in New Issue
Block a user