Example #1
0
        /// <summary>
        /// Decodes the data for the zone
        /// </summary>
        /// <param name="reader"></param>
        private void DecodeZoneData(DjvuReader reader, TextZone sibling, TextChunk chunkParent)
        {
            _zoneType = (ZoneTypes)reader.ReadByte();
            _x        = reader.ReadUInt16BigEndian() - 0x8000;
            _y        = reader.ReadUInt16BigEndian() - 0x8000;
            _width    = reader.ReadUInt16BigEndian() - 0x8000;
            _height   = reader.ReadUInt16BigEndian() - 0x8000;

            _textOffset = reader.ReadUInt16BigEndian() - 0x8000;
            _textLength = reader.ReadInt24BigEndian();

            ResolveOffsets(_parent, sibling);

            _rectangle = new Rectangle(_x, _y, _width, _height);

            int             childrenZones = reader.ReadInt24BigEndian();
            List <TextZone> children      = new List <TextZone>();

            TextZone childrenSibling = null;

            for (int x = 0; x < childrenZones; x++)
            {
                TextZone newZone = new TextZone(reader, this, childrenSibling, chunkParent);
                childrenSibling = newZone;

                children.Add(newZone);
            }

            _children = children.ToArray();
        }
Example #2
0
    public void ResolvePressureZone(GameObject zone)
    {
        PressureZone pressureScript = zone.GetComponent <PressureZone>();

        int        pressureResult = pressureScript.CheckPressure();
        GameObject replacement    = null;

        switch (pressureResult)
        {
        case 1:
            replacement = pressureScript.SpawnOnOverPressure();
            break;

        case -1:
            replacement = pressureScript.SpawnOnUnderPressure();
            break;

        default:
            break;
        }
        if (pressureResult != 0)
        {
            Vector2 position = zone.transform.position;
            removeActionsQueue.AddLast(CreateDirectAction(ActionTypes.REMOVE, ZoneTypes.GetZoneType(pressureScript), zone));
            if (replacement != null)
            {
                // create on replacement
                GameObject instance = Instantiate(replacement, position, Quaternion.identity) as GameObject;
                createActionsQueue.AddLast(CreateDirectAction(ActionTypes.CREATE, pressureScript.Pressure, instance));
            }
        }
        zeroActionsQueue.AddLast(CreateDirectAction(ActionTypes.PRESSURE_ZERO, pressureScript.Pressure, zone));
    }
Example #3
0
    public ImmutableDataPartition(string id, IXMLNode xmlNode, string error)
    {
        Hashtable hashElements = XMLUtils.GetChildren(xmlNode);

        this.id  = id;
        number   = XMLUtils.GetInt(hashElements["Number"] as IXMLNode, 0, error);
        zone     = (ZoneTypes)Enum.Parse(typeof(ZoneTypes), XMLUtils.GetString(hashElements["Zone"] as IXMLNode, null, error));
        position = StringUtils.ParseVector3(XMLUtils.GetString(hashElements["Position"] as IXMLNode, null, error));

        // get the minigames in the partition(optional)
        if (hashElements.ContainsKey("Minigame"))
        {
            minigameList = new List <MinigameTypes>();
            string   strAmounts   = XMLUtils.GetString(hashElements["Minigame"] as IXMLNode);
            string[] arrayAmounts = strAmounts.Split(","[0]);
            for (int i = 0; i < arrayAmounts.Length; ++i)
            {
                minigameList.Add((MinigameTypes)Enum.Parse(typeof(MinigameTypes), arrayAmounts[i]));
            }
        }

        // get list of wellapad unlocks
        if (hashElements.ContainsKey("DecoTypeAllowed"))
        {
            string strStoreCategories = XMLUtils.GetString(hashElements["DecoTypeAllowed"] as IXMLNode);
            decoCategoriesStore = strStoreCategories.Split(","[0]);
        }
    }
