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) {
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."); }
480 public void LoadCampaign(
string path,
Client client =
null)
485 public static void SendMessage(
string msg,
ChatMessageType? messageType =
null,
Client sender =
null, Character character =
null)
487 GameMain.Server.SendChatMessage(msg, messageType, sender, character);
490 public static void SendTraitorMessage(WriteOnlyMessage message,
Client client)
492 GameMain.Server.SendTraitorMessage(message, client);
495 public static void SendDirectChatMessage(
string sendername,
string text, Character sender,
ChatMessageType messageType =
ChatMessageType.Private,
Client client =
null,
string iconStyle =
"")
499 GameMain.Server.SendDirectChatMessage(cm, client);
504 GameMain.Server.SendDirectChatMessage(chatMessage, client);
509 GameServer.Log(message, type);
512 public static void DispatchRespawnSub()
514 GameMain.Server.RespawnManager.DispatchShuttle(GameMain.Server.RespawnManager.GetTeamSpecificState(
CharacterTeamType.Team1));
517 public static GameServer.TryStartGameResult StartGame()
519 return GameMain.Server.TryStartGame();
522 public static void EndGame()
524 GameMain.Server.EndGame();
527 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 }); });
536 foreach (var cmd
in luaAddedCommand)
538 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
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
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)
static CampaignDataPath CreateRegular(string savePath)
Creates a CampaignDataPath with the same load and save path.