Update() private method

private Update ( ) : void
return void
示例#1
0
        private static Dictionary <int, BuildSector> ReadSectors(MapSet map, BinaryReader reader)
        {
            int count = reader.ReadInt32();

            // Create lookup table
            var link = new Dictionary <int, BuildSector>(count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + count, 0);

            for (int i = 0; i < count; i++)
            {
                BuildSector bs = new BuildSector();

                // Read Build properteis
                bs.FirstWallIndex = reader.ReadInt32();
                bs.CeilingHeight  = reader.ReadInt32();
                bs.FloorHeight    = reader.ReadInt32();

                bs.CeilingTileIndex    = reader.ReadInt32();
                bs.CeilingSlope        = reader.ReadInt32();
                bs.CeilingShade        = reader.ReadInt32();
                bs.CeilingPaletteIndex = reader.ReadInt32();
                bs.CeilingOffsetX      = reader.ReadInt32();
                bs.CeilingOffsetY      = reader.ReadInt32();

                bs.FloorTileIndex    = reader.ReadInt32();
                bs.FloorSlope        = reader.ReadInt32();
                bs.FloorShade        = reader.ReadInt32();
                bs.FloorPaletteIndex = reader.ReadInt32();
                bs.FloorOffsetX      = reader.ReadInt32();
                bs.FloorOffsetY      = reader.ReadInt32();

                bs.Visibility = reader.ReadInt32();

                bs.HiTag = reader.ReadInt32();
                bs.LoTag = reader.ReadInt32();
                bs.Extra = reader.ReadInt32();

                // Flags
                bs.CeilingFlags = ReadFlags(reader, General.Map.Config.SectorFlags.Keys);
                bs.FloorFlags   = ReadFlags(reader, General.Map.Config.SectorFlags.Keys);

                // Create new item
                Sector s = map.CreateSector();
                if (s != null)
                {
                    // Set properties
                    s.Update(bs);
                    bs.Sector = s;

                    // Add it to the lookup table
                    link.Add(i, bs);
                }
            }

            // Return lookup table
            return(link);
        }
        // This reads the sectors
        private Dictionary <int, Sector> ReadSectors(MapSet map, UniversalParser textmap)
        {
            Dictionary <int, Sector> link;

            // Get list of entries
            List <UniversalCollection> collections = GetNamedCollections(textmap.Root, "sector");

            // Create lookup table
            link = new Dictionary <int, Sector>(collections.Count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + collections.Count, 0);
            for (int i = 0; i < collections.Count; i++)
            {
                // Read fields
                UniversalCollection c = collections[i];
                string where = "sector " + i;
                int[]  colors  = new int[Sector.NUM_COLORS];
                int    hfloor  = GetCollectionEntry <int>(c, "heightfloor", false, 0, where);
                int    hceil   = GetCollectionEntry <int>(c, "heightceiling", false, 0, where);
                string tfloor  = GetCollectionEntry <string>(c, "texturefloor", true, "-", where);
                string tceil   = GetCollectionEntry <string>(c, "textureceiling", true, "-", where);
                int    bright  = GetCollectionEntry <int>(c, "lightlevel", false, 160, where);
                int    special = GetCollectionEntry <int>(c, "special", false, 0, where);
                int    tag     = GetCollectionEntry <int>(c, "id", false, 0, where);

                // villsa 9/14/11 (builder64)
                colors[0] = GetCollectionEntry <int>(c, "color1", false, 0, where);
                colors[1] = GetCollectionEntry <int>(c, "color2", false, 0, where);
                colors[2] = GetCollectionEntry <int>(c, "color3", false, 0, where);
                colors[3] = GetCollectionEntry <int>(c, "color4", false, 0, where);
                colors[4] = GetCollectionEntry <int>(c, "color5", false, 0, where);

                // villsa 9/13/11 - Flags
                Dictionary <string, bool> stringflags = new Dictionary <string, bool>();
                foreach (KeyValuePair <string, string> flag in General.Map.Config.SectorFlags)
                {
                    stringflags[flag.Key] = GetCollectionEntry <bool>(c, flag.Key, false, false, where);
                }

                // Create new item
                Sector s = map.CreateSector();
                if (s != null)
                {
                    s.Update(stringflags, hfloor, hceil, tfloor, tceil, special, tag, colors);

                    // Custom fields
                    ReadCustomFields(c, s, "sector");

                    // Add it to the lookup table
                    link.Add(i, s);
                }
            }

            // Return lookup table
            return(link);
        }
