public override void FlipY(bool relativeToSub) { base.FlipY(relativeToSub); if (Prefab.CanSpriteFlipY) { SpriteEffects ^= SpriteEffects.FlipVertically; } if (StairDirection != Direction.None) { StairDirection = StairDirection == Direction.Left ? Direction.Right : Direction.Left; Bodies.ForEach(b => GameMain.World.RemoveBody(b)); Bodies.Clear(); bodyDebugDimensions.Clear(); CreateStairBodies(); } if (HasBody) { CreateSections(); UpdateSections(); } }
/// <summary> /// A view of the full instruction stream /// </summary> /// <returns></returns> public string GetInstructions() { string info = FullName; Bodies.ForEach(B => info += $"\n{B.ToString()}\n"); return(info); }
/// <summary> /// Interpret IL instructions to find references to other type members /// </summary> private void InterpretBody() { Bodies.ForEach(B => { List <Instruction> calls = B.GetCallInstructions(); calls.ForEach(Ic => DeclaringType.Architecture.BaseTypes.ForEach(t => { List <MemberInfo> refMembers = t.GetMyMembers().FindAll(m => Ic.Operand.Contains(m.ArchName())); DirectRefMembers.AddRange(refMembers); })); }); }
public void StartSimulation(int frames, int dayScale) { IsRunning = true; var sw = new Stopwatch(); sw.Start(); var frameTime = 1000 / frames; var last = sw.ElapsedMilliseconds; var i = 1e9; const float scale = 1.0f / (float)AstronomicalObject.Au * 1000; while (IsRunning) { var now = sw.ElapsedMilliseconds; double delta = now - last; if (i > 4) { i = 0; for (var j = 0; j < Bodies.Count; j++) { var next = Bodies[j].Position; var builder = OrbitBuilders[j]; var model = OrbitModels[j]; var prev = OrbitPrevPoints[j]; OrbitPrevPoints[j] = next; builder.AddLine(prev.ToVector3() * scale, next.ToVector3() * scale); model.Dispatcher?.Invoke(() => model.Geometry = builder.ToLineGeometry3D()); } } Bodies.ForEach(body => body.CalculateGravity(Bodies)); Bodies.ForEach(body => body.UpdatePosition(86_400.0 * dayScale / frames)); last = now; i++; if (delta < frameTime) { Thread.Sleep(frameTime - (int)delta); } } }