public void RemoveFromWorld(Dyn.World world) { world.RemoveBody(PBody); PBody = PBody.Clone(world: DummyWorld); }
/// <summary> /// AddToWorld() and RemoveFromWorld() are necessary to make a square peg fit in a round hole, essentially. /// See, we're going to want to have actors with Body's attached to them that aren't in the current World. /// For instance, when they're representing a room that hasn't been entered yet. /// Or when they've just been loaded and we're about to create them but still need to know where the heck /// they are. /// Since Farseer makes it impossible to have a Body that doesn't have a World attached to it, we make a dummy /// World and use that to initialize Body's, then replace it with a copy that refers to the real game's World /// when the actor goes live. /// OPT: This allocates, irritatingly, but won't be happening every frame. /// </summary> /// <param name="world">World.</param> public void AddToWorld(Dyn.World world) { PBody = PBody.Clone(world: world); Fixture = PBody.CreateFixture(Shape); Log.Message("Added body to world, type {0}, actor {1}", PBody.BodyType, Owner); }