示例#3
0
 public static int Update(Sector_Info obj)
 {
     if (Validation(obj))
     {
         return(dalSec.Update(obj.ID, obj.Name));
     }
     else
     {
         throw new Exception(dalSec.Error_Message);
     }
 }
示例#4
0
        public void Update_NoExits_EventNotRaised()
        {
            // ARRANGE
            var mapMock = new Mock <ISectorMap>();
            var map     = mapMock.Object;

            var innerActorList   = new List <IActor>();
            var actorManagerMock = new Mock <IActorManager>();

            actorManagerMock.SetupGet(x => x.Items).Returns(innerActorList);
            var actorManager = actorManagerMock.Object;

            var propContainerManagerMock = new Mock <IPropContainerManager>();
            var propContainerManager     = propContainerManagerMock.Object;

            var traderManagerMock = new Mock <ITraderManager>();
            var traderManager     = traderManagerMock.Object;

            var dropResolverMock = new Mock <IDropResolver>();
            var dropResolver     = dropResolverMock.Object;

            var schemeServiceMock = new Mock <ISchemeService>();
            var schemeService     = schemeServiceMock.Object;

            var equipmentDurableServiceMock = new Mock <IEquipmentDurableService>();
            var equipmentDurableService     = equipmentDurableServiceMock.Object;

            var sector = new Sector(map,
                                    actorManager,
                                    propContainerManager,
                                    dropResolver,
                                    schemeService,
                                    equipmentDurableService);

            var actorMock = CreateActorMock();

            actorMock.SetupGet(x => x.Owner).Returns(new Mock <HumanPlayer>().Object);
            innerActorList.Add(actorMock.Object);



            // ACT
            using (var monitor = sector.Monitor())
            {
                sector.Update();



                // ASSERT
                monitor.Should().NotRaise(nameof(sector.HumanGroupExit));
            }
        }
示例#5
0
        private static void CreateSectors(MapSet map, List <BuildSector> buildsectors)
        {
            // Create sectors
            map.SetCapacity(0, 0, 0, map.Sectors.Count + buildsectors.Count, 0);
            foreach (var bs in buildsectors)
            {
                // Create new item
                Sector s = map.CreateSector();
                s.Update(bs);

                // Add it to the lookup table
                bs.Sector = s;
            }
        }
示例#6
0
        public void Update_PlayerActorWithSurvival_SurvivalStatsDecremented()
        {
            // ARRANGE
            var mapMock = new Mock <ISectorMap>();
            var map     = mapMock.Object;

            var innerActorList   = new List <IActor>();
            var actorManagerMock = new Mock <IActorManager>();

            actorManagerMock.SetupGet(x => x.Items).Returns(innerActorList);
            var actorManager = actorManagerMock.Object;

            var propContainerManagerMock = new Mock <IPropContainerManager>();
            var propContainerManager     = propContainerManagerMock.Object;

            var traderManagerMock = new Mock <ITraderManager>();
            var traderManager     = traderManagerMock.Object;

            var dropResolverMock = new Mock <IDropResolver>();
            var dropResolver     = dropResolverMock.Object;

            var schemeServiceMock = new Mock <ISchemeService>();
            var schemeService     = schemeServiceMock.Object;

            var equipmentDurableServiceMock = new Mock <IEquipmentDurableService>();
            var equipmentDurableService     = equipmentDurableServiceMock.Object;

            var sector = new Sector(map,
                                    actorManager,
                                    propContainerManager,
                                    dropResolver,
                                    schemeService,
                                    equipmentDurableService);

            var actorMock = CreateActorMock();

            innerActorList.Add(actorMock.Object);



            // ACT
            sector.Update();



            // ASSERT
            _survivalDataMock.Verify(x => x.Update(), Times.Once);
        }
示例#7
0
        // This reads the SECTORS from WAD file
        // Returns a lookup table with indices
        private Dictionary <int, Sector> ReadSectors(MapSet map, int firstindex)
        {
            // Get the lump from wad file
            Lump lump = wad.FindLump("SECTORS", firstindex);

            if (lump == null)
            {
                throw new Exception("Could not find required lump SECTORS!");
            }

            // Prepare to read the items
            MemoryStream mem    = new MemoryStream(lump.Stream.ReadAllBytes());
            int          num    = (int)lump.Stream.Length / 26;
            BinaryReader reader = new BinaryReader(mem);

            // Create lookup table
            Dictionary <int, Sector> link = new Dictionary <int, Sector>(num);

            // Read items from the lump
            map.SetCapacity(0, 0, 0, map.Sectors.Count + num, 0);
            for (int i = 0; i < num; i++)
            {
                // Read properties from stream
                int    hfloor  = reader.ReadInt16();
                int    hceil   = reader.ReadInt16();
                string tfloor  = Lump.MakeNormalName(reader.ReadBytes(8), WAD.ENCODING);
                string tceil   = Lump.MakeNormalName(reader.ReadBytes(8), WAD.ENCODING);
                int    bright  = reader.ReadInt16();
                int    special = reader.ReadUInt16();
                int    tag     = reader.ReadUInt16();

                // Create new item
                Sector s = map.CreateSector();
                s.Update(hfloor, hceil, tfloor, tceil, special, tag, bright);

                // Add it to the lookup table
                link.Add(i, s);
            }

            // Done
            mem.Dispose();

            // Return lookup table
            return(link);
        }
