Client LuaCsForBarotrauma
LuaBarotraumaAdditions.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using MoonSharp.Interpreter;
5 using Microsoft.Xna.Framework;
7 
9 {
10  partial class Client
11  {
12  public static IReadOnlyList<Client> ClientList
13  {
14  get
15  {
16  if (GameMain.IsSingleplayer) { return new List<Client>(); }
17 
18 #if SERVER
19  return GameMain.Server.ConnectedClients;
20 #else
22 #endif
23  }
24  }
25 
26  public ulong SteamID
27  {
28  get
29  {
30  if (AccountId.TryUnwrap(out AccountId outValue) && outValue is SteamId steamId)
31  {
32  return steamId.Value;
33  }
34  else
35  {
36  return 0;
37  }
38  }
39  }
40 
41  }
42 
43 }
44 
45 namespace Barotrauma
46 {
47  using Barotrauma.Networking;
48  using System.Linq;
49  using System.Reflection;
50 
51 
52 
53  partial class Character
54  {
55 
56  }
57 
58  partial class Item
59  {
60  public object GetComponentString(string component)
61  {
62  Type type = LuaUserData.GetType("Barotrauma.Items.Components." + component);
63 
64  if (type == null)
65  {
66  return null;
67  }
68 
69  MethodInfo method = typeof(Item).GetMethod(nameof(Item.GetComponent));
70  MethodInfo generic = method.MakeGenericMethod(type);
71  return generic.Invoke(this, null);
72  }
73 
74  }
75 
76  partial class ItemPrefab
77  {
78 
79  public static ItemPrefab GetItemPrefab(string itemNameOrId)
80  {
81  ItemPrefab itemPrefab =
82  (MapEntityPrefab.Find(itemNameOrId, identifier: null, showErrorMessages: false) ??
83  MapEntityPrefab.Find(null, identifier: itemNameOrId, showErrorMessages: false)) as ItemPrefab;
84 
85  return itemPrefab;
86  }
87  }
88 
89  abstract partial class MapEntity
90  {
91  public void AddLinked(MapEntity entity)
92  {
93  linkedTo.Add(entity);
94  }
95  }
96 
97 }
98 
99 namespace Barotrauma.Items.Components
100 {
101  using Barotrauma.Networking;
102 
103  partial class CustomInterface
104  {
105  }
106 
107  partial struct Signal
108  {
109  }
110 }
static bool IsSingleplayer
Definition: GameMain.cs:34
static GameClient Client
Definition: GameMain.cs:188
object GetComponentString(string component)
static ItemPrefab GetItemPrefab(string itemNameOrId)
static Type GetType(string typeName)
void AddLinked(MapEntity entity)
static MapEntityPrefab Find(string name, string identifier=null, bool showErrorMessages=true)
Find a matching map entity prefab
static IReadOnlyList< Client > ClientList
Option< AccountId > AccountId
The ID of the account used to authenticate this session. This value can be used as a persistent value...
override IReadOnlyList< Client > ConnectedClients
Definition: GameClient.cs:136