Example #4
0
 private void ExecuteDeleteGoodsTypesCommandDo()
 {
     _deleteZones.Add(ZoneTypes[SelectedGoodsTypesIndex].Zone);
     ZoneTypes.RemoveAt(SelectedGoodsTypesIndex);
     SelectedGoodsTypesIndex = -1;
     ExecuteSaveAllCommand.RaiseCanExecuteChanged();
     Inti();
 }
Example #5
0
    protected void AddPressureZone(GameObject zone)
    {
        boardScript.AddPressureZone(zone);
        PressureZone pressureScript = zone.GetComponent <PressureZone>();

        // if zone is not on the board or on a brick
        if (!boardScript.PositionIsOnBoard(zone.transform.position) || (boardScript.PositionIsBrick(zone.transform.position) && pressureScript.GetType() != typeof(Brick)))
        {
            IssueAction(CreateDirectAction(ActionTypes.REMOVE, ZoneTypes.GetZoneType(pressureScript), zone));
        }
    }
Example #6
0
        public static bool Detect(Vector3 position, out bool changed, out Zone z, out ZoneTypes zt)
        {
            List <Zone> zlist = ListOccupiedZones(position);

            if (zlist.Count == 0)
            {
                // No Zones occupied (We are in the wilderness)
                z  = new Zone();
                zt = new ZoneTypes();

                // Did we change to the wilderness?
                if (CurrentZoneID != -1)
                {
                    CurrentZoneID = -1;
                    zt            = FindZoneType("wilderness");
                    changed       = true;
                }
                else
                {
                    changed = false;
                }
                return(false);
            }
            else
            {
                // We are in a zone
                z  = TopZone(zlist);
                zt = new ZoneTypes();

                if (CurrentZoneID != z.ID)
                {
                    zt            = FindZoneType(z.Type);//.ToLower());
                    CurrentZoneID = z.ID;
                    changed       = true;
                }
                else
                {
                    changed = false;
                }
                return(true);
            }
        }