示例#8
0
        // This reads the sectors
        private Dictionary <int, Sector> ReadSectors(MapSet map, UniversalParser textmap)
        {
            Dictionary <int, Sector> link;

            // Get list of entries
            List <UniversalCollection> collections = GetNamedCollections(textmap.Root, "sector");

            // Create lookup table
            link = new Dictionary <int, Sector>(collections.Count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + collections.Count, 0);
            for (int i = 0; i < collections.Count; i++)
            {
                // Read fields
                UniversalCollection c = collections[i];
                string where = "sector " + i;
                int    hfloor  = GetCollectionEntry <int>(c, "heightfloor", false, 0, where);
                int    hceil   = GetCollectionEntry <int>(c, "heightceiling", false, 0, where);
                string tfloor  = GetCollectionEntry <string>(c, "texturefloor", true, "-", where);
                string tceil   = GetCollectionEntry <string>(c, "textureceiling", true, "-", where);
                int    bright  = GetCollectionEntry <int>(c, "lightlevel", false, 160, where);
                int    special = GetCollectionEntry <int>(c, "special", false, 0, where);
                int    tag     = GetCollectionEntry <int>(c, "id", false, 0, where);

                // Create new item
                Sector s = map.CreateSector();
                if (s != null)
                {
                    s.Update(hfloor, hceil, tfloor, tceil, special, tag, bright);

                    // Custom fields
                    ReadCustomFields(c, s, "sector");

                    // Add it to the lookup table
                    link.Add(i, s);
                }
            }

            // Return lookup table
            return(link);
        }
