Exemplo n.º 1
0
 public override void CompDraw()
 {
     if (forbidden)
     {
         OverlayDrawer.DrawOverlay(parent, OverlayTypes.Forbidden);
     }
 }
 public override void Draw()
 {
     base.Draw();
     if (isLocked)
     {
         OverlayDrawer.DrawOverlay(this, OverlayTypes.ForbiddenBig);
     }
 }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            var ownEffectiveRadius = RemoteTechUtility.TryGetExplosiveRadius(def);
            var map = Find.CurrentMap;

            if (map == null || ownEffectiveRadius <= 0)
            {
                return;
            }
            if (Find.Selector.NumSelected <= 1)
            {
                // highlight nearby thick mountain roof cells
                var fogGrid  = map.fogGrid;
                var roofGrid = map.roofGrid;
                GatherCellsInRadius(center, map, ownEffectiveRadius + AdditionalRoofDisplayRadius,
                                    cell => fogGrid.IsFogged(cell) || (roofGrid.RoofAt(cell)?.isThickRoof ?? false)
                                    );
                OverlayDrawer.DrawFieldEdges(cellBuffer, ThickRoofHighlightColor);

                void DrawMatchingEdgesAroundThing(Thing t)
                {
                    GatherCellsInRadius(t.Position, map, ownEffectiveRadius);
                    OverlayDrawer.DrawSolidField(cellBuffer, OtherEffectiveAreasColor);
                }

                // highlight effective areas of already built charges of same type
                var colonistBuildings = map.listerBuildings.allBuildingsColonist;
                for (var i = 0; i < colonistBuildings.Count; i++)
                {
                    if (colonistBuildings[i]?.def == def)
                    {
                        DrawMatchingEdgesAroundThing(colonistBuildings[i]);
                    }
                }
                // highlight effective areas of blueprints for charges of same type
                var blueprints = map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.Blueprint));
                for (var i = 0; i < blueprints.Count; i++)
                {
                    if (blueprints[i]?.def?.entityDefToBuild == def)
                    {
                        DrawMatchingEdgesAroundThing(blueprints[i]);
                    }
                }
            }
            // highlight own effective radius with color-coded effectiveness
            var effectiveRadiusColor = RemoteTechUtility.IsEffectiveRoofBreakerPlacement(ownEffectiveRadius, center, map, true)
                                ? EffectivePlacementColor
                                : IneffectivePlacementColor;

            GatherCellsInRadius(center, map, ownEffectiveRadius);
            OverlayDrawer.DrawFieldEdges(cellBuffer, effectiveRadiusColor);
        }
Exemplo n.º 4
0
        public static bool DisposeHandle(OverlayDrawer __instance, Thing thing)
        {
            ThingOverlaysHandle thingOverlaysHandle;

            lock (__instance) //added
            {
                if (__instance.overlayHandles.TryGetValue(thing, out thingOverlaysHandle))
                {
                    thingOverlaysHandle.Dispose();
                    __instance.overlayHandles.Remove(thing);
                }
            }
            return(false);
        }
Exemplo n.º 5
0
    public override void Draw()
    {
        if (health < def.maxHealth && def.useStandardHealth)
        {
            OverlayDrawer.DrawOverlay(this, OverlayTypes.Damaged);
        }

        //If we've already added to the map mesh don't bother with drawing our base mesh
        if (def.drawerType == DrawerType.RealtimeOnly)
        {
            base.Draw();
        }

        Comps_Draw();
    }
