Exemple #1
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;
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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 <IntVec3>(ref this.HiveLoclist, "HiveLoclist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <Thing>(ref this.HiveChildlist, "HiveChildlist", LookMode.Reference, new object[0]);
            Scribe_Collections.Look <IntVec3>(ref this.HiveChildLoclist, "HiveChildLoclist", LookMode.Reference, new object[0]);

            base.ExposeData();
        }
Exemple #4
0
        /*
         * public override void DrawLayer()
         * {
         *  if (!this.Visible)
         *  {
         *      return;
         *  }
         *  int count = this.subMeshes.Count;
         *  for (int i = 0; i < count; i++)
         *  {
         *      LayerSubMesh layerSubMesh = this.subMeshes[i];
         *      Vector3 s = new Vector3(.28f, 1f, .28f);
         *      Matrix4x4 matrix = default(Matrix4x4);
         *      matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
         *      if (layerSubMesh.finalized && !layerSubMesh.disabled)
         *      {
         *          Graphics.DrawMesh(layerSubMesh.mesh, Vector3.zero, Quaternion.identity, layerSubMesh.material, 0);
         *      }
         *  }
         * }
         */
        // Token: 0x060047BA RID: 18362 RVA: 0x0021ADFC File Offset: 0x002191FC
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(AMXBMatBases.Hive);

            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;
            }
        }