コード例 #1
0
        // Token: 0x060004C5 RID: 1221 RVA: 0x00030B6C File Offset: 0x0002EF6C
        protected override Job TryGiveJob(Pawn pawn)
        {
            MapComponent_HiveGrid _HiveGrid = pawn.Map.GetComponent <MapComponent_HiveGrid>();
            HiveLike Tunnel = null;

            Tunnel = JobGiver_EnterHiveTunnel.FindMyTunnel(pawn);
            if (Tunnel == null)
            {
                return(null);
            }
            if (Tunnel.HitPoints == 0)
            {
                return(null);
            }
            bool flag1 = Tunnel.def == XenomorphDefOf.RRY_Xenomorph_Hive;
            bool flag2 = Tunnel.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child;
            bool flag3 = Tunnel.Map.mapPawns.AllPawnsSpawned.Any(x => x.isPotentialHost() && pawn.TryGetComp <Comp_Xenomorph>().IsAcceptablePreyFor(pawn, x, true));
            bool flag4 = _HiveGrid.HiveGuardlist.Contains(pawn) || (Tunnel.hiveMaintainer != null && Tunnel.hiveMaintainer.CurStage != MaintainableStage.Healthy && (_HiveGrid.HiveWorkerlist.Contains(pawn) || _HiveGrid.HiveWorkerlist.NullOrEmpty()));

            if (flag3 || flag4 || Tunnel == null || (Tunnel != null && Tunnel.spawnedPawns.Contains(pawn) && (Tunnel.Position.Roofed(Tunnel.Map) || flag1)) || !pawn.CanReach(Tunnel, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))
            {
                return(null);
            }
            if (Tunnel.hiveDormant && !_HiveGrid.HiveGuardlist.Contains(pawn))
            {
                return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_EnterHiveTunnel, Tunnel));
            }
            return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_EnterHiveTunnel, Tunnel));
        }
コード例 #2
0
        public override void ExposeData()
        {
            MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => MapComponent_HiveGrid.HiveFloatToShort(this.GetDepth(c)), delegate(IntVec3 c, ushort val)
            {
                this.depthGrid[this.map.cellIndices.CellToIndex(c)] = MapComponent_HiveGrid.HiveShortToFloat(val);
            }, "depthGrid");


            if (Scribe.mode == LoadSaveMode.Saving)
            {
                this.HiveGuardlist.RemoveAll((Pawn x) => x.Destroyed);
                this.HiveWorkerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.potentialHosts.RemoveAll((Pawn x) => x.Destroyed);
                this.nonpotentialHosts.RemoveAll((Pawn x) => x.Destroyed);
                this.Queenlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Dronelist.RemoveAll((Pawn x) => x.Destroyed);
                this.Warriorlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Runnerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Runnerlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Thrumbomorphlist.RemoveAll((Pawn x) => x.Destroyed);
                this.Hivelist.RemoveAll((Thing x) => x.Destroyed);
                this.HiveChildlist.RemoveAll((Thing x) => x.Destroyed);
            }
            Scribe_Collections.Look <Pawn>(ref this.HiveGuardlist, "HiveGuardlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.HiveWorkerlist, "HiveWorkerlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.potentialHosts, "potentialHosts", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.nonpotentialHosts, "nonpotentialHosts", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Queenlist, "Queenlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Dronelist, "Dronelist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Warriorlist, "Warriorlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Runnerlist, "Runnerlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Predalienlist, "Predalienlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Pawn>(ref this.Thrumbomorphlist, "Thrumbomorphlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <PotentialXenomorphHiveLocation>(ref this.PotentialHiveLoclist, "PotentialHiveLoclist", LookMode.Deep);
            Scribe_Collections.Look <Thing>(ref this.Hivelist, "Hivelist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Thing>(ref this.HiveChildlist, "HiveChildlist", LookMode.Reference, new object[0]);
            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                this.HiveGuardlist.RemoveAll((Pawn x) => x == null);
                this.HiveWorkerlist.RemoveAll((Pawn x) => x == null);
                this.potentialHosts.RemoveAll((Pawn x) => x == null);
                this.nonpotentialHosts.RemoveAll((Pawn x) => x == null);
                this.Queenlist.RemoveAll((Pawn x) => x == null);
                this.Dronelist.RemoveAll((Pawn x) => x == null);
                this.Warriorlist.RemoveAll((Pawn x) => x == null);
                this.Runnerlist.RemoveAll((Pawn x) => x == null);
                this.Predalienlist.RemoveAll((Pawn x) => x == null);
                this.Thrumbomorphlist.RemoveAll((Pawn x) => x == null);
                this.Hivelist.RemoveAll((Thing x) => x == null);
                this.HiveChildlist.RemoveAll((Thing x) => x == null);
            }
            Scribe_Deep.Look <ThingOwner>(ref this.innerContainer, "innerContainer", new object[]
            {
                this
            });
            base.ExposeData();
        }
