public IController GetController() { ITransformable transf; string[] transformableNames = PrefabUtils.GetEntityAndComponentName(Transformable); if (transformableNames[0] == null) { transf = FatherEntity.SceneNodes[Transformable]; } else { transf = GameWorldManager.Instance.GetEntity(transformableNames[0]).SceneNodes[transformableNames[1]]; } switch (Type) { case ControllerType.BodyController: Body body; GameEntity ent; string[] bodyNames = PrefabUtils.GetEntityAndComponentName(Body); if (bodyNames[0] == null) { body = FatherEntity.PhysicsEntity.GetBody(Body); ent = FatherEntity; } else { ent = GameWorldManager.Instance.GetEntity(bodyNames[0]); body = ent.PhysicsEntity.GetBody(bodyNames[1]); } BodyController bc = new BodyController(transf, body, ent); return(bc); case ControllerType.LineJointController: Joint joint; string[] jointNames = PrefabUtils.GetEntityAndComponentName(Joint); if (jointNames[0] == null) { joint = FatherEntity.PhysicsEntity.GetJoint(Joint); } else { joint = GameWorldManager.Instance.GetEntity(jointNames[0]).PhysicsEntity.GetJoint(jointNames[1]); } LineJointController ljc = new LineJointController(transf, joint.BodyA, joint.BodyB); return(ljc); } return(new BodyController(null, null, null)); }
private void GameEntityCreateControllers(GameEntity entity) { foreach (ControllerPrefab cp in _controllersPrefab.Values) { cp.FatherEntity = entity; switch (cp.Type) { case ControllerType.BodyController: BodyController bc = cp.GetController() as BodyController; entity.BodyControllers.Add(bc); FrameUpdateManager.Instance.Register(bc); break; case ControllerType.LineJointController: LineJointController ljc = cp.GetController() as LineJointController; entity.LineJointControllers.Add(ljc); FrameUpdateManager.Instance.Register(ljc); break; } } }