Exemplo n.º 1
0
        public CombatDebugOverlay(Actor self)
        {
            healthInfo = self.Info.TraitInfoOrDefault <HealthInfo>();
            coords     = Exts.Lazy(self.Trait <BodyOrientation>);

            var localPlayer = self.World.LocalPlayer;

            devMode = localPlayer != null?localPlayer.PlayerActor.Trait <DeveloperMode>() : null;
        }
Exemplo n.º 2
0
 public SharedCargo(ActorInitializer init, SharedCargoInfo info)
     : base(info)
 {
     self             = init.Self;
     Manager          = self.Owner.PlayerActor.TraitsImplementing <SharedCargoManager>().Where(m => m.Info.Type == Info.ShareType).First();
     Unloading        = false;
     checkTerrainType = info.UnloadTerrainTypes.Count > 0;
     facing           = Exts.Lazy(self.TraitOrDefault <IFacing>);
 }
Exemplo n.º 3
0
        public SupportPowerManager(ActorInitializer init)
        {
            self       = init.self;
            DevMode    = init.self.Trait <DeveloperMode>();
            RadarPings = Exts.Lazy(() => init.world.WorldActor.TraitOrDefault <RadarPings>());

            init.world.ActorAdded   += ActorAdded;
            init.world.ActorRemoved += ActorRemoved;
        }
Exemplo n.º 4
0
 protected ClientTooltipRegionWidget(ClientTooltipRegionWidget other)
     : base(other)
 {
     Template         = other.Template;
     TooltipContainer = other.TooltipContainer;
     tooltipContainer = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
     orderManager     = other.orderManager;
     clientIndex      = other.clientIndex;
 }
Exemplo n.º 5
0
        public EditorViewportControllerWidget(World world, WorldRenderer worldRenderer)
        {
            this.worldRenderer  = worldRenderer;
            tooltipContainer    = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
            CurrentBrush        = DefaultBrush = new EditorDefaultBrush(this, worldRenderer);
            editorActionManager = world.WorldActor.Trait <EditorActionManager>();

            editorActionManager.OnChange += EditorActionManagerOnChange;
        }
Exemplo n.º 6
0
        public ObserverArmyIconsWidget(World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;

            GetTooltipUnit   = () => TooltipUnit;
            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
        }
Exemplo n.º 7
0
        public ViewportControllerWidget(World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer   = Exts.Lazy(() =>
                                           Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            resourceLayer = world.WorldActor.TraitOrDefault <ResourceLayer>();
        }
Exemplo n.º 8
0
 public DeployToUpgrade(Actor self, DeployToUpgradeInfo info)
 {
     this.self        = self;
     this.info        = info;
     manager          = self.Trait <UpgradeManager>();
     checkTerrainType = info.AllowedTerrainTypes.Count > 0;
     canTurn          = self.Info.HasTraitInfo <IFacingInfo>();
     body             = Exts.Lazy(self.TraitOrDefault <ISpriteBody>);
 }
        public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;
            clocks             = new Dictionary <string, Animation>();

            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
        }
        public ProductionQueueOrBuildingPickerFromSelection(World world, ProductionQueueOrBuildingPickerFromSelectionInfo info)
        {
            this.world = world;

            tabsWidget             = Exts.Lazy(() => Ui.Root.GetOrNull(info.ProductionTabsWidget) as ProductionTabsWidget);
            paletteWidget          = Exts.Lazy(() => Ui.Root.GetOrNull(info.ProductionPaletteWidget) as ProductionPaletteWidget);
            buildSelectWidget      = Exts.Lazy(() => Ui.Root.GetOrNull(info.BuildSelectPalette) as BuildSelectPaletteWidget);
            productionParentWidget = Exts.Lazy(() => Ui.Root.GetOrNull(info.ProductionParent));
            buildingCancelWidget   = Exts.Lazy(() => Ui.Root.GetOrNull(info.BuildingCancel));
        }
Exemplo n.º 11
0
        public SupportPowerManager(ActorInitializer init)
        {
            Self = init.Self;

            TechTree   = Self.Trait <TechTree>();
            RadarPings = Exts.Lazy(() => init.World.WorldActor.TraitOrDefault <RadarPings>());

            init.World.ActorAdded   += ActorAdded;
            init.World.ActorRemoved += ActorRemoved;
        }
Exemplo n.º 12
0
 protected MapPreviewWidget(MapPreviewWidget other)
     : base(other)
 {
     Preview          = other.Preview;
     SpawnOccupants   = other.SpawnOccupants;
     ShowSpawnPoints  = other.ShowSpawnPoints;
     TooltipTemplate  = other.TooltipTemplate;
     TooltipContainer = other.TooltipContainer;
     tooltipContainer = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
 }
