Class Session<TUniverse>
- Namespace
- AlphaFramework.World
- Assembly
- AlphaFramework.World.dll
A common base for game sessions (i.e. a game actually being played).
public class Session<TUniverse> where TUniverse : class, IUniverse
Type Parameters
TUniverseThe specific type of IUniverse stored in the session.
- Inheritance
-
objectSession<TUniverse>
- Derived
Constructors
Session()
Base-constructor for XML serialization. Do not call manually!
public Session()
Session(TUniverse)
Creates a new game session based upon a given universe
public Session(TUniverse baseUniverse)
Parameters
baseUniverseTUniverseThe universe to base the new game session on.
Properties
MapSourceFile
The filename of the map file the Universe was loaded from.
public string? MapSourceFile { get; set; }
Property Value
TimeWarpFactor
The factor by which GameTime progression should be multiplied in relation to real time.
public double TimeWarpFactor { get; set; }
Property Value
Universe
The current state of the game world.
[LuaHide]
public TUniverse Universe { get; set; }
Property Value
- TUniverse
Methods
Load(string)
Loads a Session<TUniverse> from a compressed XML file (savegame).
public static Session<TUniverse> Load(string path)
Parameters
pathstringThe file to load from.
Returns
- Session<TUniverse>
Exceptions
- IOException
A problem occurred while reading the file.
- UnauthorizedAccessException
Read access to the file is not permitted.
- InvalidOperationException
A problem occurred while deserializing the XML data.
Load<TSession>(string)
Loads a Session<TUniverse> from a compressed XML file (savegame).
protected static TSession Load<TSession>(string path) where TSession : Session<TUniverse>
Parameters
pathstringThe file to load from.
Returns
- TSession
Type Parameters
TSession
Exceptions
- IOException
A problem occurred while reading the file.
- UnauthorizedAccessException
Read access to the file is not permitted.
- InvalidOperationException
A problem occurred while deserializing the XML data.
Save(string)
Saves this session in an XML file (savegame).
public virtual void Save(string path)
Parameters
pathstringThe file to save in.
Exceptions
- IOException
A problem occurred while writing the file.
- UnauthorizedAccessException
Write access to the file is not permitted.
Update(double)
Updates the underlying Universe.
public virtual double Update(double elapsedRealTime)
Parameters
elapsedRealTimedoubleHow much real time in seconds has elapsed since this method was last called.
Returns
- double
The elapsed game time (real time multiplied by TimeWarpFactor)