public void PostInitialise(List <CK2Title> ck2Titles) { var holder = ck2Titles.Where(t => t.Holder != null).GroupBy(t => t.Holder).OrderBy(group => group.Count()).First().Key; //If the province is either: the same relgion as the owner, a primary or accepted culture, or in the dejure territory of the owner then it is a core. Cores.AddRange(World.GetCountriesFromCharacter(holder).Where(c => c.Religion == Religion || c.PrimaryCulture == Culture || c.AcceptedCultures.Contains(Culture) || World.Cultures[c.PrimaryCulture].Group.Cultures.Any(cul => cul.Name == Culture) || ck2Titles.Any(t => c.IsDejure(t)))); // c.CountryTag != "KHA")); Owner = World.GetIndependentCountryFromCharacter((CK2Character)holder); if (Cores.Count == 0) { Cores.Add(Owner); } if (ControllerTag == null) { ControllerTag = Owner.CountryTag; } //add to owner numholdings ck2Titles.ForEach(title => { AddToFormable(title); CalcCountryEffects(title); if (title.Rank == TitleRank.county) { title.Province.BaronTitles.ForEach(barony => CalcCountryEffects(barony)); } }); }
public static void AddCore(CoreData coreData) { var Cores = GetCoresFromJson(); if (Cores == null) { Cores = new List <CoreData>(); } Cores.Add(coreData); SaveCores(Cores); }
public void SetCore(string tag, bool addCore) { if (addCore && !Cores.Contains(tag)) { Cores.Add(tag); IsModProvince = true; } else if (!addCore && Cores.Contains(tag)) { Cores.Remove(tag); IsModProvince = true; } }
public void TokenCallback(ParadoxParser parser, string token) { switch (token) { case "name": Name = parser.ReadString(); break; case "tax": Tax = parser.ReadDouble(); break; case "add_core": Cores.Add(parser.ReadString()); break; case "top_provinces": TopProvinces = parser.ReadStringList(); break; case "army": Armies.Add(parser.Parse(new Army())); break; } }
public void PostInitialise() { if (Eu4Provinces.Count > 0) { CalcEffects(World, SiblingProvinces, Eu4Provinces); var largeCultures = Pops.GetLargeCultures(0.4f); // TODO: dynamically create countries that don't have a primary nation in vic2 foreach (var cul in largeCultures) { World.CultureNations.KeyValuePairs.ForEach(cul, tag => { Cores.Add(World.Vic2Countries.Find(c => c.CountryTag == tag) ?? new Vic2Country(World, tag, World.Cultures[cul])); }); // add neoculture as accepted culture if (World.V2Mapper.NeoCultures.ContainsKey(cul) && World.V2Mapper.NeoCultures[cul] == Owner?.PrimaryCulture) { if (!Owner.AcceptedCultures.Contains(cul)) { Owner.AcceptedCultures.Add(cul); } } if (World.Cultures[cul].PrimaryNation == null) { if (World.Cultures[cul].Group.Union == null) { } } else { Cores.Add(World.Cultures[cul].PrimaryNation); } if (World.Cultures[cul].Group.Union != null) { Cores.Add(World.Cultures[cul].Group.Union); } } } //effects on owner if (Owner != null) { IterateEffects(World, World.CountryEffects.Sublists["province"], 1, Eu4Provinces, (effects, fromProvince) => { Owner.FromProvinceEffect(effects); }); } }
public CPU(IHardware hardware, bool coresEnabled = false) : base(hardware) { this.coresEnabled = coresEnabled; if (this.coresEnabled) { int coreCount = 0; using (var processor = new System.Management.ManagementObjectSearcher("Select * from Win32_Processor")) { foreach (var item in processor.Get()) { coreCount += int.Parse(item["NumberOfCores"].ToString()); } } for (int i = 1; i <= coreCount; i++) { Cores.Add(new CORE($"CPU Core #{i}")); } } Update(); InitTimer(() => Update()); }
/// <summary> /// Adds a new service Core to the Tower. /// </summary> /// <param name="perimeter">Polygon perimeter defining the footprint of the service Core.</param> /// <param name="baseStory">Index of the lowest Story whose elevation will serve as the lowest level of the Core.</param> /// <param name="addHeight">Additional height of the Core above the highest Story.</param> /// <param name="color">Color of the Core when it it is accessed as a Space.</param> /// <returns> /// True if the Core is successfully added. /// </returns> public bool AddCore(Polygon perimeter, int baseStory = 0, double addHeight = 0.0, Color color = null) { if (baseStory < 0 || baseStory > Stories.Count - 1) { return(false); } var coreHeight = 0.0; var coreStories = new List <Story>(); for (int i = baseStory; i < Stories.Count; i++) { coreHeight += Stories[i].Height; if (i > baseStory) { coreStories.Add(Stories[i]); } } coreHeight += addHeight; var core = new Room() { Elevation = Stories[baseStory].Elevation, Height = coreHeight, Perimeter = perimeter }; if (color != null) { core.Color = color; } Cores.Add(core); foreach (Story story in coreStories) { story.AddOpening(perimeter); } return(true); }
public void AppendThread(CpuId thread, int coreId) { Core core = null; foreach (Core c in Cores) { if (c.CoreId == coreId) { core = c; } } if (core == null) { core = new Core(_cpu, coreId); Cores.Add(core); } if (thread != null) { core.Threads.Add(thread); } }
/// <summary> /// Adds a new service Core to the Tower. /// </summary> /// <param name="perimeter">Polygon perimeter defining the footprint of the service Core.</param> /// <param name="baseStory">Index of the lowest Story whose elevation will serve as the lowest level of the Core.</param> /// <param name="addHeight">Additional height of the Core above the highest Story.</param> /// <param name="color">Color of the Core when it it is accessed as a Space.</param> /// <returns> /// True if the Core is successfully added. /// </returns> public bool AddServiceCore(Polygon perimeter, int baseStory = 0, double addHeight = 0.0, Color color = null) { if (baseStory < 0 || baseStory > Stories.Count - 1) { return(false); } var core = new Room() { Color = Palette.Gray, Elevation = Stories[baseStory].Elevation, Height = Height + addHeight, Perimeter = perimeter }; Cores.Add(core); foreach (Story story in Stories) { story.AddExclusion(core); } return(true); }
public virtual void ReadChildData(BinaryReader reader) { int x = 0; _materialEffects.ReadString(reader); _bitmap.ReadString(reader); for (x = 0; (x < _data.Count); x = (x + 1)) { Data.Add(new ByteBlockBlock()); Data[x].Read(reader); } for (x = 0; (x < _data.Count); x = (x + 1)) { Data[x].ReadChildData(reader); } for (x = 0; (x < _data2.Count); x = (x + 1)) { Data2.Add(new ByteBlockBlock()); Data2[x].Read(reader); } for (x = 0; (x < _data2.Count); x = (x + 1)) { Data2[x].ReadChildData(reader); } for (x = 0; (x < _data3.Count); x = (x + 1)) { Data3.Add(new ByteBlockBlock()); Data3[x].Read(reader); } for (x = 0; (x < _data3.Count); x = (x + 1)) { Data3[x].ReadChildData(reader); } for (x = 0; (x < _cores.Count); x = (x + 1)) { Cores.Add(new LiquidCoreBlockBlock()); Cores[x].Read(reader); } for (x = 0; (x < _cores.Count); x = (x + 1)) { Cores[x].ReadChildData(reader); } for (x = 0; (x < _data4.Count); x = (x + 1)) { Data4.Add(new ByteBlockBlock()); Data4[x].Read(reader); } for (x = 0; (x < _data4.Count); x = (x + 1)) { Data4[x].ReadChildData(reader); } for (x = 0; (x < _data5.Count); x = (x + 1)) { Data5.Add(new ByteBlockBlock()); Data5[x].Read(reader); } for (x = 0; (x < _data5.Count); x = (x + 1)) { Data5[x].ReadChildData(reader); } }
public void CreateBuilding( Plane basePlane, double floorHeight, double?targetBuildingArea = null, int?floorCount = null, double width = 0, double length = 0, double depth = 0, bool isCurved = false, bool createCores = false, double hallwayToDepth = 0, double coreSizeFactorFloors = 0, double coreSizeFactorArea = 0) { Length = length; Width = width; Depth = depth; BasePlane = basePlane; FloorHeight = floorHeight; IsCurved = isCurved; this.hallwayToDepth = hallwayToDepth; this.coreSizeFactorFloors = coreSizeFactorFloors; this.coreSizeFactorArea = coreSizeFactorArea; using (var point = Point.ByCoordinates(Width / 2, Length / 2)) using (var zAxis = Vector.ZAxis()) { BaseCenter = Plane.ByOriginNormal(point, zAxis); } Setup(); Surface baseSurface = MakeBaseSurface(); if (baseSurface == null) { throw new ArgumentException("Could not create building shape."); } // Surface is constructed with lower left corner at (0,0). Move and rotate to given base plane. baseSurface = TransformFromOrigin(baseSurface); FloorArea = baseSurface.Area; if (floorCount != null) { FloorCount = (int)floorCount; } else if (targetBuildingArea != null) { FloorCount = (int)Math.Ceiling((double)targetBuildingArea / FloorArea); } else { throw new ArgumentException($"Either {nameof(floorCount)} or {nameof(targetBuildingArea)} is required."); } Mass = baseSurface.Thicken(FloorCount * FloorHeight, both_sides: false); TotalVolume = Mass.Volume; FacadeArea = Mass.Area - (2 * FloorArea); for (int i = 0; i < FloorCount; i++) { using (var offsetVector = Vector.ByCoordinates(0, 0, i * FloorHeight)) { Floors.Add(new[] { (Surface)baseSurface.Translate(offsetVector) }); FloorElevations.Add(BasePlane.Origin.Z + (i * FloorHeight)); } } using (var offsetVector = Vector.ByCoordinates(0, 0, FloorCount * FloorHeight)) { TopPlane = (Plane)BasePlane.Translate(offsetVector); } baseSurface.Dispose(); if (createCores) { var coreBases = MakeCoreSurface(); if (coreBases == null || coreBases.Count == 0) { NetFloors = Floors; return; } // Transform all cores from origin. foreach (var coreBase in coreBases) { using (var core = coreBase.Thicken(FloorCount * FloorHeight, both_sides: false)) { Cores.Add(TransformFromOrigin(core)); } coreBase.Dispose(); } // Cut cores out of floors. NetFloors = new List <Surface[]>(); foreach (var floor in Floors) { NetFloors.Add(Cores.Aggregate(floor, (f, core) => f.SelectMany( surface => surface.SubtractFrom(core)) .Cast <Surface>() .ToArray())); } } else { NetFloors = Floors; } }