当前位置: 首页>>代码示例>>C#>>正文


C# ModData类代码示例

本文整理汇总了C#中ModData的典型用法代码示例。如果您正苦于以下问题:C# ModData类的具体用法?C# ModData怎么用?C# ModData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ModData类属于命名空间,在下文中一共展示了ModData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScrollItemWidget

 public ScrollItemWidget(ModData modData)
     : base(modData)
 {
     IsVisible = () => false;
     VisualHeight = 0;
     IgnoreChildMouseOver = true;
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:ScrollItemWidget.cs

示例2: GetSpriteSrc

		protected override string GetSpriteSrc(ModData modData, TileSet tileSet, string sequence, string animation, string sprite, Dictionary<string, MiniYaml> d)
		{
			var loader = (TilesetSpecificSpriteSequenceLoader)Loader;

			var spriteName = sprite ?? sequence;

			if (LoadField<bool>(d, "UseTilesetCode", false))
			{
				string code;
				if (loader.TilesetCodes.TryGetValue(ResolveTilesetId(tileSet, d), out code))
					spriteName = spriteName.Substring(0, 1) + code + spriteName.Substring(2, spriteName.Length - 2);
			}

			if (LoadField<bool>(d, "AddExtension", true))
			{
				var useTilesetExtension = LoadField<bool>(d, "UseTilesetExtension", false);

				string tilesetExtension;
				if (useTilesetExtension && loader.TilesetExtensions.TryGetValue(ResolveTilesetId(tileSet, d), out tilesetExtension))
					return spriteName + tilesetExtension;

				return spriteName + loader.DefaultSpriteExtension;
			}

			return spriteName;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:TilesetSpecificSpriteSequence.cs

示例3: Run

        public void Run(ModData modData, string[] args)
        {
            Game.ModData = modData;
            map = new Map(modData, modData.ModFiles.OpenPackage(args[1]));
            Console.WriteLine("Resizing map {0} from {1} to {2},{3}", map.Title, map.MapSize, width, height);
            map.Resize(width, height);

            var forRemoval = new List<MiniYamlNode>();

            foreach (var kv in map.ActorDefinitions)
            {
                var actor = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());
                var location = actor.InitDict.Get<LocationInit>().Value(null);
                if (!map.Contains(location))
                {
                    Console.WriteLine("Removing actor {0} located at {1} due being outside of the new map boundaries.".F(actor.Type, location));
                    forRemoval.Add(kv);
                }
            }

            foreach (var kv in forRemoval)
                map.ActorDefinitions.Remove(kv);

            map.Save((IReadWritePackage)map.Package);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:25,代码来源:ResizeMapCommand.cs

示例4: PreReleaseWarningPrompt

 public PreReleaseWarningPrompt(Widget widget, World world, ModData modData)
 {
     if (!promptAccepted && modData.Manifest.Metadata.Version != "{DEV_VERSION}")
         widget.Get<ButtonWidget>("CONTINUE_BUTTON").OnClick = () => ShowMainMenu(world);
     else
         ShowMainMenu(world);
 }
开发者ID:pchote,项目名称:OpenRA,代码行数:7,代码来源:PreReleaseWarningPrompt.cs

示例5: ProcessYaml

        static void ProcessYaml(ModData modData, Map map, MiniYaml yaml, int engineDate, UpgradeAction processYaml)
        {
            if (yaml == null)
                return;

            if (yaml.Value != null)
            {
                var files = FieldLoader.GetValue<string[]>("value", yaml.Value);
                foreach (var filename in files)
                {
                    var fileNodes = MiniYaml.FromStream(map.Open(filename), filename);
                    processYaml(modData, engineDate, ref fileNodes, null, 0);

                    // HACK: Obtain the writable save path using knowledge of the underlying filesystem workings
                    var packagePath = filename;
                    var package = map.Package;
                    if (filename.Contains("|"))
                        modData.DefaultFileSystem.TryGetPackageContaining(filename, out package, out packagePath);

                    ((IReadWritePackage)package).Update(packagePath, Encoding.ASCII.GetBytes(fileNodes.WriteToString()));
                }
            }

            processYaml(modData, engineDate, ref yaml.Nodes, null, 1);
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:25,代码来源:UpgradeMapCommand.cs

示例6: Run

        public void Run(ModData modData, string[] args)
        {
            for (int i = 1; i < args.Length;)
            {
                var parts = args[i].Split(Comma, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 3)
                {
                    foreach (var c in parts)
                        Console.Write(byte.Parse(c).ToString("X2"));
                }
                else
                {
                    Console.Write(byte.Parse(parts[1]).ToString("X2"));
                    Console.Write(byte.Parse(parts[2]).ToString("X2"));
                    Console.Write(byte.Parse(parts[3]).ToString("X2"));
                    var alpha = byte.Parse(parts[0]);
                    if (alpha < 255)
                        Console.Write(alpha.ToString("X2"));
                }

                if (++i != args.Length)
                    Console.Write(", ");
                else
                    Console.WriteLine();
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:Rgba2Hex.cs

示例7: CursorProvider

        public CursorProvider(ModData modData)
        {
            var sequenceFiles = modData.Manifest.Cursors;

            cursors = new Dictionary<string, CursorSequence>();
            palettes = new Cache<string, PaletteReference>(CreatePaletteReference);
            var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
            var shadowIndex = new int[] { };

            if (sequences.NodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(sequences.NodesDict["ShadowIndex"].Value,
                    out shadowIndex[shadowIndex.Length - 1]);
            }

            palette = new HardwarePalette();
            foreach (var p in sequences.NodesDict["Palettes"].Nodes)
                palette.AddPalette(p.Key, new Palette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);

            var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));
            foreach (var s in sequences.NodesDict["Cursors"].Nodes)
                LoadSequencesForCursor(spriteLoader, s.Key, s.Value);

            palette.Initialize();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:26,代码来源:CursorProvider.cs

示例8: CursorProvider

        public CursorProvider(ModData modData)
        {
            var fileSystem = modData.DefaultFileSystem;
            var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select(
                s => MiniYaml.FromStream(fileSystem.Open(s), s)));

            var shadowIndex = new int[] { };

            var nodesDict = new MiniYaml(null, sequenceYaml).ToDictionary();
            if (nodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
                    out shadowIndex[shadowIndex.Length - 1]);
            }

            var palettes = new Dictionary<string, ImmutablePalette>();
            foreach (var p in nodesDict["Palettes"].Nodes)
                palettes.Add(p.Key, new ImmutablePalette(fileSystem.Open(p.Value.Value), shadowIndex));

            Palettes = palettes.AsReadOnly();

            var frameCache = new FrameCache(fileSystem, modData.SpriteLoaders);
            var cursors = new Dictionary<string, CursorSequence>();
            foreach (var s in nodesDict["Cursors"].Nodes)
                foreach (var sequence in s.Value.Nodes)
                    cursors.Add(sequence.Key, new CursorSequence(frameCache, sequence.Key, s.Key, s.Value.Value, sequence.Value));

            Cursors = cursors.AsReadOnly();
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:30,代码来源:CursorProvider.cs

示例9: Run

        public void Run(ModData modData, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            Game.ModData = modData;

            try
            {
                Log.AddChannel("debug", null);
                Log.AddChannel("perf", null);

                // bind some nonfatal error handling into FieldLoader, so we don't just *explode*.
                ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s));
                FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));

                IEnumerable<Map> maps;
                if (args.Length < 2)
                {
                    Game.ModData.MapCache.LoadMaps();
                    maps = Game.ModData.MapCache
                        .Where(m => m.Status == MapStatus.Available)
                        .Select(m => m.Map);
                }
                else
                    maps = new[] { new Map(args[1]) };

                foreach (var testMap in maps)
                {
                    Console.WriteLine("Testing map: {0}".F(testMap.Title));
                    testMap.PreloadRules();

                    foreach (var customPassType in Game.ModData.ObjectCreator
                        .GetTypesImplementing<ILintPass>())
                    {
                        try
                        {
                            var customPass = (ILintPass)Game.ModData.ObjectCreator
                                .CreateBasic(customPassType);

                            customPass.Run(EmitError, EmitWarning, testMap);
                        }
                        catch (Exception e)
                        {
                            EmitError("{0} failed with exception: {0}".F(customPassType, e));
                        }
                    }
                }

                if (errors > 0)
                {
                    Console.WriteLine("Errors: {0}", errors);
                    Environment.Exit(1);
                }
            }
            catch (Exception e)
            {
                EmitError("Failed with exception: {0}".F(e));
                Environment.Exit(1);
            }
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:59,代码来源:CheckYaml.cs