Exemplo n.º 13
0
 public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
 {
     this.world         = world;
     this.worldRenderer = worldRenderer;
     clocks             = new Dictionary <ProductionQueue, Animation>();
     GetTooltipIcon     = () => TooltipIcon;
     tooltipContainer   = Exts.Lazy(() =>
                                    Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
     iconSize = new float2(IconWidth, IconHeight);
 }
Exemplo n.º 14
0
        public ViewportControllerWidget(ModData modData, World world, WorldRenderer worldRenderer)
        {
            this.modData       = modData;
            this.world         = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer   = Exts.Lazy(() =>
                                           Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            resourceRenderers = world.WorldActor.TraitsImplementing <ResourceRenderer>().ToArray();
        }
Exemplo n.º 15
0
        public SupportPowersWidget(World world, WorldRenderer worldRenderer)
        {
            this.worldRenderer = worldRenderer;
            spm = world.LocalPlayer.PlayerActor.Trait <SupportPowerManager>();
            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            icon  = new Animation(world, "icon");
            clock = new Animation(world, "clock");
        }
Exemplo n.º 16
0
        public CombatDebugOverlay(Actor self)
        {
            attack = Exts.Lazy(() => self.TraitOrDefault <AttackBase>());
            coords = Exts.Lazy(() => self.Trait <IBodyOrientation>());
            health = Exts.Lazy(() => self.TraitOrDefault <Health>());

            var localPlayer = self.World.LocalPlayer;

            devMode = localPlayer != null?localPlayer.PlayerActor.Trait <DeveloperMode>() : null;
        }
Exemplo n.º 17
0
        public ShpTSReader(Stream stream)
        {
            stream.ReadUInt16();
            var width      = stream.ReadUInt16();
            var height     = stream.ReadUInt16();
            var size       = new Size(width, height);
            var frameCount = stream.ReadUInt16();

            for (var i = 0; i < frameCount; i++)
            {
                frames.Add(new FrameHeader(stream, size));
            }

            for (var i = 0; i < frameCount; i++)
            {
                var f = frames[i];
                if (f.FileOffset == 0)
                {
                    continue;
                }

                stream.Position = f.FileOffset;

                // Uncompressed
                if (f.Format == 1 || f.Format == 0)
                {
                    f.Data = stream.ReadBytes(f.Size.Width * f.Size.Height);
                }

                // Uncompressed scanlines
                else if (f.Format == 2)
                {
                    f.Data = new byte[f.Size.Width * f.Size.Height];
                    for (var j = 0; j < f.Size.Height; j++)
                    {
                        var length = stream.ReadUInt16() - 2;
                        stream.Read(f.Data, f.Size.Width * j, length);
                    }
                }

                // RLE-zero compressed scanlines
                else if (f.Format == 3)
                {
                    f.Data = new byte[f.Size.Width * f.Size.Height];

                    for (var j = 0; j < f.Size.Height; j++)
                    {
                        var length = stream.ReadUInt16() - 2;
                        Format2.DecodeInto(stream.ReadBytes(length), f.Data, j * f.Size.Width);
                    }
                }
            }

            spriteFrames = Exts.Lazy(() => frames.Cast <ISpriteFrame>());
        }
Exemplo n.º 18
0
        public MapPreviewWidget()
        {
            tooltipContainer = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            spawnClaimed       = ChromeProvider.GetImage("lobby-bits", "spawn-claimed");
            spawnUnclaimed     = ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed");
            spawnFont          = Game.Renderer.Fonts[ChromeMetrics.Get <string>("SpawnFont")];
            spawnColor         = ChromeMetrics.Get <Color>("SpawnColor");
            spawnContrastColor = ChromeMetrics.Get <Color>("SpawnContrastColor");
            spawnLabelOffset   = ChromeMetrics.Get <int2>("SpawnLabelOffset");
        }
Exemplo n.º 19
0
        public CombatDebugOverlay(Actor self)
        {
            healthInfo = self.Info.TraitInfoOrDefault <HealthInfo>();
            blockInfo  = self.Info.TraitInfoOrDefault <BlocksProjectilesInfo>();
            attack     = Exts.Lazy(() => self.TraitOrDefault <AttackBase>());
            coords     = Exts.Lazy(() => self.Trait <BodyOrientation>());

            var localPlayer = self.World.LocalPlayer;

            devMode = localPlayer != null?localPlayer.PlayerActor.Trait <DeveloperMode>() : null;
        }
 public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
 {
     this.world         = world;
     this.worldRenderer = worldRenderer;
     clocks             = new Dictionary <ProductionQueue, Animation>();
     timestep           = world.IsReplay ? world.WorldActor.Trait <MapOptions>().GameSpeed.Timestep : world.Timestep;
     GetTooltipIcon     = () => TooltipIcon;
     tooltipContainer   = Exts.Lazy(() =>
                                    Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
     iconSize = new float2(IconWidth, IconHeight);
 }
Exemplo n.º 21
0
        public SoundInfo(MiniYaml y)
        {
            FieldLoader.Load(this, y);
            Variants      = Load(y, "Variants");
            Prefixes      = Load(y, "Prefixes");
            Voices        = Load(y, "Voices");
            Notifications = Load(y, "Notifications");

            VoicePools         = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(a.Value)));
            NotificationsPools = Exts.Lazy(() => Notifications.ToDictionary(a => a.Key, a => new SoundPool(a.Value)));
        }
Exemplo n.º 22
0
        public SupportPowersWidget(ModData modData, World world, WorldRenderer worldRenderer)
        {
            this.modData       = modData;
            this.worldRenderer = worldRenderer;
            GetTooltipIcon     = () => TooltipIcon;
            spm = world.LocalPlayer.PlayerActor.Trait <SupportPowerManager>();
            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            clock = new Animation(world, ClockAnimation);
        }
Exemplo n.º 23
0
        public ResourceCollector(Actor self, ResourceCollectorInfo info)
            : base(info)
        {
            this.info = info;
            Ticks     = info.InitialDelay;

            resourceLayer = self.World.WorldActor.Trait <UndergroundResourceLayer>();
            building      = self.Trait <Building>();

            rallyPoint = Exts.Lazy(() => self.IsDead ? null : self.TraitOrDefault <RallyPoint>());
        }
        protected LabelWithTooltipWidget(LabelWithTooltipWidget other)
            : base(other)
        {
            TooltipTemplate  = other.TooltipTemplate;
            TooltipContainer = other.TooltipContainer;

            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            GetTooltipText = other.GetTooltipText;
        }
Exemplo n.º 25
0
 public AttackGarrisoned(Actor self, AttackGarrisonedInfo info)
     : base(self, info)
 {
     Info      = info;
     coords    = Exts.Lazy(() => self.Trait <BodyOrientation>());
     armaments = new List <Armament>();
     muzzles   = new List <AnimationWithOffset>();
     paxFacing = new Dictionary <Actor, IFacing>();
     paxPos    = new Dictionary <Actor, IPositionable>();
     paxRender = new Dictionary <Actor, RenderSprites>();
 }
Exemplo n.º 26
0
        public D2ImageWidget(World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;

            GetImageName       = () => ImageName;
            GetImageCollection = () => ImageCollection;
            GetPaletteName     = () => PaletteName;
            GetTooltipText     = () => TooltipText;
            tooltipContainer   = Exts.Lazy(() =>
                                           Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
        }
Exemplo n.º 27
0
        public ProductionPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
        {
            this.orderManager  = orderManager;
            World              = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer   = Exts.Lazy(() =>
                                           Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation(world, NotBuildableAnimation);
            cantBuild.PlayFetchIndex(NotBuildableSequence, () => 0);
            clock = new Animation(world, ClockAnimation);
        }
Exemplo n.º 28
0
        public EditorViewportControllerWidget(World world, WorldRenderer worldRenderer)
        {
            this.worldRenderer  = worldRenderer;
            tooltipContainer    = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
            CurrentBrush        = DefaultBrush = new EditorDefaultBrush(this, worldRenderer);
            editorActionManager = world.WorldActor.Trait <EditorActionManager>();

            editorActionManager.OnChange += EditorActionManagerOnChange;

            // Allow zooming out to full map size
            worldRenderer.Viewport.UnlockMinimumZoom(0.25f);
        }
Exemplo n.º 29
0
        public ProductionPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer)
        {
            this.orderManager  = orderManager;
            this.World         = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer   = Exts.Lazy(() =>
                                           Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation(world, "clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation(world, "clock");
        }
Exemplo n.º 30
0
        public SequenceProvider(IReadOnlyFileSystem fileSystem, ModData modData, TileSet tileSet, MiniYaml additionalSequences)
        {
            this.modData = modData;
            this.tileSet = tileSet;

            sequences = Exts.Lazy(() => {
                using (new Support.PerfTimer("LoadSequences"))
                    return(Load(fileSystem, additionalSequences));
            });

            spriteCache = Exts.Lazy(() => new SpriteCache(fileSystem, modData.SpriteLoaders, new SheetBuilder(SheetT.Indexed)));
        }