Fixing stuff part 1
This commit is contained in:
@@ -270,7 +270,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
otherClients = new List<Client>();
|
||||
|
||||
serverSettings = new ServerSettings(this, "Server", 0, 0, 0, false, false);
|
||||
serverSettings = new ServerSettings(this, "Server", 0, 0, 0, false, false, System.Net.IPAddress.Any);
|
||||
Voting = new Voting();
|
||||
|
||||
if (steamId == 0)
|
||||
|
||||
@@ -386,7 +386,7 @@ namespace Barotrauma
|
||||
#endif
|
||||
|
||||
new GUIButton(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(20, 50) },
|
||||
"Remove Client-Side Lua", style: "MainMenuGUIButton", color: GUI.Style.Red)
|
||||
"Remove Client-Side Lua", style: "MainMenuGUIButton", color: GUIStyle.Red)
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
UserData = Tab.Empty,
|
||||
@@ -407,7 +407,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side Lua?", new string[] { "Remove", "Cancel" });
|
||||
var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side Lua?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
|
||||
|
||||
msg.Buttons[0].OnClicked = (GUIButton button, object obj) =>
|
||||
{
|
||||
|
||||
@@ -1252,7 +1252,7 @@ namespace Barotrauma
|
||||
|
||||
commands.Add(new Command("install_cl_lua", "Installs client-Side Lua into your client.", (string[] args) =>
|
||||
{
|
||||
if (!File.Exists("Mods/LuaForBarotrauma/clientside_files.zip"))
|
||||
if (!System.IO.File.Exists("Mods/LuaForBarotrauma/clientside_files.zip"))
|
||||
{
|
||||
GameMain.Server.SendChatMessage("clientside_files.zip doesn't exist, Github version?", ChatMessageType.ServerMessageBox);
|
||||
|
||||
|
||||
@@ -83,47 +83,12 @@ namespace Barotrauma
|
||||
return generic.Invoke(this, new object[]{comp, extraData });
|
||||
}
|
||||
}
|
||||
|
||||
partial class ItemPrefab
|
||||
{
|
||||
public static void AddToSpawnQueue(ItemPrefab itemPrefab, Vector2 position, object spawned = null)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, position, onSpawned: (Item item) =>
|
||||
{
|
||||
GameMain.Lua.CallFunction(spawned, new object[] { item });
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, object spawned = null)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, inventory, null, null, onSpawned: (Item item) =>
|
||||
{
|
||||
GameMain.Lua.CallFunction(spawned, new object[] { item });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
using Barotrauma.Networking;
|
||||
|
||||
partial class CustomInterface
|
||||
{
|
||||
public void UpdateClients()
|
||||
{
|
||||
|
||||
//notify all clients of the new state
|
||||
GameMain.Server.CreateEntityEvent(item, new object[]
|
||||
{
|
||||
NetEntityEvent.Type.ComponentState,
|
||||
item.GetComponentIndex(this)
|
||||
});
|
||||
|
||||
item.CreateServerEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
partial struct Signal
|
||||
{
|
||||
public static Signal Create(string value, int stepsTaken = 0, Character sender = null, Item source = null, float power = 0.0f, float strength = 1.0f)
|
||||
|
||||
@@ -82,8 +82,18 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoMod.Common" Version="22.3.24.1" />
|
||||
<PackageReference Include="RestSharp" Version="106.13.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>..\..\Libraries\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MoonSharp.Interpreter">
|
||||
<HintPath>..\..\Libraries\MoonSharp.Interpreter.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Sourced from https://stackoverflow.com/a/45248069 -->
|
||||
<Target Name="GetGitRevision" BeforeTargets="WriteGitRevision" Condition="'$(BuildHash)' == ''">
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
object[] obj = new object[] { signal, connection };
|
||||
GameMain.Lua.hook.Call("signalReceived", obj);
|
||||
GameMain.Lua.hook.Call("signalReceived." + recipient.item.prefab.Identifier, obj);
|
||||
GameMain.Lua.hook.Call("signalReceived." + recipient.item.Prefab.Identifier, obj);
|
||||
|
||||
foreach (ItemComponent ic in recipient.item.Components)
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Barotrauma.Items.Components
|
||||
private readonly struct EventData : IEventData
|
||||
{
|
||||
public readonly CustomInterfaceElement BtnElement;
|
||||
|
||||
|
||||
public EventData(CustomInterfaceElement btnElement)
|
||||
{
|
||||
BtnElement = btnElement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CustomInterfaceElement : ISerializableEntity
|
||||
{
|
||||
public bool ContinuousSignal;
|
||||
@@ -141,8 +141,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool RecreateGUIOnResolutionChange => true;
|
||||
|
||||
public readonly List<CustomInterfaceElement> customInterfaceElementList = new List<CustomInterfaceElement>();
|
||||
|
||||
private readonly List<CustomInterfaceElement> customInterfaceElementList = new List<CustomInterfaceElement>();
|
||||
|
||||
public CustomInterface(Item item, ContentXElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
@@ -260,8 +260,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void UpdateSignalsProjSpecific();
|
||||
|
||||
partial void InitProjSpecific();
|
||||
|
||||
partial void InitProjSpecific();
|
||||
|
||||
private void ButtonClicked(CustomInterfaceElement btnElement)
|
||||
{
|
||||
if (btnElement == null) return;
|
||||
@@ -342,4 +342,4 @@ namespace Barotrauma.Items.Components
|
||||
return base.Save(parentElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,32 +37,8 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
|
||||
partial class AfflictionPrefab
|
||||
{
|
||||
public static AfflictionPrefab[] ListArray
|
||||
{
|
||||
get
|
||||
{
|
||||
return List.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partial class CharacterInfo
|
||||
{
|
||||
public static CharacterInfo Create(string speciesName, string name = "", JobPrefab jobPrefab = null, string ragdollFileName = null, int variant = 0, Rand.RandSync randSync = Rand.RandSync.Unsynced, string npcIdentifier = "")
|
||||
{
|
||||
return new CharacterInfo(speciesName, name, name, jobPrefab, ragdollFileName, variant, randSync, npcIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
partial class Item
|
||||
{
|
||||
public static void AddToRemoveQueue(Item item)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToRemoveQueue(item);
|
||||
}
|
||||
|
||||
public object GetComponentString(string component)
|
||||
{
|
||||
Type type = Type.GetType("Barotrauma.Items.Components." + component);
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateEntityEvent(INetSerializable entity, object[] extraData)
|
||||
public void CreateEntityEvent(INetSerializable entity, NetEntityEvent.IData extraData)
|
||||
{
|
||||
GameMain.NetworkMember.CreateEntityEvent(entity, extraData);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Barotrauma
|
||||
{
|
||||
public bool IsSingleplayer => GameMain.IsSingleplayer;
|
||||
public bool IsMultiplayer => GameMain.IsMultiplayer;
|
||||
public GameSettings GameSettings => GameMain.Config;
|
||||
|
||||
#if CLIENT
|
||||
public bool Paused => GameMain.Instance?.Paused == true;
|
||||
@@ -205,53 +204,6 @@ namespace Barotrauma
|
||||
new Explosion(range, force, damage, structureDamage, itemDamage, empStrength, ballastFloraStrength).Explode(pos, null);
|
||||
}
|
||||
|
||||
public static Character Spawn(string name, Vector2 worldPos)
|
||||
{
|
||||
Character spawnedCharacter = null;
|
||||
Vector2 spawnPosition = worldPos;
|
||||
|
||||
string characterLowerCase = name.ToLowerInvariant();
|
||||
JobPrefab job = null;
|
||||
if (!JobPrefab.Prefabs.ContainsKey(characterLowerCase))
|
||||
{
|
||||
job = JobPrefab.Prefabs.Find(jp => jp.Name != null && jp.Name.Equals(characterLowerCase, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
else
|
||||
{
|
||||
job = JobPrefab.Prefabs[characterLowerCase];
|
||||
}
|
||||
bool human = job != null || characterLowerCase == CharacterPrefab.HumanSpeciesName;
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(name)) { return null; }
|
||||
|
||||
if (human)
|
||||
{
|
||||
var variant = job != null ? Rand.Range(0, job.Variants, Rand.RandSync.Server) : 0;
|
||||
CharacterInfo characterInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: job, variant: variant);
|
||||
spawnedCharacter = Character.Create(characterInfo, spawnPosition, ToolBox.RandomSeed(8));
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
//TODO: a way to select which team to spawn to?
|
||||
spawnedCharacter.TeamID = Character.Controlled != null ? Character.Controlled.TeamID : CharacterTeamType.Team1;
|
||||
#if CLIENT
|
||||
GameMain.GameSession.CrewManager.AddCharacter(spawnedCharacter);
|
||||
#endif
|
||||
}
|
||||
spawnedCharacter.GiveJobItems(null);
|
||||
spawnedCharacter.Info.StartItemsGiven = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CharacterPrefab.FindBySpeciesName(name) != null)
|
||||
{
|
||||
spawnedCharacter = Character.Create(name, spawnPosition, ToolBox.RandomSeed(8));
|
||||
}
|
||||
}
|
||||
|
||||
return spawnedCharacter;
|
||||
}
|
||||
|
||||
public static string SpawnItem(string name, Vector2 pos, bool inventory = false, Character character = null)
|
||||
{
|
||||
string error;
|
||||
@@ -259,11 +211,6 @@ namespace Barotrauma
|
||||
return error;
|
||||
}
|
||||
|
||||
public static void RemoveItem(Item item)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToRemoveQueue(item);
|
||||
}
|
||||
|
||||
public static ItemPrefab GetItemPrefab(string itemNameOrId)
|
||||
{
|
||||
ItemPrefab itemPrefab =
|
||||
@@ -273,20 +220,6 @@ namespace Barotrauma
|
||||
return itemPrefab;
|
||||
}
|
||||
|
||||
public void AddItemPrefabToSpawnQueue(ItemPrefab itemPrefab, Vector2 position, DynValue spawned = null)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, position, onSpawned: (Item item) => {
|
||||
if (spawned?.Type == DataType.Function) GameMain.Lua.CallFunction(spawned, UserData.Create(item));
|
||||
});
|
||||
}
|
||||
|
||||
public void AddItemPrefabToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, DynValue spawned = null)
|
||||
{
|
||||
EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, inventory, onSpawned: (Item item) => {
|
||||
if (spawned?.Type == DataType.Function) GameMain.Lua.CallFunction(spawned, UserData.Create(item));
|
||||
});
|
||||
}
|
||||
|
||||
public static Submarine GetRespawnSub()
|
||||
{
|
||||
#if SERVER
|
||||
@@ -356,34 +289,6 @@ namespace Barotrauma
|
||||
return new Signal(value, stepsTaken, sender, source, power, strength);
|
||||
}
|
||||
|
||||
public static ContentPackage[] GetEnabledContentPackages()
|
||||
{
|
||||
return GameMain.Config.AllEnabledPackages.ToArray();
|
||||
}
|
||||
|
||||
public static List<string> GetEnabledPackagesDirectlyFromFile()
|
||||
{
|
||||
List<string> enabledPackages = new List<string>();
|
||||
|
||||
XDocument doc = XMLExtensions.LoadXml("config_player.xml");
|
||||
var contentPackagesElement = doc.Root.Element("contentpackages");
|
||||
|
||||
string coreName = contentPackagesElement.Element("core")?.GetAttributeString("name", "");
|
||||
enabledPackages.Add(coreName);
|
||||
|
||||
XElement regularElement = contentPackagesElement.Element("regular");
|
||||
List<XElement> subElements = regularElement?.Elements()?.ToList();
|
||||
|
||||
foreach (var subElement in subElements)
|
||||
{
|
||||
if (!bool.TryParse(subElement.GetAttributeString("enabled", "false"), out bool enabled) || !enabled) { continue; }
|
||||
|
||||
string name = subElement.GetAttributeString("name", null);
|
||||
enabledPackages.Add(name);
|
||||
}
|
||||
return enabledPackages;
|
||||
}
|
||||
|
||||
private List<DebugConsole.Command> luaAddedCommand = new List<DebugConsole.Command>();
|
||||
|
||||
public void RemoveCommand(string name)
|
||||
@@ -450,7 +355,7 @@ namespace Barotrauma
|
||||
GameMain.Server.SendChatMessage(msg, (ChatMessageType)messageType, sender, character);
|
||||
}
|
||||
|
||||
public static void SendTraitorMessage(Client client, string msg, string missionid, TraitorMessageType type)
|
||||
public static void SendTraitorMessage(Client client, string msg, Identifier missionid, TraitorMessageType type)
|
||||
{
|
||||
GameMain.Server.SendTraitorMessage(client, msg, missionid, type);
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ namespace Barotrauma
|
||||
GenerateDocs(typeof(WayPoint), "WayPoint.lua", "WayPoint");
|
||||
}
|
||||
|
||||
public static void GenerateDocs(Type type, string name, string? categoryName = null)
|
||||
public static void GenerateDocs(Type type, string name, string categoryName = null)
|
||||
{
|
||||
GenerateDocs(type, "../../../../docs/baseluadocs/" + name, "../../../../docs/lua/generated/" + name, categoryName);
|
||||
}
|
||||
|
||||
public static void GenerateDocs(Type type, string baselua, string fileresult, string? categoryName = null)
|
||||
public static void GenerateDocs(Type type, string baselua, string fileresult, string categoryName = null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
|
||||
@@ -565,7 +565,7 @@ namespace Barotrauma
|
||||
if (mapEntityUpdateTick % MapEntityUpdateInterval == 0)
|
||||
{
|
||||
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
foreach (Hull hull in Hull.HullList)
|
||||
{
|
||||
hull.Update(deltaTime * MapEntityUpdateInterval, cam);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user