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;
94 public GameServer Server
102 public bool IsDedicated
106 return GameMain.Server.ServerPeer is LidgrenServerPeer;
110 public bool Paused =>
false;
118 return GameMain.Server.ServerSettings;
130 return GameMain.Server.RespawnManager;
215 return GameMain.Server?.GameStarted ==
true;
255 public ServerPeer
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();
343 if (
GameMain.Server.RespawnManager ==
null)
345 return GameMain.Server.RespawnManager.RespawnShuttle;
359 var steering = item.GetComponent<Items.
Components.Steering>();
360 if (steering !=
null)
371 if (item ==
null)
return null;
377 if (item ==
null)
return null;
383 if (item ==
null)
return null;
389 if (item ==
null)
return null;
395 if (item ==
null)
return null;
396 return item.GetComponent<
Holdable>();
401 DebugConsole.ExecuteCommand(command);
406 return new Signal(value, stepsTaken, sender, source, power, strength);
409 private List<DebugConsole.Command> luaAddedCommand =
new List<DebugConsole.Command>();
410 public IEnumerable<DebugConsole.Command>
LuaAddedCommand {
get {
return luaAddedCommand; } }
414 DebugConsole.Command[] permitted =
new DebugConsole.Command[]
416 DebugConsole.FindCommand(
"cl_reloadluacs"),
417 DebugConsole.FindCommand(
"cl_lua"),
418 DebugConsole.FindCommand(
"cl_toggleluadebug"),
421 foreach (var consoleCommand
in LuaAddedCommand.Concat(permitted.AsEnumerable()))
423 if (consoleCommand.Names.Contains(command))
434 for (var i = 0; i < DebugConsole.Commands.Count; i++)
436 foreach (var cmdname
in DebugConsole.Commands[i].Names)
440 luaAddedCommand.Remove(DebugConsole.Commands[i]);
441 DebugConsole.Commands.RemoveAt(i);
450 var cmd =
new DebugConsole.Command(name, help, (
string[] arg1) => onExecute(
new object[] { arg1 }),
453 if (getValidArgs ==
null)
return null;
454 var validArgs = getValidArgs();
455 if (validArgs is DynValue luaValue)
457 return luaValue.ToObject<
string[][]>();
459 return (
string[][])validArgs;
462 luaAddedCommand.Add(cmd);
463 DebugConsole.Commands.Add(cmd);
466 public List<DebugConsole.Command>
Commands => DebugConsole.Commands;
472 if (!
LuaCsFile.
CanWriteToPath(path)) {
throw new ScriptRuntimeException($
"Saving files to {path} is disallowed."); }
473 SaveUtil.SaveGame(path);
478 SaveUtil.LoadGame(path);
482 public void LoadCampaign(
string path,
Client client =
null)
487 public static void SendMessage(
string msg,
ChatMessageType? messageType =
null,
Client sender =
null, Character character =
null)
489 GameMain.Server.SendChatMessage(msg, messageType, sender, character);
492 public static void SendTraitorMessage(WriteOnlyMessage message,
Client client)
494 GameMain.Server.SendTraitorMessage(message, client);
497 public static void SendDirectChatMessage(
string sendername,
string text, Character sender,
ChatMessageType messageType =
ChatMessageType.Private,
Client client =
null,
string iconStyle =
"")
501 GameMain.Server.SendDirectChatMessage(cm, client);
506 GameMain.Server.SendDirectChatMessage(chatMessage, client);
511 GameServer.Log(message, type);
514 public static void DispatchRespawnSub()
516 GameMain.Server.RespawnManager.DispatchShuttle();
519 public static bool StartGame()
521 return GameMain.Server.TryStartGame();
524 public static void EndGame()
526 GameMain.Server.EndGame();
529 public void AssignOnClientRequestExecute(
string names,
object onExecute) => DebugConsole.AssignOnClientRequestExecute(names, (
Client a, Vector2 b,
string[] c) => { GameMain.LuaCs.CallLuaFunction(onExecute,
new object[] { a, b, c }); });
538 foreach (var cmd
in luaAddedCommand)
540 DebugConsole.Commands.Remove(cmd);
static int CharacterUpdateInterval
ChatBox ChatBox
Present only in single player games. In multiplayer. The chatbox is found from GameSession....
Explosions are area of effect attacks that can damage characters, items and structures.
void Explode(Vector2 worldPosition, Entity damageSource, Character attacker=null)
static GameSession?? GameSession
static NetLobbyScreen NetLobbyScreen
static SubEditorScreen SubEditorScreen
static Lights.LightManager LightManager
static ChatMode ActiveChatMode
static bool IsMultiplayer
static bool IsSingleplayer
static GameScreen GameScreen
static MainMenuScreen MainMenuScreen
static ParticleManager ParticleManager
static Sounds.SoundManager SoundManager
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
Lights.LightManager LightManager
static string SpawnItem(string name, Vector2 pos, bool inventory=false, Character character=null)
Sounds.SoundManager SoundManager
void OverrideTraitors(bool o)
Particles.ParticleManager ParticleManager
void EnableControlHusk(bool o)
void OverrideSignalRadio(bool o)
SubEditorScreen SubEditorScreen
void SaveGame(string path)
void DisableSpamFilter(bool o)
List< DebugConsole.Command > Commands
int CharacterUpdateInterval
void AddPriorityItem(Item item)
int PoweredUpdateInterval
void AllowWifiChat(bool o)
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)
static Submarine GetRespawnSub()
static void ExecuteCommand(string command)
void RemovePriorityCharacter(Character character)
static CustomInterface GetCustomInterface(Item item)
static Fabricator GetFabricatorComponent(Item item)
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)
void LoadGame(string path)
HashSet< Character > UpdatePriorityCharacters
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 ChatMessage Create(string senderName, string text, ChatMessageType type, Entity sender, Client client=null, PlayerConnectionChangeType changeType=PlayerConnectionChangeType.None, Color? textColor=null)
delegate void LuaCsAction(params object[] args)
delegate object LuaCsFunc(params object[] args)