Example #7
0
        private void calcZoneValuesFtr()
        {
            //Console.WriteLine("made it to the feature calculations");
            bool makeDic = (ZoneClassCount || ZoneTypes.Contains(rasterUtil.zoneType.VARIETY) || ZoneTypes.Contains(rasterUtil.zoneType.ENTROPY) || ZoneTypes.Contains(rasterUtil.zoneType.ASM) || ZoneTypes.Contains(rasterUtil.zoneType.MINORITY) || ZoneTypes.Contains(rasterUtil.zoneType.MODE) || ZoneTypes.Contains(rasterUtil.zoneType.MEDIAN));
            //
            //HashSet<byte> hByt = new HashSet<byte>();
            //
            ISpatialReference sr     = vRs.RasterInfo.SpatialReference;
            IEnvelope         vrsEnv = vRs.RasterInfo.Extent;
            ISpatialFilter    spFilt = new SpatialFilterClass();

            spFilt.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            spFilt.Geometry      = vrsEnv;
            spFilt.GeometryField = ftrCls.ShapeFieldName;
            IFeatureCursor fCur      = ftrCls.Search(spFilt, true);
            int            zoneIndex = fCur.FindField(InZoneField);
            IFeature       ftr       = fCur.NextFeature();

            while (ftr != null)
            {
                IGeometry geo  = ftr.Shape;
                double    z    = System.Convert.ToDouble(ftr.get_Value(zoneIndex));
                IPolygon4 poly = (IPolygon4)geo;
                if (needToProject)
                {
                    poly.Project(sr);
                }
                IGeometryBag        geoBag  = poly.ExteriorRingBag;
                IGeometryCollection geoColl = (IGeometryCollection)geoBag;
                for (int g = 0; g < geoColl.GeometryCount; g++)
                {
                    IGeometry geo2                  = geoColl.Geometry[g];
                    IFunctionRasterDataset rs       = rsUtil.clipRasterFunction(vRs, geo2, esriRasterClippingType.esriRasterClippingOutside);
                    IEnvelope             rsEnv     = rs.RasterInfo.Extent;
                    IRasterFunctionHelper rsFHelper = new RasterFunctionHelperClass();
                    rsFHelper.Bind(rs);
                    //Console.WriteLine((rsEnv.Width / 30).ToString() + ", " + (rsEnv.Height / 30).ToString());
                    IRasterCursor rsCur = ((IRaster2)rsFHelper.Raster).CreateCursorEx(null);
                    do
                    {
                        IPixelBlock pb = rsCur.PixelBlock;
                        for (int p = 0; p < pb.Planes; p++)
                        {
                            zoneValueDic = zoneValueDicArr[p];
                            object[] zoneValue;
                            double   cnt   = 0;
                            double   maxVl = Double.MinValue;
                            double   minVl = Double.MaxValue;
                            double   s     = 0;
                            double   s2    = 0;
                            Dictionary <double, int> uDic = null;
                            if (zoneValueDic.TryGetValue(z, out zoneValue))
                            {
                                cnt   = System.Convert.ToDouble(zoneValue[0]);
                                maxVl = System.Convert.ToDouble(zoneValue[1]);
                                minVl = System.Convert.ToDouble(zoneValue[2]);
                                s     = System.Convert.ToDouble(zoneValue[3]);
                                s2    = System.Convert.ToDouble(zoneValue[4]);
                                uDic  = (Dictionary <double, int>)zoneValue[5];
                            }
                            else
                            {
                                zoneValue    = new object[6];
                                zoneValue[0] = cnt;
                                zoneValue[1] = maxVl;
                                zoneValue[2] = minVl;
                                zoneValue[3] = s;
                                zoneValue[4] = s2;
                                uDic         = null;
                                if (makeDic)
                                {
                                    uDic = new Dictionary <double, int>();
                                }
                                zoneValue[5] = uDic;
                            }
                            for (int r = 0; r < pb.Height; r++)
                            {
                                for (int c = 0; c < pb.Width; c++)
                                {
                                    object vlo = pb.GetVal(p, c, r);
                                    if (vlo == null)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        double vl = System.Convert.ToDouble(vlo);
                                        cnt++;
                                        if (vl > maxVl)
                                        {
                                            maxVl = vl;
                                        }
                                        if (vl < minVl)
                                        {
                                            minVl = vl;
                                        }
                                        s  += vl;
                                        s2 += vl * vl;
                                        if (makeDic)
                                        {
                                            int cntVl = 0;
                                            if (uDic.TryGetValue(vl, out cntVl))
                                            {
                                                uDic[vl] = cntVl += 1;
                                            }
                                            else
                                            {
                                                uDic.Add(vl, 1);
                                            }
                                        }
                                    }
                                }
                            }
                            zoneValue[0]    = cnt;
                            zoneValue[1]    = maxVl;
                            zoneValue[2]    = minVl;
                            zoneValue[3]    = s;
                            zoneValue[4]    = s2;
                            zoneValue[5]    = uDic;
                            zoneValueDic[z] = zoneValue;
                        }
                    } while (rsCur.Next());
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rsCur);
                }
                ftr = fCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fCur);
        }
Example #8
0
 public Location(Vector2 worldCore2D)
 {
     this.worldCore2D = worldCore2D;
     zone             = ZoneTypes.None;
 }
Example #9
0
 public Location(ZoneTypes zone)
 {
     worldCord3D = Vector3.zero;
     worldCord2D = Vector2.zero;
     this.zone = zone;
 }
Example #10
0
 public Location(Vector2 worldCord2D)
 {
     worldCord3D = Vector3.zero;
     this.worldCord2D = worldCord2D;
     zone = ZoneTypes.None;
 }
Example #11
0
 public Location(Vector3 worldCord3D)
 {
     this.worldCord3D = worldCord3D;
     worldCord2D = Vector2.zero;
     zone = ZoneTypes.None;
 }
