예제 #1
0
        public void CheckModVersion()
        {
            Action <DownloadDataCompletedEventArgs> onComplete = i =>
            {
                if (i.Error != null)
                {
                    return;
                }
                try
                {
                    var data = Encoding.UTF8.GetString(i.Result);

                    var status = ModVersionStatus.Latest;
                    switch (data)
                    {
                    case "outdated": status = ModVersionStatus.Outdated; break;

                    case "unknown": status = ModVersionStatus.Unknown; break;

                    case "playtest": status = ModVersionStatus.PlaytestAvailable; break;
                    }

                    WarGame.RunAfterTick(() => ModVersionStatus = status);
                }
                catch { }
            };

            var queryURL = VersionCheck + "?protocol={0}&engine={1}&mod={2}&version={3}".F(
                VersionCheckProtocol,
                Uri.EscapeUriString(WarGame.EngineVersion),
                Uri.EscapeUriString(WarGame.ModData.Manifest.Id),
                Uri.EscapeUriString(WarGame.ModData.Manifest.Metadata.Version));

            new Download(queryURL, _ => { }, onComplete);
        }
예제 #2
0
        void UpdateCurrentMap()
        {
            var uid = orderManager.LobbyInfo.GlobalSettings.Map;

            if (map.Uid == uid)
            {
                return;
            }

            map = modData.MapCache[uid];
            if (map.Status == MapStatus.Available)
            {
                // Maps need to be validated and pre-loaded before they can be accessed
                var currentMap = map;
                new Task(() =>
                {
                    // Force map rules to be loaded on this background thread
                    currentMap.PreloadRules();

                    WarGame.RunAfterTick(() =>
                    {
                        // Map may have changed in the meantime
                        if (currentMap != map)
                        {
                            return;
                        }

                        // Tell the server that we have the map
                        if (!currentMap.InvalidCustomRules)
                        {
                            orderManager.IssueOrder(Order.Command("state {0}".F(Session.ClientState.NotReady)));
                        }


                        if (addBotOnMapLoad)
                        {
                            var slot = orderManager.LobbyInfo.FirstEmptySlot();
                            var bot  = currentMap.Rules.Actors["player"].TraitInfos <IBotInfo>().Select(t => t.Type).FirstOrDefault();

                            var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin);

                            if (slot != null && bot != null)
                            {
                                orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot)));
                            }


                            addBotOnMapLoad = false;
                        }
                    });
                }).Start();
            }
        }
예제 #3
0
        public IDisposable Reserve(Actor self, Actor forActor, Aircraft forAircraft)
        {
            if (reservedForAircraft != null && reservedForAircraft.MayYieldReservation)
            {
                reservedForAircraft.UnReserve();
            }

            reservedFor         = forActor;
            reservedForAircraft = forAircraft;

            return(new DisposableAction(() => { reservedFor = null; reservedForAircraft = null; }, () => WarGame.RunAfterTick(() =>
            {
                if (WarGame.IsCurrentWorld(self.World))
                {
                    throw new InvalidOperationException("Attempted to finalize  an undisposed DisposableAction.{0} ({1}) reserved {2} ({3}) "
                                                        .F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));
                }
            })));
        }