Exemplo n.º 6
0
        public static bool GetOverlaysHandle(OverlayDrawer __instance, ref ThingOverlaysHandle __result, Thing thing)
        {
            if (!thing.Spawned)
            {
                __result = null;
                return(false);
            }
            ThingOverlaysHandle thingOverlaysHandle;

            lock (__instance) //added
            {
                if (!__instance.overlayHandles.TryGetValue(thing, out thingOverlaysHandle))
                {
                    thingOverlaysHandle = new ThingOverlaysHandle(__instance, thing);
                    __instance.overlayHandles.Add(thing, thingOverlaysHandle);
                }
            }
            __result = thingOverlaysHandle;
            return(false);
        }
        static bool Prefix(OverlayDrawer __instance, Thing t)
        {
            if (t is ICustomOverlayDrawer d)
            {
                string texPath = d.OverlayTexturePath;
                if (texPath == null)
                {
                    return(false);
                }

                if (method == null)
                {
                    method = AccessTools.DeclaredMethod(typeof(OverlayDrawer), "RenderPulsingOverlay", new Type[]
                    {
                        typeof(Thing), typeof(Material), typeof(int), typeof(bool)
                    });
                    args[2] = 5;
                    args[3] = true;
                }

                if (!matCache.TryGetValue(texPath, out var mat))
                {
                    mat = MaterialPool.MatFrom(texPath, ShaderDatabase.MetaOverlay);
                    matCache.Add(texPath, mat);
                }
                if (mat == null)
                {
                    Log.ErrorOnce($"Failed to load meta overlay material from texture path '{texPath}' for building '{t.LabelCap}'.", texPath.GetHashCode());
                    return(false);
                }

                args[0] = t;
                args[1] = mat;
                method.Invoke(__instance, args);
                args[0] = null;

                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
 public void ConstructComponents()
 {
     this.spawnedThings      = new ThingOwner <Thing>(this);
     this.cellIndices        = new CellIndices(this);
     this.listerThings       = new ListerThings(ListerThingsUse.Global);
     this.listerBuildings    = new ListerBuildings();
     this.mapPawns           = new MapPawns(this);
     this.dynamicDrawManager = new DynamicDrawManager(this);
     this.mapDrawer          = new MapDrawer(this);
     this.tooltipGiverList   = new TooltipGiverList();
     this.pawnDestinationReservationManager = new PawnDestinationReservationManager();
     this.reservationManager = new ReservationManager(this);
     this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager();
     this.designationManager             = new DesignationManager(this);
     this.lordManager                    = new LordManager(this);
     this.debugDrawer                    = new DebugCellDrawer();
     this.passingShipManager             = new PassingShipManager(this);
     this.haulDestinationManager         = new HaulDestinationManager(this);
     this.gameConditionManager           = new GameConditionManager(this);
     this.weatherManager                 = new WeatherManager(this);
     this.zoneManager                    = new ZoneManager(this);
     this.resourceCounter                = new ResourceCounter(this);
     this.mapTemperature                 = new MapTemperature(this);
     this.temperatureCache               = new TemperatureCache(this);
     this.areaManager                    = new AreaManager(this);
     this.attackTargetsCache             = new AttackTargetsCache(this);
     this.attackTargetReservationManager = new AttackTargetReservationManager(this);
     this.lordsStarter                   = new VoluntarilyJoinableLordsStarter(this);
     this.thingGrid                  = new ThingGrid(this);
     this.coverGrid                  = new CoverGrid(this);
     this.edificeGrid                = new EdificeGrid(this);
     this.blueprintGrid              = new BlueprintGrid(this);
     this.fogGrid                    = new FogGrid(this);
     this.glowGrid                   = new GlowGrid(this);
     this.regionGrid                 = new RegionGrid(this);
     this.terrainGrid                = new TerrainGrid(this);
     this.pathGrid                   = new PathGrid(this);
     this.roofGrid                   = new RoofGrid(this);
     this.fertilityGrid              = new FertilityGrid(this);
     this.snowGrid                   = new SnowGrid(this);
     this.deepResourceGrid           = new DeepResourceGrid(this);
     this.exitMapGrid                = new ExitMapGrid(this);
     this.linkGrid                   = new LinkGrid(this);
     this.glowFlooder                = new GlowFlooder(this);
     this.powerNetManager            = new PowerNetManager(this);
     this.powerNetGrid               = new PowerNetGrid(this);
     this.regionMaker                = new RegionMaker(this);
     this.pathFinder                 = new PathFinder(this);
     this.pawnPathPool               = new PawnPathPool(this);
     this.regionAndRoomUpdater       = new RegionAndRoomUpdater(this);
     this.regionLinkDatabase         = new RegionLinkDatabase();
     this.moteCounter                = new MoteCounter();
     this.gatherSpotLister           = new GatherSpotLister();
     this.windManager                = new WindManager(this);
     this.listerBuildingsRepairable  = new ListerBuildingsRepairable();
     this.listerHaulables            = new ListerHaulables(this);
     this.listerMergeables           = new ListerMergeables(this);
     this.listerFilthInHomeArea      = new ListerFilthInHomeArea(this);
     this.reachability               = new Reachability(this);
     this.itemAvailability           = new ItemAvailability(this);
     this.autoBuildRoofAreaSetter    = new AutoBuildRoofAreaSetter(this);
     this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this);
     this.roofCollapseBuffer         = new RoofCollapseBuffer();
     this.wildAnimalSpawner          = new WildAnimalSpawner(this);
     this.wildPlantSpawner           = new WildPlantSpawner(this);
     this.steadyEnvironmentEffects   = new SteadyEnvironmentEffects(this);
     this.skyManager                 = new SkyManager(this);
     this.overlayDrawer              = new OverlayDrawer();
     this.floodFiller                = new FloodFiller(this);
     this.weatherDecider             = new WeatherDecider(this);
     this.fireWatcher                = new FireWatcher(this);
     this.dangerWatcher              = new DangerWatcher(this);
     this.damageWatcher              = new DamageWatcher();
     this.strengthWatcher            = new StrengthWatcher(this);
     this.wealthWatcher              = new WealthWatcher(this);
     this.regionDirtyer              = new RegionDirtyer(this);
     this.cellsInRandomOrder         = new MapCellsInRandomOrder(this);
     this.rememberedCameraPos        = new RememberedCameraPos(this);
     this.mineStrikeManager          = new MineStrikeManager();
     this.storyState                 = new StoryState(this);
     this.retainedCaravanData        = new RetainedCaravanData(this);
     this.components.Clear();
     this.FillComponents();
 }
 public static void RenderNeedsGasOverlay(OverlayDrawer drawer, Thing thing)
 {
     RenderPulsingOverlay_MI.Invoke(drawer, new object[] { thing, Resources.NeedsGas, 2, true });
 }