Esempio n. 1
0
        void SpaceInitialSpawn(SaveGame sg)
        {
            var sys = Game.GameData.GetSystem(System);

            Game.RequestWorld(sys, (world) =>
            {
                World = world;
                rpcClient.SpawnPlayer(System, world.TotalTime, Position, Orientation);
                world.SpawnPlayer(this, Position, Orientation);
                msnRuntime?.EnteredSpace();
            });
        }
Esempio n. 2
0
        void Launch()
        {
            var b   = server.GameData.GetBase(Base);
            var sys = server.GameData.GetSystem(b.System);

            server.RequestWorld(sys, (world) =>
            {
                this.World = world;
                var obj    = sys.Objects.FirstOrDefault((o) =>
                {
                    return(o.Dock != null &&
                           o.Dock.Kind == DockKinds.Base &&
                           o.Dock.Target.Equals(Base, StringComparison.OrdinalIgnoreCase));
                });
                System      = b.System;
                Orientation = Quaternion.Identity;
                Position    = Vector3.Zero;
                if (obj == null)
                {
                    FLLog.Error("Base", "Can't find object in " + sys + " docking to " + b);
                }
                else
                {
                    Position    = obj.Position;
                    Orientation = (obj.Rotation == null ? Matrix3.Identity : new Matrix3(obj.Rotation.Value)).ExtractRotation();
                    Position    = Vector3.Transform(new Vector3(0, 0, 500), Orientation) + obj.Position; //TODO: This is bad
                }
                var msg = server.NetServer.CreateMessage();
                msg.Write(new SpawnPlayerPacket()
                {
                    System      = System,
                    Position    = Position,
                    Orientation = Orientation,
                    Ship        = Character.EncodeLoadout()
                });
                server.NetServer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
                world.SpawnPlayer(this, Position, Orientation);
            });
        }
Esempio n. 3
0
        public void OpenSaveGame(Data.Save.SaveGame sg)
        {
            Orientation       = Quaternion.Identity;
            Position          = sg.Player.Position;
            Base              = sg.Player.Base;
            System            = sg.Player.System;
            Character         = new NetCharacter();
            Character.Credits = sg.Player.Money;
            string ps;

            if (sg.Player.ShipArchetype != null)
            {
                ps = sg.Player.ShipArchetype;
            }
            else
            {
                ps = game.GameData.GetShip(sg.Player.ShipArchetypeCrc).Nickname;
            }
            Character.Ship      = game.GameData.GetShip(ps);
            Character.Equipment = new List <NetEquipment>();
            foreach (var eq in sg.Player.Equip)
            {
                var       hp = eq.Hardpoint;
                Equipment equip;
                if (eq.EquipName != null)
                {
                    equip = game.GameData.GetEquipment(eq.EquipName);
                }
                else
                {
                    equip = game.GameData.GetEquipment(eq.EquipHash);
                }
                if (equip != null)
                {
                    Character.Equipment.Add(new NetEquipment()
                    {
                        Equipment = equip, Hardpoint = hp, Health = 1
                    });
                }
            }
            if (Base != null)
            {
                lock (rtcs)
                {
                    Client.SendPacket(new BaseEnterPacket()
                    {
                        Base = Base,
                        Ship = Character.EncodeLoadout(),
                        RTCs = rtcs.ToArray()
                    }, PacketDeliveryMethod.ReliableOrdered);
                }
                InitStory(sg);
            }
            else
            {
                var sys = game.GameData.GetSystem(System);
                game.RequestWorld(sys, (world) =>
                {
                    World = world;
                    Client.SendPacket(new SpawnPlayerPacket()
                    {
                        System      = System,
                        Position    = Position,
                        Orientation = Orientation,
                        Ship        = Character.EncodeLoadout()
                    }, PacketDeliveryMethod.ReliableOrdered);
                    world.SpawnPlayer(this, Position, Orientation);
                    //work around race condition where world spawns after player has been sent to a base
                    InitStory(sg);
                });
            }
        }
Esempio n. 4
0
        public void OpenSaveGame(Data.Save.SaveGame sg)
        {
            Orientation       = Quaternion.Identity;
            Position          = sg.Player.Position;
            Base              = sg.Player.Base;
            System            = sg.Player.System;
            Character         = new NetCharacter();
            Character.Credits = sg.Player.Money;
            string ps;

            if (sg.Player.ShipArchetype != null)
            {
                ps = sg.Player.ShipArchetype;
            }
            else
            {
                ps = game.GameData.GetShip(sg.Player.ShipArchetypeCrc).Nickname;
            }
            Character.Ship      = game.GameData.GetShip(ps);
            Character.Equipment = new List <NetEquipment>();
            foreach (var eq in sg.Player.Equip)
            {
                var       hp = eq.Hardpoint;
                Equipment equip;
                if (eq.EquipName != null)
                {
                    equip = game.GameData.GetEquipment(eq.EquipName);
                }
                else
                {
                    equip = game.GameData.GetEquipment(eq.EquipHash);
                }
                if (equip != null)
                {
                    Character.Equipment.Add(new NetEquipment()
                    {
                        Equipment = equip, Hardpoint = hp, Health = 1
                    });
                }
            }
            if (Base != null)
            {
                lock (rtcs)
                {
                    client.SendPacket(new BaseEnterPacket()
                    {
                        Base = Base,
                        Ship = Character.EncodeLoadout(),
                        RTCs = rtcs.ToArray()
                    }, NetDeliveryMethod.ReliableOrdered);
                }
            }
            else
            {
                var sys = game.GameData.GetSystem(System);
                game.RequestWorld(sys, (world) =>
                {
                    World = world;
                    client.SendPacket(new SpawnPlayerPacket()
                    {
                        System      = System,
                        Position    = Position,
                        Orientation = Orientation,
                        Ship        = Character.EncodeLoadout()
                    }, NetDeliveryMethod.ReliableOrdered);
                    world.SpawnPlayer(this, Position, Orientation);
                });
            }
            var missionNum = sg.StoryInfo?.MissionNum ?? 0;

            if (game.GameData.Ini.ContentDll.AlwaysMission13)
            {
                missionNum = 14;
            }
            if (missionNum != 0 && (missionNum - 1) < game.GameData.Ini.Missions.Count)
            {
                msnRuntime = new MissionRuntime(game.GameData.Ini.Missions[missionNum - 1], this);
                msnRuntime.Update(TimeSpan.Zero);
            }
        }