コード例 #3
0
        public static IntVec3 CenterCellValue(IntVec3 pos)
        {
            Map map = MapGenerator.mapBeingGenerated;
            MapComponent_HiveGrid hiveGrid = map.HiveGrid();

            hiveGrid.PotentialHiveLoclist.Add(new PotentialXenomorphHiveLocation(pos));
            //    Log.Message(string.Format("Ruin spawned: {0}, adding to Maps Potential Hive locations, Total: {1}", pos, hiveGrid.PotentialHiveLoclist.Count));

            return(pos);
        }
コード例 #4
0
        public static void AddSnowRadialPostfix(IntVec3 center, Map map, float radius, float depth)
        {
            //    Log.Message(string.Format("AddSnowRadial center: {0}, radius: {1}, depth: {2}", center, radius, depth));
            MapComponent_HiveGrid _HiveGrid = map.GetComponent <MapComponent_HiveGrid>();

            if (_HiveGrid != null)
            {
                //        Log.Message(string.Format("AddSnowRadial _HiveGrid != null center: {0}, radius: {1}, depth: {2}", center, radius, depth));
                HiveUtility.AddHiveRadial(center, map, radius, depth);
            }
        }
コード例 #5
0
        private bool CanHaveHive(int ind)
        {
            Building building = this.map.edificeGrid[ind];

            if (building != null && !MapComponent_HiveGrid.CanCoexistWithHive(building.def))
            {
                return(false);
            }
            TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(ind);

            return(terrainDef.passability != Traversability.Impassable);// terrainDef == null || terrainDef.holdSnow;
        }
コード例 #6
0
        public static void AddHiveRadial(IntVec3 center, Map map, float radius, float depth)
        {
            int num = GenRadial.NumCellsInRadius(radius);

            for (int i = 0; i < num; i++)
            {
                IntVec3 intVec = center + GenRadial.RadialPattern[i];
                if (intVec.InBounds(map))
                {
                    float lengthHorizontal = (center - intVec).LengthHorizontal;
                    float num2             = 1f - lengthHorizontal / radius;

                    MapComponent_HiveGrid _HiveGrid = map.GetComponent <MapComponent_HiveGrid>();
                    _HiveGrid.AddDepth(intVec, num2 * depth);
                }
            }
        }
