2 using System.Collections.Generic;
7 using FarseerPhysics.Dynamics;
8 using Microsoft.Xna.Framework;
9 using MoonSharp.Interpreter;
17 public string SaveFolder =>
string.IsNullOrEmpty(GameSettings.CurrentConfig.SavePath) ? SaveUtil.DefaultSaveFolder : GameSettings.CurrentConfig.SavePath;
29 public byte SessionId =>
GameMain.Client.SessionId;
30 public byte MyID => SessionId;
45 public Sounds.SoundManager SoundManager
49 return GameMain.SoundManager;
53 public Lights.LightManager LightManager
57 return GameMain.LightManager;
61 public SubEditorScreen SubEditorScreen
69 public MainMenuScreen MainMenuScreen
73 return GameMain.MainMenuScreen;
77 public Particles.ParticleManager ParticleManager
81 return GameMain.ParticleManager;
85 public bool IsSubEditor
89 return Screen.
Selected is SubEditorScreen;
120 return GameMain.Client.ServerSettings;
132 return GameMain.Client.RespawnManager;
217 return GameMain.Client?.GameStarted ==
true;
263 public ClientPeer
Peer
275 Settings = UserData.CreateStatic(typeof(GameSettings));
314 public static void Explode(Vector2 pos,
float range = 100,
float force = 30,
float damage = 30,
float structureDamage = 30,
float itemDamage = 30,
float empStrength = 0,
float ballastFloraStrength = 0)
316 new Explosion(range, force, damage, structureDamage, itemDamage, empStrength, ballastFloraStrength).
Explode(pos,
null);
319 public static string SpawnItem(
string name, Vector2 pos,
bool inventory =
false,
Character character =
null)
322 DebugConsole.SpawnItem(
new string[] { name, inventory ?
"inventory" :
"cursor" }, pos, character, out error);
328 return ContentPackageManager.EnabledPackages.All.ToArray();
346 if (
GameMain.Client.RespawnManager ==
null) {
return null; }
357 var steering = item.GetComponent<Items.
Components.Steering>();
358 if (steering !=
null)
369 if (item ==
null)
return null;
375 if (item ==
null)
return null;
381 if (item ==
null)
return null;
387 if (item ==
null)
return null;
393 if (item ==
null)
return null;
394 return item.GetComponent<
Holdable>();
399 DebugConsole.ExecuteCommand(command);
404 return new Signal(value, stepsTaken, sender, source, power, strength);
407 private List<DebugConsole.Command> luaAddedCommand =
new List<DebugConsole.Command>();
408 public IEnumerable<DebugConsole.Command>
LuaAddedCommand {
get {
return luaAddedCommand; } }
412 DebugConsole.Command[] permitted =
new DebugConsole.Command[]
414 DebugConsole.FindCommand(
"cl_reloadluacs"),
415 DebugConsole.FindCommand(
"cl_lua"),
416 DebugConsole.FindCommand(
"cl_toggleluadebug"),
419 foreach (var consoleCommand
in LuaAddedCommand.Concat(permitted.AsEnumerable()))
421 if (consoleCommand.Names.Contains(command))
432 for (var i = 0; i < DebugConsole.Commands.Count; i++)
434 foreach (var cmdname
in DebugConsole.Commands[i].Names)
438 luaAddedCommand.Remove(DebugConsole.Commands[i]);
439 DebugConsole.Commands.RemoveAt(i);
448 var cmd =
new DebugConsole.Command(name, help, (
string[] arg1) => onExecute(
new object[] { arg1 }),
451 if (getValidArgs ==
null)
return null;
452 var validArgs = getValidArgs();
453 if (validArgs is DynValue luaValue)
455 return luaValue.ToObject<
string[][]>();
457 return (
string[][])validArgs;
460 luaAddedCommand.Add(cmd);
461 DebugConsole.Commands.Add(cmd);
464 public List<DebugConsole.Command>
Commands => DebugConsole.Commands;
470 if (!
LuaCsFile.
CanWriteToPath(path)) {
throw new ScriptRuntimeException($
"Saving files to {path} is disallowed."); }
536 foreach (var cmd
in luaAddedCommand)
538 DebugConsole.Commands.Remove(cmd);
static int CharacterUpdateInterval
Explosions are area of effect attacks that can damage characters, items and structures.
void Explode(Vector2 worldPosition, Entity damageSource, Character attacker=null)
static NetLobbyScreen NetLobbyScreen
static bool IsMultiplayer
static bool IsSingleplayer
static GameScreen GameScreen
static GameSession GameSession
static readonly Screen SubEditorScreen
bool IsRunning
Is a round currently running?
static readonly List< Item > ItemList
List< ItemComponent > Components
static bool CanWriteToPath(string path)
DynValue CallLuaFunction(object function, params object[] args)
static Items.Components.Steering GetSubmarineSteering(Submarine sub)
void RemovePriorityItem(Item item)
bool disableDisconnectCharacter
int MapEntityUpdateInterval
static string SpawnItem(string name, Vector2 pos, bool inventory=false, Character character=null)
static void SendTraitorMessage(WriteOnlyMessage message, Client client)
void OverrideTraitors(bool o)
static void SendDirectChatMessage(ChatMessage chatMessage, Client client)
void EnableControlHusk(bool o)
void OverrideSignalRadio(bool o)
void SaveGame(string path)
void DisableSpamFilter(bool o)
List< DebugConsole.Command > Commands
int CharacterUpdateInterval
void AddPriorityItem(Item item)
int PoweredUpdateInterval
void AllowWifiChat(bool o)
void AssignOnClientRequestExecute(string names, object onExecute)
static void Explode(Vector2 pos, float range=100, float force=30, float damage=30, float structureDamage=30, float itemDamage=30, float empStrength=0, float ballastFloraStrength=0)
void RemoveCommand(string name)
void DisableDisconnectCharacter(bool o)
void ClearPriorityCharacter()
IEnumerable< DebugConsole.Command > LuaAddedCommand
static Holdable GetHoldableComponent(Item item)
bool IsCustomCommandPermitted(Identifier command)
static LightComponent GetLightComponent(Item item)
HashSet< Item > UpdatePriorityItems
void AssignOnExecute(string names, object onExecute)
void OverrideRespawnSub(bool o)
static ContentPackage[] GetEnabledContentPackages()
static Signal CreateSignal(string value, int stepsTaken=1, Character sender=null, Item source=null, float power=0, float strength=1)
void LoadCampaign(string path, Client client=null)
static Submarine GetRespawnSub()
static void Log(string message, ServerLog.MessageType type)
static void ExecuteCommand(string command)
void RemovePriorityCharacter(Character character)
static CustomInterface GetCustomInterface(Item item)
static Fabricator GetFabricatorComponent(Item item)
static void SendDirectChatMessage(string sendername, string text, Character sender, ChatMessageType messageType=ChatMessageType.Private, Client client=null, string iconStyle="")
static GameServer.TryStartGameResult StartGame()
static ItemPrefab GetItemPrefab(string itemNameOrId)
static WifiComponent GetWifiComponent(Item item)
void AddCommand(string name, string help, LuaCsAction onExecute, LuaCsFunc getValidArgs=null, bool isCheat=false)
void AddPriorityCharacter(Character character)
static void SendMessage(string msg, ChatMessageType? messageType=null, Client sender=null, Character character=null)
void LoadGame(string path)
HashSet< Character > UpdatePriorityCharacters
static void DispatchRespawnSub()
static void MakeFieldAccessible(IUserDataDescriptor IUUD, string fieldName)
static int MapEntityUpdateInterval
static int PoweredUpdateInterval
static MapEntityPrefab Find(string name, string identifier=null, bool showErrorMessages=true)
Find a matching map entity prefab
static void LoadCampaign(CampaignDataPath path, Client client)
static ChatMessage Create(string senderName, string text, ChatMessageType type, Entity sender, Client client=null, PlayerConnectionChangeType changeType=PlayerConnectionChangeType.None, Color? textColor=null)
TryStartGameResult TryStartGame()
void SendDirectChatMessage(string txt, Client recipient, ChatMessageType messageType=ChatMessageType.Server)
void EndGame(CampaignMode.TransitionType transitionType=CampaignMode.TransitionType.None, bool wasSaved=false, IEnumerable< Mission > missions=null)
void SendTraitorMessage(WriteOnlyMessage msg, Client client)
static void Log(string line, ServerLog.MessageType messageType)
void SendChatMessage(string message, ChatMessageType? type=null, Client senderClient=null, Character senderCharacter=null, PlayerConnectionChangeType changeType=PlayerConnectionChangeType.None, ChatMode chatMode=ChatMode.None)
Add the message to the chatbox and pass it to all clients who can receive it
delegate void LuaCsAction(params object[] args)
delegate object LuaCsFunc(params object[] args)
static CampaignDataPath CreateRegular(string savePath)
Creates a CampaignDataPath with the same load and save path.