Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaBarotraumaAdditions.cs
Roland Firmont caac190a05 Add AddLinked to MapEntity
MapEntity.linkedTo is readonly and arrives as a table on lua side, making it impossible to add new Links.

Introducing AddLinked as an Addition makes it possible to link things.
2022-03-21 16:24:42 +01:00

115 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using MoonSharp.Interpreter;
using Microsoft.Xna.Framework;
namespace Barotrauma.Networking
{
partial class Client
{
public static List<Client> ClientList
{
get
{
#if SERVER
return GameMain.Server.ConnectedClients;
#else
return GameMain.Client.ConnectedClients;
#endif
}
}
}
}
namespace Barotrauma
{
using Barotrauma.Networking;
using System.Linq;
using System.Reflection;
partial class Character
{
}
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);
if (type == null)
return null;
MethodInfo method = typeof(Item).GetMethod(nameof(Item.GetComponent));
MethodInfo generic = method.MakeGenericMethod(type);
return generic.Invoke(this, null);
}
}
partial class ItemPrefab
{
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;
}
}
abstract partial class MapEntity
{
public void AddLinked(MapEntity entity)
{
linkedTo.Add(entity);
}
}
}
namespace Barotrauma.Items.Components
{
using Barotrauma.Networking;
partial class CustomInterface
{
}
partial struct Signal
{
}
}