/// <summary> /// Create a <see cref="PhysicsInterface"/>. /// </summary> public PhysicsInterface(QSGame game) : base(game, InterfaceType.Physics) { this.game.GameMessage += this.Game_GameMessage; this.actors = new Dictionary <Int64, IPhysicsActor>(); this.physicsScene = this.game.Physics.CreateScene(); this.rigidBodyGroup = new CollisionGroup(); this.phantomGroup = new CollisionGroup(); this.terrainGroup = new CollisionGroup(); // Phantoms do not collide with terrain var pair = new CollisionGroupPair(this.terrainGroup, this.phantomGroup); CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.NoBroadPhase); pair = new CollisionGroupPair(this.terrainGroup, this.terrainGroup); CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.NoBroadPhase); pair = new CollisionGroupPair(this.phantomGroup, this.phantomGroup); CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.NoBroadPhase); // Phantoms collide with rigid bodies, but do not affect each others' movement. pair = new CollisionGroupPair(this.phantomGroup, this.rigidBodyGroup); CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.NoSolver); pair = new CollisionGroupPair(this.terrainGroup, this.rigidBodyGroup); CollisionRules.CollisionGroupRules.Add(pair, CollisionRule.Normal); }
public SampleScene(QSGame game) : base(game) { LoadFog("EnvironmentalEffects/Fog/GrayLowLayingFog"); // Load terrain this.game.SceneManager.CreateAndAddEntityByTemplateID(4); LoadCharacter(); // Load light this.game.SceneManager.CreateAndAddEntityByTemplateID(9); LoadSkyDome(); // Load a space ship BaseEntity newEntity = new BaseEntity(this.game, new Vector3(1000.0f, 254.0f, 600.0f), Matrix.CreateRotationX(0.3f), 10.0f); this.game.SceneManager.AddEntityByTemplateID(newEntity, 8); //LoadRainParticleEmitter(); LoadSnowParticleEmitter(); LoadWater(); BoxStack(2, new Vector3(1015.0f, 185.0f, 700.0f)); BoxAntiGrav(new Vector3(1000.0f, 200.0f, 730.0f), false); BoxAntiGrav(new Vector3(1000.0f, 200.0f, 575.0f), true); LoadPrimitives(); // This allows our scene to hear about messages, in case we want to do any scene-specific events. game.GameMessage += this.Game_GameMessage; }
/// <summary> /// Constructs a new instance of a compositor. /// </summary> public ScreenCompositor(QSGame gameInstance) { this.screens = new List <IScreen>(); this.game = gameInstance; this.afterLoadContent = false; }
/// <summary> /// Create an entity /// </summary> /// <param name="game">Reference to the main game object.</param> /// <param name="position">Position of entity</param> /// <param name="rotation">Rotation of entity</param> /// <param name="scale">Scale of entity</param> public BaseEntity(QSGame game, Vector3 position, Matrix rotation, float scale) : this(game, QSGame.TemplateIDCustom) { this.position = position; this.rotation = rotation; this.scale = scale; }
public NavMesh(QSGame game) : base(game) { // Register to receive messages this.Game.GameMessage += this.Game_GameMessage; meshGenerator = new NavMeshGenerator(this); }
/// <summary> /// Constructs a new physics actor. /// </summary> /// <param name="desc">Descriptor for the actor.</param> internal BEPUActor(ActorDesc desc) { this.actorType = desc.Type; this.shapes = desc.Shapes; this.ownerEntityID = desc.EntityID; this.game = desc.Game; this.body = new QSBody(this); }
public EntityInfoWindow(int xPos, int yPos, Int64 EntityID, QSGame game) : base() { MsgGetName msgName = ObjectPool.Aquire <MsgGetName>(); msgName.UniqueTarget = EntityID; game.SendMessage(msgName); Initialize(xPos, yPos, msgName.Name); }
public PhysicsRenderManager(QSGame game) : base(game) { // By default physics rendering is disabled. this.Enabled = false; this.Game.Services.AddService(typeof(PhysicsRenderManager), this); this.modelDrawer = new InstancedModelDrawer(game); this.modelDrawer.IsWireframe = true; }
public EntityLoader(QSGame Game) { this.game = Game; this.EntityContentLoader = new ContentManager(this.game.Services, this.game.Settings.EntitiesDirectory); this.EntityDefinitionsContentLoader = new ContentManager(this.game.Services, this.game.Settings.EntityDefinitionsDirectory); this.ComponentDefinitionsContentLoader = new ContentManager(this.game.Services, this.game.Settings.ComponentDefinitionsDirectory); this.entityDefinitions = new Dictionary <int, EntityDefinition>(); CacheEntityDefinitions(); }
/// <summary> /// A screen with instructions on things that can be done within the game demo. /// </summary> /// <param name="xPos">The horizontal position</param> /// <param name="yPos">The vertical position</param> public InstructionsScreen(int xPos, int yPos, QSGame game) { this.game = game; this.x = xPos; this.y = yPos; this.guiScreen = new ControlsScreenGUI(xPos, yPos); // Add the screen the to GuiManager's screen this.game.Gui.Screen.Desktop.Children.Add(this.guiScreen); }
/// <summary> /// A screen to show performance and rendering statistics. /// </summary> /// <param name="xPos">The horizontal position</param> /// <param name="yPos">The vertical position</param> public StatsScreen(int xPos, int yPos, QSGame game) { this.game = game; this.game.GameMessage += this.Game_GameMessage; this.x = xPos; this.y = yPos; this.guiScreen = new StatsScreenGUI(xPos, yPos); // Add the screen the to GuiManager's screen this.game.Gui.Screen.Desktop.Children.Add(this.guiScreen); }
/// <summary> /// Constructs a new FPS counter. /// </summary> /// <param name="xPos">The horizontal position of the FPS counter.</param> /// <param name="yPos">The vertical position of the FPS counter.</param> public FPSScreen(int xPos, int yPos, QSGame game) { this.game = game; this.fpsString = ""; this.frameCount = 0; this.x = xPos; this.y = yPos; timer = new Stopwatch(); timer.Start(); }
/// <summary> /// Create an entity /// </summary> /// <param name="game">Reference to the main game object.</param> /// <param name="TemplateID">Template ID used to create this object.</param> public BaseEntity(QSGame game, int TemplateID) { this.game = game; this.templateID = TemplateID; this.componentList = new Dictionary <ComponentType, BaseComponent>(); this.activeComponents = new List <BaseComponent>(); this.children = new Dictionary <Int64, BaseEntity>(); this.Game.GameMessage += this.Game_GameMessage; this.uniqueID = totalIDsUsed; ++totalIDsUsed; }
/// <summary> /// Create a terrain patch. /// </summary> /// <param name="game">QSGame reference</param> /// <param name="terrain">Terrain section this patch belongs to</param> /// <param name="parentQuadTree">Parent QuadTree section</param> public TerrainPatch(QSGame game, TerrainComponent terrain, QuadTree parentQuadTree) : base(game) { this.terrain = terrain; this.parentQuadTree = parentQuadTree; // Create an array index of 4 for each, as 4 is our lowest detail level indexBuffers = new IndexBuffer[(int)LOD.NumOfLODs]; numTris = new int[(int)LOD.NumOfLODs]; // Setup patch with the highest LOD available SetupTerrainIndices(parentQuadTree.Width, terrain.Detail); }
public GuiManager(QSGame game) : base(game) { this.game = game; // Add this to the game service list this.game.Services.AddService(typeof(GuiManager), this); this.gui = new Nuclex.UserInterface.GuiManager(this.game.Services); this.input = new Nuclex.Input.InputManager(this.game.Services, game.Window.Handle); // The Nuclex UserInterface requires its own input handling setup. For now // this engine will use Nuclex's input handling for GUI, but it may be replaced // in the future if needed. this.game.Services.AddService(typeof(Nuclex.Input.InputManager), this.input); }
/// <summary> /// Creates a new AudioSystem instance. /// </summary> public AudioManager(QSGame game) : base(game) { this.Game.Services.AddService(typeof(AudioManager), this); listeners = new List <AudioListener>(); activeCues = new List <Cue>(); activeCue3Ds = new List <Cue3D>(); inactiveCue3Ds = new Queue <Cue3D>(); categories = new Dictionary <string, AudioCategory>(); categoryVolumes = new Dictionary <AudioCategory, float>(); // Set default volume. globalVolume = 50f; }
/// <summary> /// Creates a child <see cref="QuadTree"/> section. /// </summary> /// <param name="SourceTerrain">Parent <see cref="Terrain"/> section</param> /// <param name="verticesLength"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> public QuadTree(QSGame game, TerrainComponent sourceTerrain, int verticesLength, int offsetX, int offsetZ) { this.Game = game; this.terrain = sourceTerrain; if (boundingBoxMaterial == null) { boundingBoxMaterial = game.Content.Load <Material>("Material/Terrain"); } this.offsetX = offsetX; this.offsetZ = offsetZ; // This truncation requires all heightmap images to be // a power of two in height and width this.width = ((int)Math.Sqrt(verticesLength) / 2) + 1; SetupBoundingBox(); // If this tree is the smallest allowable size, set it as a leaf // so that it will not continue branching smaller. int widthMinusOne = this.width - 1; if ((widthMinusOne * widthMinusOne) <= this.terrain.MinLeafSize) { this.isLeaf = true; CreateBoundingBoxMesh(); } if (this.isLeaf) { SetupTerrainVertices(); this.leafPatch = new TerrainPatch(this.Game, this.terrain, this); } else { BranchOff(); } }
/// <summary> /// Create an instance of an input polling handler /// </summary> /// <param name="Game"></param> public InputPollingHandler(QSGame Game) { this.game = Game; this.gamepadButtons = new Dictionary <Buttons, InputButton> [4]; for (int i = 0; i < gamepadButtons.Length; ++i) { gamepadButtons[i] = new Dictionary <Buttons, InputButton>(); } this.keys = new Dictionary <Keys, InputButton>(); this.mouseButtons = new Dictionary <MouseButton, InputButton>(); this.thumbsticks = new Vector2[4, 2]; // 4 players, 2 thumbsticks this.previousThumbsticks = new Vector2[4, 2]; this.triggers = new float[4, 2]; this.previousTriggers = new float[4, 2]; this.game.GameMessage += this.Game_GameMessage; }
/// <summary> /// Creates a root <see cref="QuadTree"/> node. This should only be called from the /// parent Terrain section. /// </summary> /// <param name="game">QSGame reference</param> /// <param name="terrain">Parent terrain section</param> /// <param name="verticesLength">Length of vertices in this QuadTree</param> public QuadTree(QSGame game, TerrainComponent terrain, int verticesLength) { this.Game = game; this.terrain = terrain; if (boundingBoxMaterial == null) { boundingBoxMaterial = game.Content.Load <Material>("Material/WireFrame"); } // This truncation requires all heightmap images to be // a power of two in height and width this.width = (int)Math.Sqrt(verticesLength); this.rootWidth = width; // Vertices are only used for setting up the dimensions of // the bounding box. The vertices used in rendering are // located in the terrain class. SetupBoundingBox(); // If this tree is the smallest allowable size, set it as a leaf // so that it will not continue branching smaller. if (verticesLength <= this.terrain.MinLeafSize) { this.isLeaf = true; CreateBoundingBoxMesh(); } if (this.isLeaf) { SetupTerrainVertices(); this.leafPatch = new TerrainPatch(this.Game, this.terrain, this); } else { BranchOffRoot(); } }
/// <summary> /// Constructs a new physics manager. /// </summary> /// <param name="game">A reference to the QuickStart QSGame instance.</param> public BEPUPhysicsManager(QSGame game) : base(game) { }
/// <summary> /// Create an instance of an input polling handler /// </summary> /// <param name="Game"></param> public InputPollingHandler(QSGame Game) { this.game = Game; this.keys = new Dictionary <Keys, InputButton>(); this.game.GameMessage += this.Game_GameMessage; }
/// <summary> /// Create push effect /// </summary> /// <param name="velocity">Direction * speed</param> public ConstantPushEffect(QSGame game, int effectID) : base(game, effectID) { this.game = game; this.type = CollisionEffectType.ConstantPushEffect; }
public DebugMessageEntity(QSGame game) : base(game) { this.Game.GameMessage += new EngineMessageHandler(Game_GameMessage); }
/// <summary> /// Create an entity /// </summary> /// <param name="game">Reference to the main game object.</param> public BaseEntity(QSGame game) : this(game, QSGame.TemplateIDCustom) { }
public ConstantCollisionEffect(QSGame game, int effectID) : base(game, effectID) { collisionList = new List <Int64>(); }
/// <summary> /// Constructs a new <see cref="PhysicsSystem"/> instance. /// </summary> /// <param name="game"></param> public PhysicsManager(QSGame game) : base(game) { this.Game.Services.AddService(typeof(PhysicsManager), this); }
/// <summary> /// Create push effect /// </summary> /// <param name="velocity">Direction * speed</param> public CollisionEffect(QSGame game, int effectID) { this.game = game; this.effectID = effectID; }
/// <summary> /// Create a <see cref="CameraInterface"/>. /// </summary> public CameraInterface(QSGame game) : base(game, InterfaceType.Camera) { this.game.GameMessage += this.Game_GameMessage; }
/// <summary> /// Called from a derived class to construct an interface. /// </summary> public QSInterface(QSGame game, InterfaceType interfaceID) { this.game = game; this.interfaceID = interfaceID; }
/// <summary> /// Create a <see cref="CameraInterface"/>. /// </summary> public InputInterface(QSGame game) : base(game, InterfaceType.Input) { this.game.GameMessage += this.Game_GameMessage; }