예제 #1
0
        public void SpawnRequest(MClient c, MNetMessage m)
        {
            MSpawnMessage sm = MSpawnMessage.Deserialize <MSpawnMessage>(m.Payload);

            //List<MServerObject> spawns = JsonConvert.DeserializeObject<List<MServerObject>>(sm.Spawnables);
            foreach (DataRow dr in sm.SpawnTable.Rows)
            {
                if (string.IsNullOrEmpty((string)dr["instanceid"]))
                {
                    dr[DB.INSTANCEID]   = UidGen.GUID();
                    dr[DB.DATECREATED]  = DateTime.Now;
                    dr[DB.DATEMODIFIED] = DateTime.Now;
                }
            }

            _DataBase.AddToWorld(sm.SpawnTable);

            MNetMessage mn = new MNetMessage();

            mn.Command = MNetMessage.SPAWN;
            mn.Version = 1;
            mn.Payload = sm.Serialize();
            SendToAllClients(c, mn.Serialize());

            UniverseChanged?.Invoke(this, new ServerEvent("+1", 3));
        }
예제 #2
0
        public void SyncWorld(MClient c)
        {
            MNetMessage mn = new MNetMessage();

            mn.Command = MNetMessage.SPAWN;
            mn.UserID  = MNetMessage.SERVER;
            if (c.Account != null)
            {
                //List<MServerObject> items = DB.GetObjectsNear(c.Account.UserID, c.Account.CurrentPosition[0], c.Account.CurrentPosition[1], c.Account.CurrentPosition[2]);

                //if (items.Count > 0)
                {
                    MSpawnMessage msm = new MSpawnMessage(_DataBase.GetObjectsNear(c.Account.UserID, c.Account.CurrentPosition[0], c.Account.CurrentPosition[1], c.Account.CurrentPosition[2]));
                    mn.Payload = msm.Serialize();
                    Send(c, "Message", mn.Serialize());
                }
            }
        }