Example #12
0
        // WorldofValheimZones.ServerSafeZonePath.Value
        public static void LoadZoneData(string ZonePath)
        {
            Debug.Log($"Loading zone file: {ZonePath}");
            // Clean up the old zone data
            ZoneT.Clear();
            Zones.Clear();
            int pos = 0;

            foreach (string text2 in File.ReadAllLines(ZonePath))
            {
                if (!string.IsNullOrWhiteSpace(text2) && text2[0] != '#')
                {
                    string[] array2 = text2.Split(' ');
                    // Check if it is a type
                    if (array2[0].ToLower() == "type:")
                    {
                        Debug.Log($"Loading Type: {array2[1]}");
                        ZoneTypes zt = new ZoneTypes {
                            Name = array2[1]
                        };

                        // Go through each argument to override defaults.

                        if (array2.Length >= 3)
                        {
                            zt.PVP = bool.Parse(array2[2]);
                        }

                        if (array2.Length >= 4)
                        {
                            zt.PVPEnforce = bool.Parse(array2[3]);
                        }

                        if (array2.Length >= 5)
                        {
                            zt.ShowPosition = bool.Parse(array2[4]);
                        }

                        if (array2.Length >= 6)
                        {
                            zt.PositionEnforce = bool.Parse(array2[5]);
                        }

                        ZoneT.Add(zt);
                    }
                    else if (array2[0].ToLower() == "configuration:")
                    {
                        string   texttosend      = text2.Replace(": ", "|");
                        string[] array           = texttosend.Replace(" | ", "|").Split('|');
                        ZoneHandler.ZoneTypes zt = ZoneHandler.FindZoneType(array[1]);
                        if (zt.Name.ToLower() != array[1].ToString().ToLower())
                        {
                            Debug.Log($"ERROR: While applying custom configuration for the Zone Type: {array[1]},");
                            Debug.Log($"Zone Type: {array[1]} Does not exist in the {WorldofValheimZones.ZonePath.Value} file!");
                            return;
                        }
                        else
                        {
                            Debug.Log($"Loading Custom Configuration for the Zone Type: {array[1]} with an Overridable Permission Node of: 'HackShardGaming.WoV-Zones.Override.{array[1]}'");
                            zt.Admins         = array[2];
                            zt.Configurations = array[3];
                        }
                    }
                    else
                    {
                        if (array2.Length != 7)
                        {
                            Debug.Log($"Zone {text2} is not correctly formated!");
                        }
                        else
                        {
                            Debug.Log($"Loading Zone: {array2[0]}");
                            Zone z = new Zone();
                            z.Name     = array2[0];
                            z.Type     = array2[1];
                            z.Priority = int.Parse(array2[2]);
                            z.Shape    = array2[3];
                            Vector2     posi = new Vector3();
                            CultureInfo info = new CultureInfo("en-US");
                            z.Position = new Vector2(Convert.ToSingle(array2[4], info), Convert.ToSingle(array2[5], info));
                            z.Radius   = Convert.ToSingle(array2[6], info);
                            //z.pvp = bool.Parse(array2[7]);
                            z.ID = pos;
                            Zones.Add(z);
                            pos++;
                        }
                    }
                }
            }
#if DEBUG
            _debug();
#endif
        }
Example #13
0
 public Location(Vector3 worldCord3D)
 {
     this.worldCord3D = worldCord3D;
     zone             = ZoneTypes.None;
 }
Example #14
0
 public Location(ZoneTypes zone)
 {
     this.worldCoord3D = Vector3.zero;
     this.worldCoord2D = Vector2.zero;
     this.zone         = ZoneTypes.None;
 }
 public Location(Vector3 worldCord3D)
 {
     this.worldCord3D = worldCord3D;
     worldCord2D      = Vector2.zero;
     zone             = ZoneTypes.None;
 }
Example #16
0
 public PlayerLocation(Vector2 worldCord2D)
 {
     this.worldCord2D = worldCord2D;
     zone             = ZoneTypes.None;
 }
