public PlanetSim(int maxUsedCores = 0, int screenWidth = -1, int screenHeight = -1, bool freeFPS = false) : base() { graphics = new GraphicsDeviceManager(this); InputKeyboard = new KeyboardAdvanced(); InputMouse = new MouseAdvanced(); GravityHandler = new GravityHandling(); CollisionHandler = new CollisionHandling(); MultiProcessing = new MultiProcessingUnit(this); Content.RootDirectory = "Content"; Pause = true; GameGlobals.MaximumProcessorsUsed = maxUsedCores; m_universes = new Universe[GameGlobals.MaxUniverseCount]; #if DEBUG #endif //graphics.SynchronizeWithVerticalRetrace = false; IsFixedTimeStep = !freeFPS; if (screenWidth > 0 && screenHeight > 0) { ScreenWidth = screenWidth; ScreenHeight = screenHeight; } }
public static IVault ImportFrom(this IVault target, IVault source, CollisionHandling collisionHandling) { var cloneOfRoot = source.Root.Clone(); target.Root.SetEntireMetadata(cloneOfRoot.Metadata); cloneOfRoot.GetBranches().ForEach(b => target.ImportBranch(b, collisionHandling)); ((Branch)cloneOfRoot).GetValues(ValueKind.Regular).ForEach(v => target.ImportValue(v, collisionHandling != CollisionHandling.Error)); ((Branch)cloneOfRoot).GetValues(ValueKind.Internal).ForEach(v => target.ImportValue(v, true)); return(target); }
public IBranch ImportBranch(IBranch branch, CollisionHandling collisionHandling) { using (Vault.ExposeReadWrite()) { using (branch.Vault.ExposeReadWrite()) { var existing = GetBranch(branch.Name); if (existing == null) { return(AttachBranch(branch.Clone())); } else { (collisionHandling != CollisionHandling.Error).AssertTrue(); if (collisionHandling == CollisionHandling.Overwrite) { existing.Delete(); return(AttachBranch(branch.Clone())); } else if (collisionHandling == CollisionHandling.Merge) { // atomicity is not guaranteed. sorry branch.GetBranches().ForEach(b => existing.ImportBranch(b, CollisionHandling.Merge)); branch.GetValues().ForEach(v => existing.ImportValue(v, true)); return(this); } else { throw new NotSupportedException(String.Format( "Collision handling strategy '{0}' is not supported.", collisionHandling)); } } } } }
public IBranch ImportBranch(IBranch branch, CollisionHandling collisionHandling) { return(((IBranch)Root).ImportBranch(branch, collisionHandling)); }
public IBranch ImportBranch(IBranch branch, CollisionHandling collisionHandling) { using (Vault.ExposeReadWrite()) { using (branch.Vault.ExposeReadWrite()) { var existing = GetBranch(branch.Name); if (existing == null) { return AttachBranch(branch.Clone()); } else { (collisionHandling != CollisionHandling.Error).AssertTrue(); if (collisionHandling == CollisionHandling.Overwrite) { existing.Delete(); return AttachBranch(branch.Clone()); } else if (collisionHandling == CollisionHandling.Merge) { // atomicity is not guaranteed. sorry branch.GetBranches().ForEach(b => existing.ImportBranch(b, CollisionHandling.Merge)); branch.GetValues().ForEach(v => existing.ImportValue(v, true)); return this; } else { throw new NotSupportedException(String.Format( "Collision handling strategy '{0}' is not supported.", collisionHandling)); } } } } }