示例#9
0
        public async Task <ICommandResult> Handle(EditSectorCommand command)
        {
            Sector Sector = await _SectorRepository.GetById(command.Id);

            if (Sector == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            NameOrDescription name = new NameOrDescription(command.Name);

            Sector.Update(name, command.UpdatedByUserId);

            AddNotifications(name.Notifications);
            AddNotifications(Sector.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _SectorRepository.Update(Sector);

            return(new CommandResult(
                       true,
                       Messages.UPDATED_WITH_SUCCESS,
                       new SectorCommandResult
            {
                Id = Sector.Id,
                Name = Sector.Name.Name,
                CreatedDate = Sector.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = Sector.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = Sector.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = Sector.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = Sector.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = Sector.Audit.CompanyAndBranchOffice.BranchOfficeId
            }));
        }
示例#10
0
        private static Dictionary <int, Sector> ReadSectors(MapSet map, BinaryReader reader)
        {
            int count = reader.ReadInt32();

            // Create lookup table
            Dictionary <int, Sector> link = new Dictionary <int, Sector>(count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + count, 0);

            for (int i = 0; i < count; i++)
            {
                int effect = reader.ReadInt32();
                int hfloor = reader.ReadInt32();
                int hceil  = reader.ReadInt32();
                int bright = reader.ReadInt32();

                //mxd. Tags
                int        numtags = reader.ReadInt32();          //mxd
                List <int> tags    = new List <int>(numtags);     //mxd
                for (int a = 0; a < numtags; a++)
                {
                    tags.Add(reader.ReadInt32());                                              //mxd
                }
                string tfloor = ReadString(reader);
                string tceil  = ReadString(reader);

                //mxd. Slopes
                float    foffset = reader.ReadSingle();
                Vector3D fslope  = new Vector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                float    coffset = reader.ReadSingle();
                Vector3D cslope  = new Vector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                //flags
                Dictionary <string, bool> stringflags = new Dictionary <string, bool>(StringComparer.Ordinal);
                int numFlags = reader.ReadInt32();
                for (int f = 0; f < numFlags; f++)
                {
                    stringflags.Add(ReadString(reader), reader.ReadBoolean());
                }

                //add missing flags
                foreach (KeyValuePair <string, string> flag in General.Map.Config.SectorFlags)
                {
                    if (stringflags.ContainsKey(flag.Key))
                    {
                        continue;
                    }
                    stringflags.Add(flag.Key, false);
                }

                // Create new item
                Dictionary <string, UniValue> fields = ReadCustomFields(reader);
                Sector s = map.CreateSector();
                if (s != null)
                {
                    s.Update(hfloor, hceil, tfloor, tceil, effect, stringflags, tags, bright, foffset, fslope, coffset, cslope);

                    // Add custom fields
                    s.Fields.BeforeFieldsChange();
                    foreach (KeyValuePair <string, UniValue> group in fields)
                    {
                        s.Fields.Add(group.Key, group.Value);
                    }

                    // Add it to the lookup table
                    link.Add(i, s);
                }
            }

            // Return lookup table
            return(link);
        }
示例#11
0
        // This reads the sectors
        private Dictionary <int, Sector> ReadSectors(MapSet map, UniversalParser textmap)
        {
            // Get list of entries
            List <UniversalCollection> collections = GetNamedCollections(textmap.Root, "sector");

            // Create lookup table
            Dictionary <int, Sector> link = new Dictionary <int, Sector>(collections.Count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + collections.Count, 0);
            char[] splitter = new[] { ' ' };             //mxd
            for (int i = 0; i < collections.Count; i++)
            {
                // Read fields
                UniversalCollection c = collections[i];
                string where = "sector " + i;
                int    hfloor  = GetCollectionEntry(c, "heightfloor", false, 0, where);
                int    hceil   = GetCollectionEntry(c, "heightceiling", false, 0, where);
                string tfloor  = GetCollectionEntry(c, "texturefloor", true, "-", where);
                string tceil   = GetCollectionEntry(c, "textureceiling", true, "-", where);
                int    bright  = GetCollectionEntry(c, "lightlevel", false, 160, where);
                int    special = GetCollectionEntry(c, "special", false, 0, where);
                int    tag     = GetCollectionEntry(c, "id", false, 0, where);

                //mxd. MoreIDs
                List <int> tags = new List <int> {
                    tag
                };
                string moreids = GetCollectionEntry(c, "moreids", false, string.Empty, where);
                if (!string.IsNullOrEmpty(moreids))
                {
                    string[] moreidscol = moreids.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string sid in moreidscol)
                    {
                        int id;
                        if (int.TryParse(sid.Trim(), out id) && id != 0 && !tags.Contains(id))
                        {
                            tags.Add(id);
                        }
                    }
                }
                if (tag == 0 && tags.Count > 1)
                {
                    tags.RemoveAt(0);
                }

                //mxd. Read slopes
                float fslopex = GetCollectionEntry(c, "floorplane_a", false, 0.0f, where);
                float fslopey = GetCollectionEntry(c, "floorplane_b", false, 0.0f, where);
                float fslopez = GetCollectionEntry(c, "floorplane_c", false, 0.0f, where);
                float foffset = GetCollectionEntry(c, "floorplane_d", false, float.NaN, where);

                float cslopex = GetCollectionEntry(c, "ceilingplane_a", false, 0.0f, where);
                float cslopey = GetCollectionEntry(c, "ceilingplane_b", false, 0.0f, where);
                float cslopez = GetCollectionEntry(c, "ceilingplane_c", false, 0.0f, where);
                float coffset = GetCollectionEntry(c, "ceilingplane_d", false, float.NaN, where);

                //mxd. Read flags
                Dictionary <string, bool> stringflags = new Dictionary <string, bool>(StringComparer.Ordinal);
                foreach (KeyValuePair <string, string> flag in General.Map.Config.SectorFlags)
                {
                    stringflags[flag.Key] = GetCollectionEntry(c, flag.Key, false, false, where);
                }
                foreach (KeyValuePair <string, string> flag in General.Map.Config.CeilingPortalFlags)
                {
                    stringflags[flag.Key] = GetCollectionEntry(c, flag.Key, false, false, where);
                }
                foreach (KeyValuePair <string, string> flag in General.Map.Config.FloorPortalFlags)
                {
                    stringflags[flag.Key] = GetCollectionEntry(c, flag.Key, false, false, where);
                }

                // Create new item
                Sector s = map.CreateSector();
                if (s != null)
                {
                    s.Update(hfloor, hceil, tfloor, tceil, special, stringflags, tags, bright, foffset, new Vector3D(fslopex, fslopey, fslopez).GetNormal(), coffset, new Vector3D(cslopex, cslopey, cslopez).GetNormal());

                    // Custom fields
                    ReadCustomFields(c, s, "sector");

                    // Add it to the lookup table
                    link.Add(i, s);
                }
            }

            // Return lookup table
            return(link);
        }