コード例 #7
0
 public override void ExposeData()
 {
     MapExposeUtility.ExposeUshort(this.map, (IntVec3 c) => MapComponent_HiveGrid.HiveFloatToShort(this.GetDepth(c)), delegate(IntVec3 c, ushort val)
     {
         this.depthGrid[this.map.cellIndices.CellToIndex(c)] = MapComponent_HiveGrid.HiveShortToFloat(val);
     }, "depthGrid");
     Scribe_Collections.Look <Pawn>(ref this.HiveGuardlist, "HiveGuardlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.HiveWorkerlist, "HiveWorkerlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.potentialHosts, "potentialHosts", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.nonpotentialHosts, "nonpotentialHosts", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Queenlist, "Queenlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Dronelist, "Dronelist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Warriorlist, "Warriorlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Runnerlist, "Runnerlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Predalienlist, "Predalienlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Pawn>(ref this.Thrumbomorphlist, "Thrumbomorphlist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Thing>(ref this.Hivelist, "Hivelist", LookMode.Reference, new object[0]);
     Scribe_Collections.Look <Thing>(ref this.HiveChildlist, "HiveChildlist", LookMode.Reference, new object[0]);
     base.ExposeData();
 }
コード例 #8
0
        public static bool TryFindGoodHiveLoc(Pawn pawn, out IntVec3 c, Pawn victim = null, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false)
        {
            Map map = pawn.Map;
            c = IntVec3.Invalid;
            if (map == null)
            {
                return false;
            }
            if (!pawn.isXenomorph(out Comp_Xenomorph _Xenomorph))
            {
                return false;
            }
            else
            {
                c = _Xenomorph.HiveLoc;
            }
            MapComponent_HiveGrid hiveGrid = pawn.Map.GetComponent<MapComponent_HiveGrid>();
            bool selected = map != null ? Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

            Predicate<IntVec3> validatora = delegate (IntVec3 y)
            {
                if (y.GetTerrain(map).HasTag("Water"))
                {
                    return false;
                }
                bool roofed = (!allowUnroofed && y.Roofed(map)) || allowUnroofed;
                bool score = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged, allowUnroofed, allowDigging) > 0f;;
                bool filled = y.Filled(map) && !allowDigging;
                bool edifice = y.GetEdifice(map).DestroyedOrNull() || allowDigging;
                bool building = y.GetFirstBuilding(map).DestroyedOrNull() || allowDigging;
                bool thing = y.GetThingList(map).All(x => x.GetType() != typeof(Building_XenomorphCocoon) && x.GetType() != typeof(Building_XenoEgg) && x.GetType() != typeof(HiveLike));
                bool r = score && !filled && edifice && building && thing && roofed;
                return r;
            };
            /*
            if (validatora (_Xenomorph.HiveLoc))
            {

                c = _Xenomorph.HiveLoc;
            }
            else
            if (hiveGrid.Hivelist.NullOrEmpty())
            {
                Log.Warning("no hives present");
                if (!hiveGrid.HiveLoclist.NullOrEmpty())
                {
                //    Log.Message("hivelocs present");
                    c = hiveGrid.HiveLoclist.RandomElement();
                //    return true;
                }
                else
                {
                    Log.Warning("no hivelocs present");
                }
            }
            else
            {
            //    Log.Message("hives present");
                c = hiveGrid.Hivelist.RandomElement().Position;
            //    return true;
            }
            */
            if (c == IntVec3.Invalid || c.x < 1 || c.z < 1 || c == IntVec3.Zero || c.InNoBuildEdgeArea(map) || c.InNoZoneEdgeArea(map) || c.GetTerrain(map).HasTag("Water"))
            {
                if (!InfestationLikeCellFinder.TryFindCell(out c, out IntVec3 lc, map, allowFogged, allowUnroofed, allowDigging))
                {
                //    Log.Message(string.Format("Cant find suitable hive location, defaulting to map edge"));
                    if (!InfestationCellFinder.TryFindCell(out c, map))
                    {
                    //    Log.Message(string.Format("Cant find suitable hive location, defaulting to map edge"));
                        if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
                        {
                        //    Log.Message(string.Format("Cant find spot near map edge"));
                        }
                        else
                        {
                        //    Log.Message(string.Format("RCellFinder: {0}", c));
                        }
                    }
                    else
                    {
                    //    Log.Message(string.Format("InfestationCellFinder: {0}", c));
                    }
                }
                else
                {
                //    Log.Message(string.Format("InfestationLikeCellFinder: {0}", c));
                }
            }
コード例 #9
0
        // Token: 0x060047BA RID: 18362 RVA: 0x0021ADFC File Offset: 0x002191FC
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(this.HiveMaterial);

            if (subMesh.mesh.vertexCount == 0)
            {
                SectionLayerGeometryMaker_Solid.MakeBaseGeometry(this.section, subMesh, AltitudeLayer.Terrain);
            }
            subMesh.Clear(MeshParts.Colors);
            MapComponent_HiveGrid _AvPHiveCreep = base.Map.GetComponent <MapComponent_HiveGrid>();

            //    Log.Message(string.Format(" 6 {0}", _AvPHiveCreep.DepthGridDirect_Unsafe));
            float[]     depthGridDirect_Unsafe = _AvPHiveCreep.DepthGridDirect_Unsafe;
            CellRect    cellRect    = this.section.CellRect;
            int         num         = base.Map.Size.z - 1;
            int         num2        = base.Map.Size.x - 1;
            bool        flag        = false;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    float num3 = depthGridDirect_Unsafe[cellIndices.CellToIndex(i, j)];
                    int   num4 = cellIndices.CellToIndex(i, j - 1);
                    float num5 = (j <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j - 1);
                    float num6 = (j <= 0 || i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j);
                    float num7 = (i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i - 1, j + 1);
                    float num8 = (j >= num || i <= 0) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i, j + 1);
                    float num9 = (j >= num) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j + 1);
                    float num10 = (j >= num || i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j);
                    float num11 = (i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    num4 = cellIndices.CellToIndex(i + 1, j - 1);
                    float num12 = (j <= 0 || i >= num2) ? num3 : depthGridDirect_Unsafe[num4];
                    this.vertDepth[0] = (num5 + num6 + num7 + num3) / 4f;
                    this.vertDepth[1] = (num7 + num3) / 2f;
                    this.vertDepth[2] = (num7 + num8 + num9 + num3) / 4f;
                    this.vertDepth[3] = (num9 + num3) / 2f;
                    this.vertDepth[4] = (num9 + num10 + num11 + num3) / 4f;
                    this.vertDepth[5] = (num11 + num3) / 2f;
                    this.vertDepth[6] = (num11 + num12 + num5 + num3) / 4f;
                    this.vertDepth[7] = (num5 + num3) / 2f;
                    this.vertDepth[8] = num3;
                    for (int k = 0; k < 9; k++)
                    {
                        if (this.vertDepth[k] > 0.01f)
                        {
                            ;
                            flag = true;
                        }
                        subMesh.colors.Add(SectionLayer_Hive.HiveDepthColor(this.vertDepth[k]));
                    }
                }
            }
            if (flag)
            {
                subMesh.disabled = false;
                subMesh.FinalizeMesh(MeshParts.Colors);
            }
            else
            {
                subMesh.disabled = true;
            }
        }