rebase to origin/unstable-tests
This commit is contained in:
@@ -341,7 +341,7 @@ namespace Barotrauma
|
||||
|
||||
if (levelData.HasBeaconStation && !levelData.IsBeaconActive)
|
||||
{
|
||||
var beaconMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Any(t => t.Equals("beaconnoreward", StringComparison.OrdinalIgnoreCase)));
|
||||
var beaconMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Any(t => t.Equals("beaconnoreward", StringComparison.OrdinalIgnoreCase))).OrderBy(m => m.UintIdentifier);
|
||||
if (beaconMissionPrefabs.Any())
|
||||
{
|
||||
Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed));
|
||||
@@ -354,7 +354,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (levelData.HasHuntingGrounds)
|
||||
{
|
||||
var huntingGroundsMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase)));
|
||||
var huntingGroundsMissionPrefabs = MissionPrefab.Prefabs.Where(m => m.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase))).OrderBy(m => m.UintIdentifier);
|
||||
if (!huntingGroundsMissionPrefabs.Any())
|
||||
{
|
||||
DebugConsole.AddWarning("Could not find a hunting grounds mission for the level. No mission with the tag \"huntinggrounds\" found.");
|
||||
|
||||
@@ -397,11 +397,6 @@ namespace Barotrauma.Items.Components
|
||||
//Only add valid connections
|
||||
if (otherC.Grid != grid && (otherC.Grid == null || !Grids.ContainsKey(otherC.Grid.ID)) && ValidPowerConnection(c, otherC))
|
||||
{
|
||||
if (otherC.Item.Condition <= 0.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
otherC.Grid = grid; //Assigning ID early prevents unncessary adding to stack
|
||||
probeStack.Push(otherC);
|
||||
}
|
||||
@@ -665,7 +660,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public static bool ValidPowerConnection(Connection conn1, Connection conn2)
|
||||
{
|
||||
return conn1.IsPower && conn2.IsPower && (conn1.Item.HasTag("junctionbox") || conn2.Item.HasTag("junctionbox") || conn1.Item.HasTag("dock") || conn2.Item.HasTag("dock") || conn1.IsOutput != conn2.IsOutput);
|
||||
return
|
||||
conn1.IsPower && conn2.IsPower &&
|
||||
conn1.Item.Condition > 0.0f && conn2.Item.Condition > 0.0f &&
|
||||
(conn1.Item.HasTag("junctionbox") || conn2.Item.HasTag("junctionbox") || conn1.Item.HasTag("dock") || conn2.Item.HasTag("dock") || conn1.IsOutput != conn2.IsOutput);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
|
||||
|
||||
if (Voltage > OverloadVoltage && CanBeOverloaded)
|
||||
if (Voltage > OverloadVoltage && CanBeOverloaded && item.Repairables.Any())
|
||||
{
|
||||
item.Condition = 0.0f;
|
||||
}
|
||||
|
||||
@@ -957,7 +957,18 @@ namespace Barotrauma
|
||||
|
||||
public PriceInfo GetPriceInfo(Location.StoreInfo store)
|
||||
{
|
||||
if (!store.Identifier.IsEmpty && StorePrices != null && StorePrices.TryGetValue(store.Identifier, out var storePriceInfo))
|
||||
if (store == null)
|
||||
{
|
||||
string message = $"Tried to get price info for \"{Identifier}\" with a null store parameter!\n{Environment.StackTrace.CleanupStackTrace()}";
|
||||
#if DEBUG
|
||||
DebugConsole.ShowError(message);
|
||||
#else
|
||||
DebugConsole.AddWarning(message);
|
||||
GameAnalyticsManager.AddErrorEventOnce("ItemPrefab.GetPriceInfo:StoreParameterNull", GameAnalyticsManager.ErrorSeverity.Error, message);
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
else if (!store.Identifier.IsEmpty && StorePrices != null && StorePrices.TryGetValue(store.Identifier, out var storePriceInfo))
|
||||
{
|
||||
return storePriceInfo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class LuaRequire {
|
||||
private Script lua { get; set; }
|
||||
private Dictionary<Tuple<string, Table>, DynValue> LoadedModules { get; set; }
|
||||
|
||||
private bool GetExistingReturnValue(Tuple<string, Table> key, ref DynValue returnValue) {
|
||||
return LoadedModules.TryGetValue(key, out returnValue);
|
||||
}
|
||||
|
||||
private void ExecuteModule(Tuple<string, Table> key, ref DynValue returnValue) {
|
||||
string moduleName = key.Item1;
|
||||
Table globalContext = key.Item2;
|
||||
returnValue = lua.Call(lua.RequireModule(moduleName, globalContext));
|
||||
LoadedModules[key] = returnValue;
|
||||
}
|
||||
|
||||
// Lua modules that have been previously loaded by require() will
|
||||
// not be loaded again; instead, their initial return value is
|
||||
// preserved and returned again on subsequent attempts.
|
||||
public DynValue Require(string moduleName, Table globalContext) {
|
||||
DynValue returnValue = DynValue.Nil;
|
||||
var key = new Tuple<string, Table>(moduleName, globalContext);
|
||||
|
||||
if (GetExistingReturnValue(key, ref returnValue)) return returnValue;
|
||||
ExecuteModule(key, ref returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public LuaRequire(Script lua) {
|
||||
this.lua = lua;
|
||||
LoadedModules = new Dictionary<Tuple<string, Table>, DynValue>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ namespace Barotrauma
|
||||
public LuaCsHook Hook { get; private set; }
|
||||
public LuaCsNetworking Networking { get; private set; }
|
||||
public LuaCsModStore ModStore { get; private set; }
|
||||
private LuaRequire require { get; set; }
|
||||
|
||||
public CsScriptLoader CsScriptLoader { get; private set; }
|
||||
public CsLua Lua { get; private set; }
|
||||
@@ -71,9 +72,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
public static ContentPackage GetPackage(Identifier name)
|
||||
public static ContentPackage GetPackage(Identifier name, bool fallbackToAll = true)
|
||||
{
|
||||
foreach (ContentPackage package in ContentPackageManager.LocalPackages)
|
||||
foreach (ContentPackage package in ContentPackageManager.EnabledPackages.All)
|
||||
{
|
||||
if (package.NameMatches(name))
|
||||
{
|
||||
@@ -81,11 +82,22 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ContentPackage package in ContentPackageManager.AllPackages)
|
||||
if (fallbackToAll)
|
||||
{
|
||||
if (package.NameMatches(name))
|
||||
foreach (ContentPackage package in ContentPackageManager.LocalPackages)
|
||||
{
|
||||
return package;
|
||||
if (package.NameMatches(name))
|
||||
{
|
||||
return package;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ContentPackage package in ContentPackageManager.AllPackages)
|
||||
{
|
||||
if (package.NameMatches(name))
|
||||
{
|
||||
return package;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,22 +276,18 @@ namespace Barotrauma
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private DynValue Require(string modname, Table globalContext)
|
||||
public DynValue Require(string moduleName, Table globalContexts)
|
||||
{
|
||||
try
|
||||
{
|
||||
return lua.Call(lua.RequireModule(modname, globalContext));
|
||||
|
||||
return require.Require(moduleName, globalContexts);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
HandleException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public object CallLuaFunction(object function, params object[] arguments)
|
||||
{
|
||||
try
|
||||
@@ -362,6 +370,8 @@ namespace Barotrauma
|
||||
Lua = new CsLua(this);
|
||||
CsScript = new CsScriptRunner(this);
|
||||
|
||||
require = new LuaRequire(lua);
|
||||
|
||||
Game = new LuaGame();
|
||||
Networking = new LuaCsNetworking();
|
||||
Hook.Initialize();
|
||||
|
||||
@@ -153,7 +153,10 @@ namespace Barotrauma
|
||||
{
|
||||
Name = TextManager.GetWithVariable("wreckeditemformat", "[name]", Name);
|
||||
}
|
||||
Name = Name.Fallback(OriginalName);
|
||||
if (!string.IsNullOrEmpty(OriginalName))
|
||||
{
|
||||
Name = Name.Fallback(OriginalName);
|
||||
}
|
||||
|
||||
var tags = new HashSet<Identifier>();
|
||||
string joinedTags = element.GetAttributeString("tags", "");
|
||||
|
||||
@@ -1229,6 +1229,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!connectedSubs.Contains(item.Submarine)) { continue; }
|
||||
if (!item.HasTag("cargocontainer")) { continue; }
|
||||
if (item.NonInteractable || item.HiddenInGame) { continue; }
|
||||
var itemContainer = item.GetComponent<ItemContainer>();
|
||||
if (itemContainer == null) { continue; }
|
||||
int emptySlots = 0;
|
||||
|
||||
Reference in New Issue
Block a user