Example #17
0
        /// <summary>
        /// Decodes the data for the zone
        /// </summary>
        /// <param name="reader"></param>
        private void DecodeZoneData(DjvuReader reader, TextZone sibling, TextChunk chunkParent)
        {
            _zoneType = (ZoneTypes)reader.ReadByte();
            _x = reader.ReadUInt16MSB() - 0x8000;
            _y = reader.ReadUInt16MSB() - 0x8000;
            _width = reader.ReadUInt16MSB() - 0x8000;
            _height = reader.ReadUInt16MSB() - 0x8000;

            _textOffset = reader.ReadUInt16MSB() - 0x8000;
            _textLength = reader.ReadInt24MSB();

            ResolveOffsets(_parent, sibling);

            _rectangle = new Rectangle(_x, _y, _width, _height);

            int childrenZones = reader.ReadInt24MSB();
            List<TextZone> children = new List<TextZone>();

            TextZone childrenSibling = null;

            for (int x = 0; x < childrenZones; x++)
            {
                TextZone newZone = new TextZone(reader, this, childrenSibling, chunkParent);
                childrenSibling = newZone;

                children.Add(newZone);
            }

            _children = children.ToArray();
        }
Example #18
0
 public static void _debug(ZoneTypes zt)
 {
     Debug.Log($"  Type: {zt.Name} -> [ {zt.PVP}, {zt.PVPEnforce}, {zt.ShowPosition}, {zt.PositionEnforce}, [{zt.Admins}], [{zt.Configurations}] ]");
 }