示例10: Run

        public void Run(ModData modData, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            Game.ModData = modData;

            var package = modData.ModFiles.OpenWritablePackage(args[1]);
            var engineDate = Exts.ParseIntegerInvariant(args[2]);
            UpgradeMap(modData, package, engineDate);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:9,代码来源:UpgradeMapCommand.cs

示例11: MultiplayerLogic

        public MultiplayerLogic(Widget widget, ModData modData, Action onStart, Action onExit, string directConnectHost, int directConnectPort)
        {
            this.modData = modData;
            this.onStart = onStart;
            this.onExit = onExit;

            incompatibleVersionColor = ChromeMetrics.Get<Color>("IncompatibleVersionColor");
            incompatibleGameColor = ChromeMetrics.Get<Color>("IncompatibleGameColor");
            incompatibleProtectedGameColor = ChromeMetrics.Get<Color>("IncompatibleProtectedGameColor");
            protectedGameColor = ChromeMetrics.Get<Color>("ProtectedGameColor");
            waitingGameColor = ChromeMetrics.Get<Color>("WaitingGameColor");
            incompatibleWaitingGameColor = ChromeMetrics.Get<Color>("IncompatibleWaitingGameColor");
            gameStartedColor = ChromeMetrics.Get<Color>("GameStartedColor");
            incompatibleGameStartedColor = ChromeMetrics.Get<Color>("IncompatibleGameStartedColor");

            LoadBrowserPanel(widget);
            LoadDirectConnectPanel(widget);
            LoadCreateServerPanel(widget);

            // Filter and refresh buttons act on the browser panel,
            // but remain visible (disabled) on the other panels
            var refreshButton = widget.Get<ButtonWidget>("REFRESH_BUTTON");
            refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching || panel != PanelType.Browser;

            var filtersButton = widget.Get<DropDownButtonWidget>("FILTERS_DROPDOWNBUTTON");
            filtersButton.IsDisabled = () => searchStatus == SearchStatus.Fetching || panel != PanelType.Browser;

            var browserTab = widget.Get<ButtonWidget>("BROWSER_TAB");
            browserTab.IsHighlighted = () => panel == PanelType.Browser;
            browserTab.OnClick = () => panel = PanelType.Browser;

            var directConnectTab = widget.Get<ButtonWidget>("DIRECTCONNECT_TAB");
            directConnectTab.IsHighlighted = () => panel == PanelType.DirectConnect;
            directConnectTab.OnClick = () => panel = PanelType.DirectConnect;

            var createServerTab = widget.Get<ButtonWidget>("CREATE_TAB");
            createServerTab.IsHighlighted = () => panel == PanelType.CreateServer;
            createServerTab.OnClick = () => panel = PanelType.CreateServer;

            widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
            Game.LoadWidget(null, "GLOBALCHAT_PANEL", widget.Get("GLOBALCHAT_ROOT"), new WidgetArgs());

            RefreshServerList();

            if (directConnectHost != null)
            {
                // The connection window must be opened at the end of the tick for the widget hierarchy to
                // work out, but we also want to prevent the server browser from flashing visible for one tick.
                widget.Visible = false;
                Game.RunAfterTick(() =>
                {
                    ConnectionLogic.Connect(directConnectHost, directConnectPort, "", OpenLobby, DoNothing);
                    widget.Visible = true;
                });
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:56,代码来源:MultiplayerLogic.cs

示例12: ReplayBrowserLogic

        public ReplayBrowserLogic(Widget widget, ModData modData, Action onExit, Action onStart)
        {
            panel = widget;

            this.modData = modData;
            this.onStart = onStart;
            Game.BeforeGameStart += OnGameStart;

            playerList = panel.Get<ScrollPanelWidget>("PLAYER_LIST");
            playerHeader = playerList.Get<ScrollItemWidget>("HEADER");
            playerTemplate = playerList.Get<ScrollItemWidget>("TEMPLATE");
            playerList.RemoveChildren();

            panel.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { cancelLoadingReplays = true; Ui.CloseWindow(); onExit(); };

            replayList = panel.Get<ScrollPanelWidget>("REPLAY_LIST");
            var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");

            var mod = modData.Manifest;
            var dir = Platform.ResolvePath("^", "Replays", mod.Id, mod.Metadata.Version);

            if (Directory.Exists(dir))
                ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template));

            var watch = panel.Get<ButtonWidget>("WATCH_BUTTON");
            watch.IsDisabled = () => selectedReplay == null || selectedReplay.GameInfo.MapPreview.Status != MapStatus.Available;
            watch.OnClick = () => { WatchReplay(); };

            panel.Get("REPLAY_INFO").IsVisible = () => selectedReplay != null;

            var preview = panel.Get<MapPreviewWidget>("MAP_PREVIEW");
            preview.SpawnOccupants = () => selectedSpawns;
            preview.Preview = () => selectedReplay != null ? selectedReplay.GameInfo.MapPreview : null;

            var titleLabel = panel.GetOrNull<LabelWidget>("MAP_TITLE");
            if (titleLabel != null)
            {
                titleLabel.IsVisible = () => selectedReplay != null;

                var font = Game.Renderer.Fonts[titleLabel.Font];
                var title = new CachedTransform<MapPreview, string>(m => WidgetUtils.TruncateText(m.Title, titleLabel.Bounds.Width, font));
                titleLabel.GetText = () => title.Update(selectedReplay.GameInfo.MapPreview);
            }

            var type = panel.GetOrNull<LabelWidget>("MAP_TYPE");
            if (type != null)
            {
                var mapType = new CachedTransform<MapPreview, string>(m => m.Categories.FirstOrDefault() ?? "");
                type.GetText = () => mapType.Update(selectedReplay.GameInfo.MapPreview);
            }

            panel.Get<LabelWidget>("DURATION").GetText = () => WidgetUtils.FormatTimeSeconds((int)selectedReplay.GameInfo.Duration.TotalSeconds);

            SetupFilters();
            SetupManagement();
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:56,代码来源:ReplayBrowserLogic.cs

示例13: CncMainMenuLogic

        public CncMainMenuLogic(Widget widget, World world, ModData modData)
            : base(widget, world, modData)
        {
            var shellmapDecorations = widget.Get("SHELLMAP_DECORATIONS");
            shellmapDecorations.IsVisible = () => menuType != MenuType.None && Game.Settings.Game.ShowShellmap;
            shellmapDecorations.Get<ImageWidget>("RECBLOCK").IsVisible = () => world.WorldTick / 25 % 2 == 0;

            var shellmapDisabledDecorations = widget.Get("SHELLMAP_DISABLED_DECORATIONS");
            shellmapDisabledDecorations.IsVisible = () => !Game.Settings.Game.ShowShellmap;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:10,代码来源:CncMainMenuLogic.cs

示例14: Run

 public void Run(ModData modData, string[] args)
 {
     Game.modData = modData;
     var table = ActorStatsExport.GenerateTable();
     var filename = "{0}-mod-dps.csv".F(Game.modData.Manifest.Mod.Id);
     using (var outfile = new StreamWriter(filename))
         outfile.Write(table.ToCharacterSeparatedValues(";", true));
     Console.WriteLine("{0} has been saved.".F(filename));
     Console.WriteLine("Open as values separated by semicolon.");
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:10,代码来源:ExportCharacterSeparatedRules.cs

示例15: Run

        public void Run(ModData modData, string[] args)
        {
            // HACK: The engine code assumes that Game.modData is set.
            Game.modData = modData;
            Game.modData.MapCache.LoadMaps();

            var engineDate = Exts.ParseIntegerInvariant(args[1]);

            Console.WriteLine("Processing Rules:");
            foreach (var filename in Game.modData.Manifest.Rules)
            {
                Console.WriteLine("\t" + filename);
                var yaml = MiniYaml.FromFile(filename);
                UpgradeRules.UpgradeActorRules(engineDate, ref yaml, null, 0);

                using (var file = new StreamWriter(filename))
                    file.WriteLine(yaml.WriteToString());
            }

            Console.WriteLine("Processing Weapons:");
            foreach (var filename in Game.modData.Manifest.Weapons)
            {
                Console.WriteLine("\t" + filename);
                var yaml = MiniYaml.FromFile(filename);
                UpgradeRules.UpgradeWeaponRules(engineDate, ref yaml, null, 0);

                using (var file = new StreamWriter(filename))
                    file.WriteLine(yaml.WriteToString());
            }

            Console.WriteLine("Processing Tilesets:");
            foreach (var filename in Game.modData.Manifest.TileSets)
            {
                Console.WriteLine("\t" + filename);
                var yaml = MiniYaml.FromFile(filename);
                UpgradeRules.UpgradeTileset(engineDate, ref yaml, null, 0);

                using (var file = new StreamWriter(filename))
                    file.WriteLine(yaml.WriteToString());
            }

            Console.WriteLine("Processing Maps:");
            var maps = Game.modData.MapCache
                .Where(m => m.Status == MapStatus.Available)
                .Select(m => m.Map);

            foreach (var map in maps)
            {
                Console.WriteLine("\t" + map.Path);
                UpgradeRules.UpgradeActorRules(engineDate, ref map.RuleDefinitions, null, 0);
                UpgradeRules.UpgradeWeaponRules(engineDate, ref map.WeaponDefinitions, null, 0);
                map.Save(map.Path);
            }
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:54,代码来源:UpgradeModCommand.cs


注:本文中的ModData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。