コード例 #1
0
 // We do not handle Harvested notification
 void INotifyHarvesterAction.Harvested(Actor self, ResourceType resource)
 {
 }
コード例 #2
0
        public void UpdateMouseover()
        {
            TooltipType       = WorldTooltipType.None;
            ActorTooltipExtra = null;
            var cell = worldRenderer.Viewport.ViewToWorld(Viewport.LastMousePos);

            if (!world.Map.Contains(cell))
            {
                return;
            }

            if (world.ShroudObscures(cell))
            {
                TooltipType = WorldTooltipType.Unexplored;
                return;
            }

            var worldPixel  = worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos);
            var underCursor = world.ScreenMap.ActorsAtMouse(worldPixel)
                              .Where(a => a.Actor.Info.HasTraitInfo <ITooltipInfo>() && !world.FogObscures(a.Actor))
                              .WithHighestSelectionPriority(worldPixel);

            if (underCursor != null)
            {
                ActorTooltip = underCursor.TraitsImplementing <ITooltip>().FirstEnabledTraitOrDefault();
                if (ActorTooltip != null)
                {
                    ActorTooltipExtra = underCursor.TraitsImplementing <IProvideTooltipInfo>().ToArray();
                    TooltipType       = WorldTooltipType.Actor;
                }

                return;
            }

            var frozen = world.ScreenMap.FrozenActorsAtMouse(world.RenderPlayer, worldPixel)
                         .Where(a => a.TooltipInfo != null && a.IsValid && a.Visible && !a.Hidden)
                         .WithHighestSelectionPriority(worldPixel);

            if (frozen != null)
            {
                FrozenActorTooltip = frozen;

                // HACK: This leaks the tooltip state through the fog
                // This will cause issues for any downstream mods that use IProvideTooltipInfo on enemy actors
                if (frozen.Actor != null)
                {
                    ActorTooltipExtra = frozen.Actor.TraitsImplementing <IProvideTooltipInfo>().ToArray();
                }

                TooltipType = WorldTooltipType.FrozenActor;
                return;
            }

            if (resourceLayer != null)
            {
                var resource = resourceLayer.GetRenderedResource(cell);
                if (resource != null)
                {
                    TooltipType     = WorldTooltipType.Resource;
                    ResourceTooltip = resource;
                }
            }
        }
コード例 #3
0
ファイル: ResourceLayer.cs プロジェクト: DoGyAUT/OpenRA
 protected virtual string ChooseRandomVariant(ResourceType t)
 {
     return(t.Variants.Keys.Random(Game.CosmeticRandom));
 }