Example #19
0
        private Dictionary <double, object[]> zoneValueDic = null;//value = [count,max,min,sum,sum2,dictionary<int,int>]->dictionary is for unique, entropy, and ASM
        private void calcZoneValues()
        {
            bool   makeDic              = (ZoneClassCount || ZoneTypes.Contains(rasterUtil.zoneType.VARIETY) || ZoneTypes.Contains(rasterUtil.zoneType.ENTROPY) || ZoneTypes.Contains(rasterUtil.zoneType.ASM) || ZoneTypes.Contains(rasterUtil.zoneType.MINORITY) || ZoneTypes.Contains(rasterUtil.zoneType.MODE) || ZoneTypes.Contains(rasterUtil.zoneType.MEDIAN));
            IPnt   zMeanCellSize        = zRs.RasterInfo.CellSize;
            IPnt   vMeanCellSize        = vRs.RasterInfo.CellSize;
            int    intersectWidthCells  = System.Convert.ToInt32(intEnv.Width / zMeanCellSize.X);
            int    intersectHeightCells = System.Convert.ToInt32(intEnv.Height / zMeanCellSize.Y);
            IPoint tl        = intEnv.UpperLeft;
            int    bH        = 512;
            int    bW        = 512;
            int    wCellsMax = intersectWidthCells;
            int    hCellsMax = intersectHeightCells;
            IPnt   zPntLoc   = new PntClass();
            IPnt   vPntLoc   = new PntClass();
            IPnt   zPntSize  = new PntClass();
            IRasterFunctionHelper inZoneHelper = new RasterFunctionHelperClass();

            inZoneHelper.Bind(InZoneRaster);
            IRasterFunctionHelper inValueHelper = new RasterFunctionHelperClass();

            inValueHelper.Bind(InValueRaster);
            IRaster2 zr = (IRaster2)inZoneHelper.Raster;
            IRaster2 vr = (IRaster2)inValueHelper.Raster;
            int      zclm, zrw, vclm, vrw;

            zr.MapToPixel(tl.X + (zMeanCellSize.X / 2), tl.Y - (zMeanCellSize.Y / 2), out zclm, out zrw);
            vr.MapToPixel(tl.X + (zMeanCellSize.X / 2), tl.Y - (zMeanCellSize.Y / 2), out vclm, out vrw);
            int ozclm = zclm;
            int ozrw  = zrw;
            int ovclm = vclm;
            int ovrw  = vrw;

            zPntLoc.SetCoords(zclm, zrw);
            vPntLoc.SetCoords(vclm, vrw);
            for (int brw = 0; brw < hCellsMax; brw += bH)
            {
                int rH = hCellsMax - brw;//Height of block
                if (rH > bH)
                {
                    rH = bH;
                }
                for (int bclm = 0; bclm < wCellsMax; bclm += bW)
                {
                    int cW = wCellsMax - bclm;//Width of block
                    if (cW > bW)
                    {
                        cW = bW;
                    }
                    zPntSize.SetCoords(cW, rH);
                    IPixelBlock zPb = ((IRaster)zr).CreatePixelBlock(zPntSize);
                    IPixelBlock vPb = ((IRaster)vr).CreatePixelBlock(zPntSize);
                    inZoneHelper.Read(zPntLoc, null, (IRaster)zr, zPb);
                    inValueHelper.Read(vPntLoc, null, (IRaster)vr, vPb);
                    for (int i = 0; i < vPb.Planes; i++)
                    {
                        zoneValueDic = zoneValueDicArr[i];
                        //double vNoDataVl = System.Convert.ToDouble(((System.Array)vProps.NoDataValue).GetValue(i));
                        //System.Array vPix = (System.Array)vPb.get_SafeArray(i);
                        for (int r = 0; r < rH; r++)
                        {
                            for (int c = 0; c < cW; c++)
                            {
                                object zObj = zPb.GetVal(0, c, r);
                                if (zObj == null)
                                {
                                    continue;
                                }
                                else
                                {
                                    double z    = System.Convert.ToDouble(zObj);
                                    object vObj = vPb.GetVal(i, c, r);

                                    if (vObj == null)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        double   v = System.Convert.ToDouble(vObj);
                                        object[] zoneValue;
                                        if (zoneValueDic.TryGetValue(z, out zoneValue))
                                        {
                                            double cnt = System.Convert.ToDouble(zoneValue[0]);
                                            zoneValue[0] = cnt += 1;
                                            double maxVl = System.Convert.ToDouble(zoneValue[1]);
                                            if (v > maxVl)
                                            {
                                                maxVl        = v;
                                                zoneValue[1] = maxVl;
                                            }
                                            double minVl = System.Convert.ToDouble(zoneValue[2]);
                                            if (v < minVl)
                                            {
                                                minVl        = v;
                                                zoneValue[2] = minVl;
                                            }
                                            double s = System.Convert.ToDouble(zoneValue[3]);
                                            zoneValue[3] = s + v;
                                            double s2 = System.Convert.ToDouble(zoneValue[4]);
                                            zoneValue[4] = s2 + v * v;
                                            if (makeDic)
                                            {
                                                Dictionary <double, int> uDic = (Dictionary <double, int>)zoneValue[5];
                                                int cntVl = 0;
                                                if (uDic.TryGetValue(v, out cntVl))
                                                {
                                                    uDic[v] = cntVl += 1;
                                                }
                                                else
                                                {
                                                    uDic.Add(v, 1);
                                                }
                                                zoneValue[5] = uDic;
                                            }
                                            zoneValueDic[z] = zoneValue;
                                        }
                                        else
                                        {
                                            zoneValue    = new object[6];
                                            zoneValue[0] = 1d;
                                            zoneValue[1] = v;
                                            zoneValue[2] = v;
                                            zoneValue[3] = v;
                                            zoneValue[4] = v * v;
                                            if (makeDic)
                                            {
                                                Dictionary <double, int> uDic = new Dictionary <double, int>();
                                                uDic.Add(v, 1);
                                                zoneValue[5] = uDic;
                                            }
                                            zoneValueDic.Add(z, zoneValue);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    //do this at the end
                    zclm = zclm + cW;
                    vclm = vclm + cW;
                    zPntLoc.SetCoords(zclm, zrw);
                    vPntLoc.SetCoords(vclm, vrw);
                }
                zrw = zrw + rH;
                vrw = vrw + rH;
                //reset PixelBlock columns
                zclm = ozclm;
                vclm = ovclm;
                zPntLoc.SetCoords(zclm, zrw);
                vPntLoc.SetCoords(vclm, vrw);
            }
        }
 public Location(Vector2 worldCord2D)
 {
     worldCord3D      = Vector3.zero;
     this.worldCord2D = worldCord2D;
     zone             = ZoneTypes.None;
 }
Example #21
0
 public Location(ZoneTypes zone)
 {
     worldCord3D = Vector3.zero;
     this.zone   = zone;
 }