public ServerWorld(GameData.StarSystem system, GameServer server) { Server = server; System = system; GameWorld = new GameWorld(null); GameWorld.PhysicsUpdate += GameWorld_PhysicsUpdate; GameWorld.LoadSystem(system, server.Resources); }
public ServerWorld(GameData.StarSystem system, GameServer server) { Server = server; System = system; GameWorld = new GameWorld(null); GameWorld.Server = this; GameWorld.LoadSystem(system, server.Resources, true); NPCs = new NPCManager(this); }
public DemoSystemView(FreelancerGame g) : base(g) { FLLog.Info("Game", "Starting System Viewer Demo"); sys = g.GameData.GetSystem("li01"); camera = new DebugCamera(g.Viewport); camera.Zoom = 5000; sysrender = new SystemRenderer(camera, g.GameData, g.ResourceManager, g); world = new GameWorld(sysrender); world.LoadSystem(sys, g.ResourceManager); g.Sound.PlayMusic(sys.MusicSpace); camera.UpdateProjection(); trender = new Renderer2D(Game.RenderState); font = g.Fonts.GetSystemFont("Agency FB"); g.Keyboard.KeyDown += G_Keyboard_KeyDown; g.Keyboard.TextInput += G_Keyboard_TextInput; }
public override void Update(TimeSpan delta) { if (current_msg != "") { msg_current_time -= delta.TotalSeconds; if (msg_current_time < 0) { current_msg = ""; } } if (!textEntry) { ProcessInput(delta); } else { if (Game.Keyboard.IsKeyDown(Keys.Enter)) { textEntry = false; Game.DisableTextInput(); if (Game.GameData.SystemExists(currentText.Trim())) { sys = Game.GameData.GetSystem(currentText.Trim()); world.LoadSystem(sys, Game.ResourceManager); camera.Free = false; camera.Update(TimeSpan.FromSeconds(1)); camera.Free = true; Game.Sound.PlayMusic(sys.MusicSpace); } else { msg_current_time = MSG_TIMER; current_msg = string.Format("{0} is not a valid system", currentText.Trim()); } } if (Game.Keyboard.IsKeyDown(Keys.Escape)) { textEntry = false; } } camera.Update(delta); camera.Free = true; world.Update(delta); }
void FinishLoad() { Game.Saves.Selected = -1; ui.OpenScene("hud"); var shp = Game.GameData.GetShip(session.PlayerShip); //Set up player object + camera player = new GameObject(shp.ModelFile.LoadFile(Game.ResourceManager), Game.ResourceManager); control = new ShipPhysicsComponent(player); control.Ship = shp; shipInput = new ShipInputComponent(player); player.Components.Add(shipInput); player.Components.Add(control); weapons = new WeaponControlComponent(player); player.Components.Add(weapons); player.Components.Add(new CDamageFuseComponent(player, shp.Fuses)); player.SetLocalTransform(session.PlayerOrientation * Matrix4x4.CreateTranslation(session.PlayerPosition)); player.PhysicsComponent.Mass = shp.Mass; playerHealth = new CHealthComponent(player); playerHealth.MaxHealth = shp.Hitpoints; playerHealth.CurrentHealth = shp.Hitpoints; player.Components.Add(playerHealth); if (shp.Mass < 0) { FLLog.Error("Ship", "Mass < 0"); } player.Tag = GameObject.ClientPlayerTag; foreach (var equipment in session.Items.Where(x => !string.IsNullOrEmpty(x.Hardpoint))) { EquipmentObjectManager.InstantiateEquipment(player, Game.ResourceManager, EquipmentType.LocalPlayer, equipment.Hardpoint, equipment.Equipment); } powerCore = player.GetComponent <PowerCoreComponent>(); if (powerCore == null) { throw new Exception("Player launched without a powercore equipped!"); } camera = new ChaseCamera(Game.RenderContext.CurrentViewport, Game.GameData.Ini.Cameras); camera.ChasePosition = session.PlayerPosition; camera.ChaseOrientation = player.LocalTransform.ClearTranslation(); var offset = shp.ChaseOffset; camera.DesiredPositionOffset = offset; if (shp.CameraHorizontalTurnAngle > 0) { camera.HorizontalTurnAngle = shp.CameraHorizontalTurnAngle; } if (shp.CameraVerticalTurnUpAngle > 0) { camera.VerticalTurnUpAngle = shp.CameraVerticalTurnUpAngle; } if (shp.CameraVerticalTurnDownAngle > 0) { camera.VerticalTurnDownAngle = shp.CameraVerticalTurnDownAngle; } camera.Reset(); sysrender = new SystemRenderer(camera, Game.GameData, Game.ResourceManager, Game); sysrender.ZOverride = true; //Draw all with regular Z world = new GameWorld(sysrender); world.LoadSystem(sys, Game.ResourceManager, false, session.SpawnTime); session.WorldReady(); player.World = world; world.AddObject(player); world.RenderUpdate += World_RenderUpdate; world.PhysicsUpdate += World_PhysicsUpdate; player.Register(world.Physics); Game.Sound.PlayMusic(sys.MusicSpace); //world.Physics.EnableWireframes(debugphysics); cur_arrow = Game.ResourceManager.GetCursor("arrow"); cur_cross = Game.ResourceManager.GetCursor("cross"); cur_reticle = Game.ResourceManager.GetCursor("fire_neutral"); current_cur = cur_cross; Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; Game.Mouse.MouseDown += Mouse_MouseDown; Game.Mouse.MouseUp += Mouse_MouseUp; input = new InputManager(Game); input.ToggleActivated += Input_ToggleActivated; input.ToggleUp += Input_ToggleUp; pilotcomponent = new AutopilotComponent(player); player.Components.Add(pilotcomponent); player.World = world; world.MessageBroadcasted += World_MessageBroadcasted; Game.Sound.ResetListenerVelocity(); FadeIn(0.5, 0.5); }
public SpaceGameplay(FreelancerGame g, GameSession session) : base(g) { FLLog.Info("Game", "Starting Gameplay Demo"); sys = g.GameData.GetSystem(session.PlayerSystem); var shp = g.GameData.GetShip(session.PlayerShip); //Set up player object + camera this.session = session; player = new GameObject(shp.Drawable, g.ResourceManager, false); control = new ShipControlComponent(player); control.Ship = shp; player.Components.Add(control); powerCore = new PowerCoreComponent(player) { ThrustCapacity = 1000, ThrustChargeRate = 100 }; player.Components.Add(powerCore); player.PhysicsComponent.Position = session.PlayerPosition; player.PhysicsComponent.Orientation = session.PlayerOrientation; player.PhysicsComponent.Material.Restitution = 1; player.PhysicsComponent.Mass = shp.Mass; player.Nickname = "player"; foreach (var equipment in session.MountedEquipment) { var equip = g.GameData.GetEquipment(equipment.Value); var obj = new GameObject(equip, player.GetHardpoint(equipment.Key), player); player.Children.Add(obj); } camera = new ChaseCamera(Game.Viewport); camera.ChasePosition = session.PlayerPosition; camera.ChaseOrientation = new Matrix4(player.PhysicsComponent.Orientation); camera.Reset(); sysrender = new SystemRenderer(camera, g.GameData, g.ResourceManager, g); world = new GameWorld(sysrender); world.LoadSystem(sys, g.ResourceManager); world.Objects.Add(player); world.Physics.SetDampingFactors(0.01f, 1f); world.RenderUpdate += World_RenderUpdate; world.PhysicsUpdate += World_PhysicsUpdate; var eng = new GameData.Items.Engine() { FireEffect = "gf_li_smallengine02_fire", LinearDrag = 600, MaxForce = 48000 }; player.Components.Add((ecpt = new EngineComponent(player, eng, g))); ecpt.Speed = 0; player.Register(sysrender, world.Physics); g.Sound.PlayMusic(sys.MusicSpace); trender = new Renderer2D(Game.RenderState); font = g.Fonts.GetSystemFont("Agency FB"); g.Keyboard.TextInput += G_Keyboard_TextInput; debugphysics = new PhysicsDebugRenderer(); cur_arrow = g.ResourceManager.GetCursor("cross"); cur_reticle = g.ResourceManager.GetCursor("fire_neutral"); current_cur = cur_arrow; hud = new Hud(g); hud.SetManeuver("FreeFlight"); Game.Keyboard.TextInput += Game_TextInput; g.Keyboard.KeyDown += Keyboard_KeyDown; input = new InputManager(Game); input.ToggleActivated += Input_ToggleActivated; input.ToggleUp += Input_ToggleUp; hud.OnManeuverSelected += Hud_OnManeuverSelected; hud.OnEntered += Hud_OnTextEntry; pilotcomponent = new AutopilotComponent(player); pilotcomponent.DockComplete += Pilotcomponent_DockComplete; player.Components.Add(pilotcomponent); player.World = world; world.MessageBroadcasted += World_MessageBroadcasted; }
void FinishLoad() { var shp = Game.GameData.GetShip(session.PlayerShip); //Set up player object + camera player = new GameObject(shp.ModelFile.LoadFile(Game.ResourceManager), Game.ResourceManager, true, false); control = new ShipPhysicsComponent(player); control.Ship = shp; shipInput = new ShipInputComponent(player); player.Components.Add(shipInput); player.Components.Add(control); weapons = new WeaponControlComponent(player); player.Components.Add(weapons); player.Transform = session.PlayerOrientation * Matrix4x4.CreateTranslation(session.PlayerPosition); player.PhysicsComponent.Mass = shp.Mass; if (shp.Mass < 0) { FLLog.Error("Ship", "Mass < 0"); } player.Nickname = "player"; foreach (var equipment in session.Mounts) { var equip = Game.GameData.GetEquipment(equipment.Item); if (equip == null) { continue; } EquipmentObjectManager.InstantiateEquipment(player, Game.ResourceManager, true, equipment.Hardpoint, equip); } powerCore = player.GetComponent <PowerCoreComponent>(); if (powerCore == null) { throw new Exception("Player launched without a powercore equipped!"); } camera = new ChaseCamera(Game.Viewport); camera.ChasePosition = session.PlayerPosition; camera.ChaseOrientation = player.Transform.ClearTranslation(); var offset = shp.ChaseOffset; camera.DesiredPositionOffset = offset; if (shp.CameraHorizontalTurnAngle > 0) { camera.HorizontalTurnAngle = shp.CameraHorizontalTurnAngle; } if (shp.CameraVerticalTurnUpAngle > 0) { camera.VerticalTurnUpAngle = shp.CameraVerticalTurnUpAngle; } if (shp.CameraVerticalTurnDownAngle > 0) { camera.VerticalTurnDownAngle = shp.CameraVerticalTurnDownAngle; } camera.Reset(); sysrender = new SystemRenderer(camera, Game.GameData, Game.ResourceManager, Game); world = new GameWorld(sysrender); world.LoadSystem(sys, Game.ResourceManager); session.WorldReady(); player.World = world; world.Objects.Add(player); world.RenderUpdate += World_RenderUpdate; world.PhysicsUpdate += World_PhysicsUpdate; player.Register(world.Physics); Game.Sound.PlayMusic(sys.MusicSpace); debugphysics = new PhysicsDebugRenderer(); //world.Physics.EnableWireframes(debugphysics); cur_arrow = Game.ResourceManager.GetCursor("cross"); cur_reticle = Game.ResourceManager.GetCursor("fire_neutral"); current_cur = cur_arrow; Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; Game.Mouse.MouseDown += Mouse_MouseDown; input = new InputManager(Game); input.ToggleActivated += Input_ToggleActivated; input.ToggleUp += Input_ToggleUp; pilotcomponent = new AutopilotComponent(player); pilotcomponent.DockComplete += Pilotcomponent_DockComplete; player.Components.Add(pilotcomponent); player.World = world; world.MessageBroadcasted += World_MessageBroadcasted; Game.Sound.ResetListenerVelocity(); FadeIn(0.5, 0.5); }
void FinishLoad() { var shp = Game.GameData.GetShip(session.PlayerShip); //Set up player object + camera player = new GameObject(shp.Drawable, Game.ResourceManager, false); control = new ShipControlComponent(player); control.Ship = shp; player.Components.Add(control); weapons = new WeaponControlComponent(player); player.Components.Add(weapons); powerCore = new PowerCoreComponent(player) { ThrustCapacity = 1000, ThrustChargeRate = 100 }; player.Components.Add(powerCore); player.Transform = new Matrix4(session.PlayerOrientation) * Matrix4.CreateTranslation(session.PlayerPosition); player.PhysicsComponent.Mass = shp.Mass; if (shp.Mass < 0) { FLLog.Error("Ship", "Mass < 0"); } player.Nickname = "player"; foreach (var equipment in session.MountedEquipment) { var equip = Game.GameData.GetEquipment(equipment.Value); if (equip == null) { continue; } equip.LoadResources(); var obj = new GameObject(equip, player.GetHardpoint(equipment.Key), player); player.Children.Add(obj); } camera = new ChaseCamera(Game.Viewport); camera.ChasePosition = session.PlayerPosition; camera.ChaseOrientation = player.Transform.ClearTranslation(); var offset = shp.ChaseOffset; camera.DesiredPositionOffset = offset; camera.Reset(); sysrender = new SystemRenderer(camera, Game.GameData, Game.ResourceManager, Game); world = new GameWorld(sysrender); world.LoadSystem(sys, Game.ResourceManager); world.Objects.Add(player); world.RenderUpdate += World_RenderUpdate; world.PhysicsUpdate += World_PhysicsUpdate; var eng = new GameData.Items.Engine() { FireEffect = "gf_li_smallengine02_fire", LinearDrag = 600, MaxForce = 48000 }; player.Components.Add((ecpt = new EngineComponent(player, eng, Game))); ecpt.Speed = 0; player.Register(world.Physics); Game.Sound.PlayMusic(sys.MusicSpace); Game.Keyboard.TextInput += G_Keyboard_TextInput; debugphysics = new PhysicsDebugRenderer(); //world.Physics.EnableWireframes(debugphysics); cur_arrow = Game.ResourceManager.GetCursor("cross"); cur_reticle = Game.ResourceManager.GetCursor("fire_neutral"); current_cur = cur_arrow; Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; Game.Mouse.MouseDown += Mouse_MouseDown; input = new InputManager(Game); input.ToggleActivated += Input_ToggleActivated; input.ToggleUp += Input_ToggleUp; pilotcomponent = new AutopilotComponent(player); pilotcomponent.DockComplete += Pilotcomponent_DockComplete; player.Components.Add(pilotcomponent); player.World = world; world.MessageBroadcasted += World_MessageBroadcasted; ConstructHud(); FadeIn(0.5, 0.5); }