public int GenerateSectorNumStars(SectorType sectorType) { int _numSectorStars; if (sectorType == SectorType.Core) { _numSectorStars = galaxy.randomNumber.Next(galaxy.SectorTypeTable[0].SectorStarNumMin, galaxy.SectorTypeTable[0].SectorStarNumMax); return(_numSectorStars); } else if (sectorType == SectorType.Middle) { _numSectorStars = galaxy.randomNumber.Next(galaxy.SectorTypeTable[1].SectorStarNumMin, galaxy.SectorTypeTable[1].SectorStarNumMax); return(_numSectorStars); } else if (sectorType == SectorType.Edge) { _numSectorStars = galaxy.randomNumber.Next(galaxy.SectorTypeTable[2].SectorStarNumMin, galaxy.SectorTypeTable[2].SectorStarNumMax); return(_numSectorStars); } else if (sectorType == SectorType.Far) { _numSectorStars = galaxy.randomNumber.Next(galaxy.SectorTypeTable[3].SectorStarNumMin, galaxy.SectorTypeTable[3].SectorStarNumMax); return(_numSectorStars); } else { return(0); } }
public void GenerateSector(SectorType sectorType) { if (sectorType == SectorType.Core) { numSectorStars = Random.Range(500, 800 + 1); } else if (sectorType == SectorType.Middle) { numSectorStars = Random.Range(200, 500 + 1); } else if (sectorType == SectorType.Edge) { numSectorStars = Random.Range(50, 200 + 1); } else if (sectorType == SectorType.Far) { numSectorStars = Random.Range(10, 50 + 1); } for (int i = 0; i < numSectorStars; i++) { Vector3 StarPosition = new Vector3(Random.Range(sectorPosition.x, Galaxy.SectorSize + sectorPosition.x + 1), Random.Range(sectorPosition.y, Galaxy.SectorSize + sectorPosition.y + 1), Random.Range(sectorPosition.z, Galaxy.SectorSize + sectorPosition.z + 1)); float fStarSystemSize = Random.Range(1, 10); Vector3 StarSystemSize = new Vector3(fStarSystemSize, fStarSystemSize, fStarSystemSize); GenerateStarSystem(StarPosition, StarSystemSize, sectorName, sectorGameObject); } }
public SectorHeader(byte[] data, int filestreamid, long filestreamoffset, SectorType type) : this() { _filestreamid = filestreamid; _filestreamoffset = filestreamoffset; _type = type; ReadBytes(data); }
public Node AddNode(SectorType type, string name, int x, int y) { Node n = new Node(type, name, x, y); Nodes.Add(n); return(n); }
/// <summary> /// Allocates the specified number and type of sectors. /// </summary> /// <param name="sectorCount">The sector count.</param> /// <param name="type">The sector type.</param> /// <returns>Returns the first sector number.</returns> public int Allocate(int sectorCount, SectorType type) { if (sectorCount == 0) { return(-2); } int num = this._innerList.Count; if (type == SectorType.Data) { for (int i = 0; i < (sectorCount - 1); i++) { this._innerList.Add(this._innerList.Count + 1); } this._innerList.Add(-2); return(num); } if (type == SectorType.FAT) { for (int j = 0; j < sectorCount; j++) { this._innerList.Add(-3); } return(num); } if (type == SectorType.DIFAT) { for (int k = 0; k < sectorCount; k++) { this._innerList.Add(-4); } } return(num); }
protected SECTOR(byte[] raw) { mRaw = raw; mBytesPerSector = raw.Length; mType = (SectorType)raw[Constants.TYPE_AT]; mNextSectorAt = BitConverter.ToInt32(raw, Constants.NEXT_SECTOR_AT); }
public void Upgrade(int level, SectorType type) { currLevel = level; currType = type; RecalcVisuals(); }
protected SECTOR(byte[] raw) { this.bytesPerSector = raw.Length; // NOTE: assuming the raw bytes are correct length!!!! this.raw = raw; type = (SectorType)raw[TYPE_AT]; nextSectorAt = BitConverter.ToInt32(raw, NEXT_SECTOR_AT); }
public static void PushSectorType(this HexRegion region, SectorType type) { var possibleSectors = region.ChildSectors.Where(x => x.Type == SectorType.Unassigned).ToList(); var index = Random.Range(0, possibleSectors.Count); possibleSectors[index].Type = type; }
public SectorList(List <int> idIndexList, Stream sourceStream, int sectorSize, SectorType type) { IdIndexList = idIndexList; SourceStream = sourceStream; SectorSize = sectorSize; Type = type; }
private IList <PatchedByteArray> GetPatches(byte[] bytes) { List <PatchedByteArray> result = new List <PatchedByteArray>(); foreach (var kvp in Layout.Sectors) { SectorType type = kvp.Key; foreach (var kvp2 in kvp.Value) { switch (type) { case SectorType.BootBin: result.Add(new PatchedByteArray(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, kvp2.Value, bytes)); result.Add(new PatchedByteArray(PspIso.Sectors.PSP_GAME_SYSDIR_EBOOT_BIN, kvp2.Value, bytes)); break; case SectorType.FFTPack: result.Add(new PatchedByteArray((FFTPack.Files)kvp2.Key, kvp2.Value, bytes)); break; case SectorType.Sector: result.Add(new PatchedByteArray((PsxIso.Sectors)kvp2.Key, kvp2.Value, bytes)); break; } } } return(result); }
public SectorList(Stream sourceStream, int sectorSize, SectorType type) { SourceStream = sourceStream; SectorSize = sectorSize; Type = type; IdIndexList = new List <int>(); }
protected NODE(int bytesPerSector, SectorType type, int nextSectorAt, string name) : base(bytesPerSector, type, nextSectorAt) { if (name.Length > Constants.MAX_FILE_NAME) { throw new Exception($"Name {name} too long!"); } mName = name; Encoding.ASCII.GetBytes(name).CopyTo(mRaw, Constants.NAME_AT); }
protected SECTOR(int bytesPerSector, SectorType type, int nextSectorAt) { mRaw = new byte[bytesPerSector]; mBytesPerSector = bytesPerSector; mType = type; mRaw[Constants.TYPE_AT] = (byte)type; NextSectorAt = nextSectorAt; }
/// <summary> /// Returns the latest SIC Codes before specified date/time /// </summary> /// <param name="maxDate">Ignore SIC codes changes after this date/time - if empty returns the latest SIC codes</param> /// <returns>The employer SIC codes</returns> public IEnumerable <OrganisationSicCode> GetSicCodes(DateTime?maxDate = null) { if (maxDate == null || maxDate.Value == DateTime.MinValue) { maxDate = SectorType.GetAccountingStartDate().AddYears(1); } return(OrganisationSicCodes.Where(s => s.Created < maxDate.Value && (s.Retired == null || s.Retired.Value > maxDate.Value))); }
//Returns the latest return for the specified accounting year or the latest ever if no accounting year is public Return GetReturn(int year = 0) { DateTime accountingStartDate = SectorType.GetAccountingStartDate(year); return(Returns .Where(r => r.Status == ReturnStatuses.Submitted && r.AccountingDate == accountingStartDate) .OrderByDescending(r => r.StatusDate) .FirstOrDefault()); }
/// <summary> /// Returns the latest organisation name before specified date/time /// </summary> /// <param name="maxDate">Ignore name changes after this date/time - if empty returns the latest name</param> /// <returns>The name of the organisation</returns> public OrganisationName GetName(DateTime?maxDate = null) { if (maxDate == null || maxDate.Value == DateTime.MinValue) { maxDate = SectorType.GetAccountingStartDate().AddYears(1); } return(OrganisationNames.Where(n => n.Created < maxDate.Value).OrderByDescending(n => n.Created).FirstOrDefault()); }
public Sector(SectorType SectorType, Vector3 SectorPosition, string SectorName, int NumSectorStars) { sectorName = SectorName; sectorType = SectorType; sectorPosition = SectorPosition; numSectorStars = NumSectorStars; sectorGameObject = new GameObject(sectorName); GenerateSector(SectorType); }
protected SECTOR(int bytesPerSector, SectorType type, int nextSectorAt) { this.bytesPerSector = bytesPerSector; this.type = type; // construct raw bytes with all zeroes raw = new byte[bytesPerSector]; raw[TYPE_AT] = (byte)type; NextSectorAt = nextSectorAt; }
public string GetSicSource(DateTime?maxDate = null) { if (maxDate == null || maxDate.Value == DateTime.MinValue) { maxDate = SectorType.GetAccountingStartDate().AddYears(1); } return(OrganisationSicCodes .FirstOrDefault(s => s.Created < maxDate.Value && (s.Retired == null || s.Retired.Value > maxDate.Value)) ?.Source); }
static internal string GetSectorType(SectorType sectorType) { switch (sectorType) { case SectorType.Default: return("Обычный"); case SectorType.Monolith: return("С монолитом"); default: return(default); } }
public Sector(long end, string name, SectorType type, SectorEnumerator se) { Name = name; Type = type; Values = new OrderedDictionary(); enumerator = se; Length = 0; Offset = end + 4; isNew = true; se.SectorMoved += UpdateSectorWhenMovement; se.SectorChanged += UpdateSectorWhenChange; }
public void Init(int id) { Id = id; currLevel = initialLevel; currType = initialType; foreach (var aura in auras) { aura.DeactivateForce(); } RecalcVisuals(); }
public IEnumerable <Return> GetRecentReports(int recentCount) { foreach (int year in GetRecentReportingYears(recentCount)) { var defaultReturn = new Return { Organisation = this, AccountingDate = SectorType.GetAccountingStartDate(year), Modified = VirtualDateTime.Now }; defaultReturn.IsLateSubmission = defaultReturn.CalculateIsLateSubmission(); yield return(GetReturn(year) ?? defaultReturn); } }
public IEnumerable <int> GetRecentReportingYears(int recentCount) { int endYear = SectorType.GetAccountingStartDate().Year; int startYear = endYear - (recentCount - 1); if (startYear < Global.FirstReportingYear) { startYear = Global.FirstReportingYear; } for (int year = endYear; year >= startYear; year--) { yield return(year); } }
public Guid GetITCSectorIDByName(string name, SectorType secType) { var ITC_Nom = new TSMSector(); //string name = name.Trim(); using (var context = new TSMContext()) { ITC_Nom = context.TSMSector.Where(u => u.Name == name && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.ITC && u.Type == secType).FirstOrDefault(); } Guid itcID = Guid.Empty; if (ITC_Nom != null) { itcID = ITC_Nom.ID; } return(itcID); }
//GET ID by Code public Guid GetINTSectorID(string sitcCode, SectorType secType) { var INT_Nom = new TSMSector(); string code = sitcCode.Trim(); using (var context = new TSMContext()) { INT_Nom = context.TSMSector.Where(u => u.Code == sitcCode && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.International && u.Type == secType).FirstOrDefault(); } Guid intID = Guid.Empty; if (INT_Nom != null) { intID = INT_Nom.ID; } return(intID); }
public static string GetITCSectorByID(Guid id, SectorType secType) { var ITC_Nom = new TSMSector(); //string code = sitcCode.Trim(); using (var context = new TSMContext()) { ITC_Nom = context.TSMSector.Where(u => u.ID == id && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.ITC && u.Type == secType).FirstOrDefault(); } string itcID = ""; if (ITC_Nom != null) { itcID = ITC_Nom.Code; } return(itcID); }
//GET ID by Name public static string GetINTSectorIDByName(string name, SectorType secType) { var INT_Nom = new TSMSector(); //string name = name.Trim(); using (var context = new TSMContext()) { INT_Nom = context.TSMSector.Where(u => u.Name == name && u.IsDeleted == false && u.NomenclatureType == NomenclatureType.International && u.Type == secType).FirstOrDefault(); } string intID = ""; if (INT_Nom != null) { intID = INT_Nom.Code; } return(intID); }
public static NODE CreateFromBytes(byte[] raw) { SectorType type = GetTypeFromBytes(raw); NODE result = null; if (type == SectorType.DIR_NODE) { result = DIR_NODE.CreateFromBytes(raw); } else if (type == SectorType.FILE_NODE) { result = FILE_NODE.CreateFromBytes(raw); } else { throw new Exception("Expected a DIR_NODE or FILE_NODE!"); } return(result); }
/// <summary> /// Scan FAT o miniFAT for free sectors to reuse. /// </summary> /// <param name="sType">Type of sector to look for</param> /// <returns>A stack of available sectors or minisectors already allocated</returns> internal Queue<Sector> FindFreeSectors(SectorType sType) { var freeList = new Queue<Sector>(); if (sType == SectorType.Normal) { var fatChain = GetSectorChain(-1, SectorType.FAT); var fatStream = new StreamView(fatChain, GetSectorSize(), _header.FATSectorsNumber*GetSectorSize(), SourceStream); var idx = 0; while (idx < _sectors.Count) { var id = fatStream.ReadInt32(); if (id == Sector.FreeSector) { if (_sectors[idx] == null) { var sector = new Sector(GetSectorSize(), SourceStream) {Id = idx}; _sectors[idx] = sector; } freeList.Enqueue(_sectors[idx]); } idx++; } } else { var miniFAT = GetSectorChain(_header.FirstMiniFATSectorId, SectorType.Normal); var miniFATView = new StreamView(miniFAT, GetSectorSize(), _header.MiniFATSectorsNumber*Sector.MinisectorSize, SourceStream); var miniStream = GetSectorChain(RootEntry.StartSector, SectorType.Normal); var miniStreamView = new StreamView(miniStream, GetSectorSize(), RootStorage.Size, SourceStream); long ptr = 0; var nMinisectors = (int) (miniStreamView.Length/Sector.MinisectorSize); while (ptr < nMinisectors) { //AssureLength(miniStreamView, (int)miniFATView.Length); var id = miniFATView.ReadInt32(); ptr += 4; if (id != Sector.FreeSector) continue; var miniSector = new Sector(Sector.MinisectorSize, SourceStream) { Id = (int) ((ptr - 4)/4), Type = SectorType.Mini }; miniStreamView.Seek(miniSector.Id*Sector.MinisectorSize, SeekOrigin.Begin); miniStreamView.Read(miniSector.GetData(), 0, Sector.MinisectorSize); freeList.Enqueue(miniSector); } } return freeList; }
/// <summary> /// Get a sector chain from a compound file given the first sector ID /// and the required sector type. /// </summary> /// <param name="sectorId">First chain sector's id </param> /// <param name="chainType">Type of Sectors in the required chain (mini sectors, normal sectors or FAT)</param> /// <returns>A list of Sectors as the result of their concatenation</returns> internal List<Sector> GetSectorChain(int sectorId, SectorType chainType) { switch (chainType) { case SectorType.DIFAT: return GetDifatSectorChain(); case SectorType.FAT: return GetFatSectorChain(); case SectorType.Normal: return GetNormalSectorChain(sectorId); case SectorType.Mini: return GetMiniSectorChain(sectorId); default: throw new CFException("Unsupproted chain type"); } }
public Node AddNode(SectorType type, string name, int x, int y) { Node n = new Node(type, name, x, y); Nodes.Add(n); return n; }
void AllocateAndFlushSectorsByType(SectorType sectorType) { for (int d = FindMaxDeepness(sectorType); d > 0; d--) { var s = _unallocatedSectorHeadLink; while (s != null) { var cs = s; s = s.NextLink; if (cs.Type == sectorType && cs.Deepness == d) { RealSectorAllocate(cs); FlushDirtySector(cs); } } s = _dirtySectorHeadLink; while (s != null) { var cs = s; s = s.NextLink; if (cs.Type == sectorType && cs.Deepness == d) { FlushDirtySector(cs); } } } }
public Node(SectorType type, string name, int x, int y) : this(name, x, y) { Type = type; }
int FindMaxDeepness(SectorType sectorType) { int maxdeep = 0; var s = _unallocatedSectorHeadLink; while (s != null) { if (s.Type == sectorType) maxdeep = Math.Max(maxdeep, s.Deepness); s = s.NextLink; } s = _dirtySectorHeadLink; while (s != null) { if (s.Type == sectorType) maxdeep = Math.Max(maxdeep, s.Deepness); s = s.NextLink; } return maxdeep; }