Beispiel #1
0
        void IServerPlayer.Launch()
        {
            var b   = Game.GameData.GetBase(Base);
            var sys = Game.GameData.GetSystem(b.System);

            Game.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.Nickname + " docking to " + b.Nickname);
                }
                else
                {
                    Position    = obj.Position;
                    Orientation = (obj.Rotation ?? Matrix4x4.Identity).ExtractRotation();
                    Position    = Vector3.Transform(new Vector3(0, 0, 500), Orientation) + obj.Position; //TODO: This is bad
                }
                BaseData = null;
                Base     = null;
                rpcClient.SpawnPlayer(System, world.TotalTime, Position, Orientation);
                world.SpawnPlayer(this, Position, Orientation);
                msnRuntime?.EnteredSpace();
            });
        }
Beispiel #2
0
        void PlayerEnterBase()
        {
            //fetch news articles
            List <NewsArticle> news = new List <NewsArticle>();

            foreach (var x in Game.GameData.Ini.News.NewsItems.Where(NewsFind))
            {
                news.Add(new NewsArticle()
                {
                    Icon = x.Icon, Category = x.Category, Headline = x.Headline,
                    Logo = x.Logo, Text = x.Text
                });
            }
            //load base
            BaseData = Game.GameData.GetBase(Base);
            //update
            Character.UpdatePosition(Base, System, Position);
            //send to player
            lock (rtcs)
            {
                rpcClient.BaseEnter(Base, rtcs.ToArray(), news.ToArray(), BaseData.SoldGoods.Select(x => new SoldGood()
                {
                    GoodCRC = CrcTool.FLModelCrc(x.Good.Ini.Nickname),
                    Price   = x.Price,
                    Rank    = x.Rank,
                    Rep     = x.Rep,
                    ForSale = x.ForSale
                }).ToArray(), GetSoldShips().ToArray());
            }
        }
Beispiel #3
0
        public GameData.Base GetBase(string id)
        {
            var legacy = fldata.Universe.FindBase(id);
            var mbase  = fldata.MBases.FindBase(id);
            var b      = new GameData.Base();

            foreach (var room in legacy.Rooms)
            {
                var nr    = new GameData.BaseRoom();
                var mroom = mbase.FindRoom(room.Nickname);
                nr.Music               = room.Music;
                nr.ThnPaths            = new List <string>();
                nr.PlayerShipPlacement = room.PlayerShipPlacement;
                foreach (var path in room.SceneScripts)
                {
                    nr.ThnPaths.Add(Compatibility.VFS.GetPath(fldata.Freelancer.DataPath + path));
                }
                nr.Hotspots = new List <GameData.BaseHotspot>();
                foreach (var hp in room.Hotspots)
                {
                    nr.Hotspots.Add(new GameData.BaseHotspot()
                    {
                        Name           = hp.Name,
                        Behavior       = hp.Behavior,
                        Room           = hp.RoomSwitch,
                        SetVirtualRoom = hp.VirtualRoom
                    });
                }
                nr.Nickname = room.Nickname;
                if (room.Nickname == legacy.StartRoom)
                {
                    b.StartRoom = nr;
                }
                nr.Camera = room.Camera;
                nr.Npcs   = new List <GameData.BaseNpc>();
                if (mroom != null)
                {
                    foreach (var npc in mroom.NPCs)
                    {
                        /*var newnpc = new GameData.BaseNpc();
                         * newnpc.StandingPlace = npc.StandMarker;
                         * var gfnpc = mbase.FindNpc(npc.Npc);
                         * newnpc.HeadMesh = fldata.Bodyparts.FindBodypart(gfnpc.Head).MeshPath;
                         * newnpc.BodyMesh = fldata.Bodyparts.FindBodypart(gfnpc.Body).MeshPath;
                         * newnpc.LeftHandMesh = fldata.Bodyparts.FindBodypart(gfnpc.LeftHand).MeshPath;
                         * newnpc.RightHandMesh = fldata.Bodyparts.FindBodypart(gfnpc.RightHand).MeshPath;
                         * nr.Npcs.Add(newnpc);*/
                    }
                }
                b.Rooms.Add(nr);
            }
            return(b);
        }
Beispiel #4
0
        public void JumpTo(string system, string target)
        {
            rpcClient.StartJumpTunnel();
            if (World != null)
            {
                World.RemovePlayer(this);
            }

            var sys = Game.GameData.GetSystem(system);

            Game.RequestWorld(sys, (world) =>
            {
                this.World = world;
                var obj    = sys.Objects.FirstOrDefault((o) =>
                {
                    return(o.Nickname.Equals(target, StringComparison.OrdinalIgnoreCase));
                });
                System   = system;
                Base     = null;
                Position = Vector3.Zero;
                if (obj == null)
                {
                    FLLog.Error("Server", $"Can't find target {target} to spawn player in {system}");
                }
                else
                {
                    Position    = obj.Position;
                    Orientation = (obj.Rotation ?? Matrix4x4.Identity).ExtractRotation();
                    Position    = Vector3.Transform(new Vector3(0, 0, 500), Orientation) + obj.Position; //TODO: This is bad
                }
                BaseData = null;
                Base     = null;
                rpcClient.SpawnPlayer(System, world.TotalTime, Position, Orientation);
                world.SpawnPlayer(this, Position, Orientation);
                msnRuntime?.EnteredSpace();
            });
        }