refactoring things out, removing unused additions

This commit is contained in:
Evil Factory
2021-09-10 19:10:05 -03:00
parent 813aaf29b8
commit ffb24594bc
8 changed files with 87 additions and 37 deletions
@@ -955,8 +955,7 @@ namespace Barotrauma
{ {
FileName = filename, FileName = filename,
Arguments = arguments, Arguments = arguments,
//#if !DEBUG #if !DEBUG
#if false
CreateNoWindow = true, CreateNoWindow = true,
UseShellExecute = false, UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden WindowStyle = ProcessWindowStyle.Hidden
@@ -124,7 +124,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MoonSharp" Version="2.0.0" /> <PackageReference Include="MoonSharp" Version="2.0.0" />
<PackageReference Include="MoonSharp.Debugger.VsCode" Version="2.0.0" />
<PackageReference Include="NVorbis" Version="0.8.6" /> <PackageReference Include="NVorbis" Version="0.8.6" />
<PackageReference Include="RestSharp" Version="106.6.10" /> <PackageReference Include="RestSharp" Version="106.6.10" />
</ItemGroup> </ItemGroup>
@@ -5,19 +5,6 @@ namespace Barotrauma.Items.Components
{ {
partial class CustomInterface : ItemComponent, IClientSerializable, IServerSerializable partial class CustomInterface : ItemComponent, IClientSerializable, IServerSerializable
{ {
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);
}
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c) public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
{ {
bool[] elementStates = new bool[customInterfaceElementList.Count]; bool[] elementStates = new bool[customInterfaceElementList.Count];
@@ -83,7 +70,7 @@ namespace Barotrauma.Items.Components
{ {
msg.Write(customInterfaceElementList[i].Signal); msg.Write(customInterfaceElementList[i].Signal);
} }
else if(customInterfaceElementList[i].ContinuousSignal) else if (customInterfaceElementList[i].ContinuousSignal)
{ {
msg.Write(customInterfaceElementList[i].State); msg.Write(customInterfaceElementList[i].State);
} }
@@ -94,4 +81,4 @@ namespace Barotrauma.Items.Components
} }
} }
} }
} }
@@ -1,7 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using MoonSharp.Interpreter;
using Microsoft.Xna.Framework;
namespace Barotrauma.Networking namespace Barotrauma.Networking
{ {
@@ -52,6 +53,8 @@ namespace Barotrauma.Networking
namespace Barotrauma namespace Barotrauma
{ {
using Barotrauma.Networking;
partial class CharacterInfo 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 = "") 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 = "")
@@ -59,4 +62,69 @@ namespace Barotrauma
return new CharacterInfo(speciesName, name, name, jobPrefab, ragdollFileName, variant, randSync, npcIdentifier); return new CharacterInfo(speciesName, name, name, jobPrefab, ragdollFileName, variant, randSync, npcIdentifier);
} }
} }
partial class Item
{
public void AddToRemoveQueue(Item item)
{
EntitySpawner.Spawner.AddToRemoveQueue(item);
}
}
partial class ItemPrefab
{
public 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 void AddToSpawnQueue(ItemPrefab itemPrefab, Inventory inventory, object spawned = null)
{
EntitySpawner.Spawner.AddToSpawnQueue(itemPrefab, inventory, onSpawned: (Item item) => {
GameMain.Lua.CallFunction(spawned, new object[] { item });
});
}
public static ItemPrefab GetItemPrefab(string itemNameOrId)
{
ItemPrefab itemPrefab =
(MapEntityPrefab.Find(itemNameOrId, identifier: null, showErrorMessages: false) ??
MapEntityPrefab.Find(null, identifier: itemNameOrId, showErrorMessages: false)) as ItemPrefab;
return itemPrefab;
}
}
}
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)
{
return new Signal(value, stepsTaken, sender, source, power, strength);
}
}
} }
@@ -143,6 +143,11 @@ namespace Barotrauma
} }
public object CallFunction(object function, object[] arguments)
{
return lua.Call(function, arguments);
}
public void SetModulePaths(string[] str) public void SetModulePaths(string[] str)
{ {
luaScriptLoader.ModulePaths = str; luaScriptLoader.ModulePaths = str;
@@ -82,7 +82,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MoonSharp" Version="2.0.0" /> <PackageReference Include="MoonSharp" Version="2.0.0" />
<PackageReference Include="MoonSharp.Debugger.VsCode" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<!-- Sourced from https://stackoverflow.com/a/45248069 --> <!-- Sourced from https://stackoverflow.com/a/45248069 -->
@@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
#if SERVER
using MoonSharp.Interpreter;
#endif
namespace Barotrauma namespace Barotrauma
{ {
@@ -69,18 +66,14 @@ namespace Barotrauma
} }
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {
CrewManager?.Update(deltaTime); CrewManager?.Update(deltaTime);
}
#if SERVER public virtual void End(CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None)
GameMain.Lua.hook.Call("update", new object[] { deltaTime }); {
#endif }
}
public virtual void End(CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None) public virtual void Remove() { }
{ }
} }
public virtual void Remove() { }
}
}
@@ -1,6 +1,6 @@
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
struct Signal partial struct Signal
{ {
public string value; public string value;
public int stepsTaken; public int stepsTaken;