internal static void Dispose() { eventBusService = null; taskService = null; coroutineService = null; timeService = null; }
public void ReplaceCoroutineService(ICoroutineService newInstance) { var index = GameComponentsLookup.CoroutineService; var component = (CoroutineServiceComponent)CreateComponent(index, typeof(CoroutineServiceComponent)); component.instance = newInstance; ReplaceComponent(index, component); }
public TutorialScenario(IWorldTreeService worldTreeService, IVrInputDispatcher inputDispatcher, INavigationService navigationService, ICoroutineService coroutineService, IGlobalObjectService globalObjectService, IVrManipulationService manipulationService) { this.worldTreeService = worldTreeService; this.inputDispatcher = inputDispatcher; this.navigationService = navigationService; this.coroutineService = coroutineService; this.globalObjectService = globalObjectService; this.manipulationService = manipulationService; }
public GameEntity SetCoroutineService(ICoroutineService newInstance) { if (hasCoroutineService) { throw new Entitas.EntitasException("Could not set CoroutineService!\n" + this + " already has an entity with CoroutineServiceComponent!", "You should check if the context already has a coroutineServiceEntity before setting it or use context.ReplaceCoroutineService()."); } var entity = CreateEntity(); entity.AddCoroutineService(newInstance); return(entity); }
public NestedCirclesStorySpringModel(ICoroutineService coroutineService, Action <NestedCirclesStorySpringModel> visualize, IStoryGraph sg) { Debug.Assert(SpringConstant * IterationDeltaT < 1, "SpringConstant * IterationDeltaT < 1"); this.coroutineService = coroutineService; this.visualize = visualize; this.sg = sg; nodeExternalConnections = BuildNodeExternalConnections(sg); positions = new Vector2[sg.EnoughIntegers.Count]; oldPositions = new Vector2[sg.EnoughIntegers.Count]; radii = new float[sg.EnoughIntegers.Count]; placed = new bool[sg.EnoughIntegers.Count]; }
public BuildingStoryLayoutPlacementAlgorithm(ICoroutineService coroutineService, Action <BuildingStoryLayoutPlacementAlgorithm> visualize, IStoryGraph sg) { this.coroutineService = coroutineService; this.visualize = visualize; this.sg = sg; laneBuilder = new BuildingLaneBuilder(sg, x => relativeTransforms[x]); nodeRows = sg.EnoughIntegers.Select(x => - 1).ToArray(); grids = sg.EnoughIntegers.ToDictionary(x => x, x => new BuildingStoryLayoutAbstractGrid()); relPositions = new Vector3[sg.EnoughIntegers.Count]; halfSizes = new Size3[sg.EnoughIntegers.Count]; isReversed = new bool[sg.EnoughIntegers.Count]; relativeTransforms = new Dictionary <int, Transform>(); }
public void ReplaceCoroutineService(ICoroutineService newInstance) { var entity = coroutineServiceEntity; if (entity == null) { entity = SetCoroutineService(newInstance); } else { entity.ReplaceCoroutineService(newInstance); } }
public Services(ILogService log, IViewService view, IMouseInputService mouseInput, ILoadConfigService loadConfig, ISceneService scene, ICoroutineService coroutine, IKeyInputService keyInput, ITimeService time, IPhysicsService physics, INetworkService network, ILocalStorageService localStorage, IFileService file, ISettingService setting) { Log = log; View = view; MouseInput = mouseInput; LoadConfig = loadConfig; Scene = scene; Coroutine = coroutine; KeyInput = keyInput; Time = time; Physics = physics; Network = network; LocalStorage = localStorage; File = file; Setting = setting; }
public GuiService() { _graphics = ServiceLocator.Instance.GetService<GraphicsDevice>(); _timer = ServiceLocator.Instance.GetService<ITimerService>(); _keyboard = ServiceLocator.Instance.GetService<IKeyboardService>(); _mouse = ServiceLocator.Instance.GetService<IMouseService>(); _renderInterface = new Gui.LibRocketRenderInterface(_graphics, ServiceLocator.Instance.GetService<ContentManager>(), true); _coroutines = ServiceLocator.Instance.GetService<ICoroutineService>(); LibRocketNet.Core.SystemInterface = new Gui.LibRocketSystemInterface(_timer); LibRocketNet.Core.RenderInterface = _renderInterface; LibRocketNet.Core.Initialize(); LibRocketNet.Core.ScriptEvent += (o, e) => { Console.WriteLine("[Gui] Script event:" + e.Script); }; Context = LibRocketNet.Core.CreateContext( ContextName, new Vector2i(_graphics.Viewport.Width, _graphics.Viewport.Height)); LoadFonts(); LibRocketNet.Core.InitDebugger(Context); _keyboard.KeyDown += KeyDownHandler; _keyboard.KeyUp += KeyUpHandler; _mouse.ButtonDown += (o, e) => { Context.ProcessMouseButtonDown(e, GetKeyModifiers()); }; _mouse.ButtonUp += (o, e) => Context.ProcessMouseButtonUp(e, GetKeyModifiers()); _mouse.WheelChanged += (w) => { Context.ProcessMouseWheel(-w, GetKeyModifiers()); }; _mouse.Move += ProcessMouseMove; _coroutines.StartCoroutine(UpdateUI()); }
protected CirclePackingAutoComponent(IEmbeddedResources embeddedResources, IViewService viewService, ICoroutineService coroutineService) { this.embeddedResources = embeddedResources; this.coroutineService = coroutineService; solver = new CirclePackingSolver(); Reset(); borderModel = new ExplicitModel(ResourceVolatility.Stable) { IndexSubranges = new ExplicitModelIndexSubrange[1], Topology = ExplicitModelPrimitiveTopology.LineStrip }; backgroundVisualElement = ModelVisualElement.New(this) .SetModel(embeddedResources.SimplePlaneXyModel()) .SetMaterial(StandardMaterial.New() .SetIgnoreLighting(true) .SetDiffuseColor(Color4.Black) .FromGlobalCache()) .SetRenderState(StandardRenderState.New() .SetZOffset(-GraphicsHelper.MinZOffset)) .SetTransform(x => Transform.Translation(new Vector3(x.border.BoundingRect.Center, 0))) .SetNonUniformScale(x => new Vector3( x.border.BoundingRect.HalfWidth, x.border.BoundingRect.HalfHeight, 1)); borderVisualElement = ModelVisualElement.New(this) .SetModel(x => x.GetRelevantBorderModel()) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.Yellow) .SetIgnoreLighting(true) .FromGlobalCache()); circleVisualElements = new List <IVisualElement>(); selectOnClickInterationElement = new SelectOnClickInteractionElement(this, viewService); // todo: make precise hittable = new RectangleHittable <CirclePackingAutoComponent>(this, Transform.Identity, x => x.border.BoundingRect, x => 0); }
public async void RunOptimizationAsync(ICoroutineService coroutineService) { if (runningAsync) { return; } runningAsync = true; for (var i = 0; i < MaxIterations; i++) { if (!runningAsync) { break; } OptimizeStep(out var cost); if ((i + 1) % NumIterationPerBreak == 0) { RefreshStatuses(); await coroutineService.WaitUpdates(1); } } runningAsync = false; }
public NestedSpheresStoryLayout(IEmbeddedResources embeddedResources, ICoroutineService coroutineService, Lazy <IViewService> viewServiceLazy) { this.coroutineService = coroutineService; this.viewServiceLazy = viewServiceLazy; focusVisualEffect = new FocusVisualEffect(); mainModel = embeddedResources.SphereModel(64, true); lineModel = embeddedResources.LineModel(); sphereMaterials = new IMaterial[] { StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 0.5f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 1.0f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 0.5f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 1.0f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 0.5f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 1.0f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(), }; sphereRenderState = StandardRenderState.New().SetCullFace(CullFace.Back).FromGlobalCache(); lineMaterial = StandardMaterial.New().SetDiffuseColor(Color4.Red).FromGlobalCache(); lineMaterialExternal = StandardMaterial.New().SetDiffuseColor(0.7f * Color4.Red); lineRenderState = StandardRenderState.New().SetLineWidth(3).FromGlobalCache(); }
private ICoroutineService GetService(string name) { if (_service == null) { if (!_coroutineServiceFactories.TryGetValue(name, out IFactory <ICoroutineService> serviceFactory)) { var fragment = new TextFragment() { Code = TextCodes.NotFoundCoroutineContainerByName, DefaultFormatting = "找不到名称为{0}的协程容器", ReplaceParameters = new List <object>() { name } }; throw new UtilityException((int)Errors.NotFoundCoroutineContainerByName, fragment); } _service = serviceFactory.Create(); } return(_service); }
public NestedCirclesStoryLayout(IEmbeddedResources embeddedResources, ICoroutineService coroutineService) { this.coroutineService = coroutineService; planeModel = embeddedResources.SimplePlaneXyModel(); circleModel = embeddedResources.CircleModel(64); lineModel = embeddedResources.LineModel(); circleMaterials = new IMaterial[] { StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 0f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 1f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache() }; lineMaterial = StandardMaterial.New().SetDiffuseColor(Color4.Blue).FromGlobalCache(); lineMaterialExternal = StandardMaterial.New().SetDiffuseColor(0.7f * Color4.White).FromGlobalCache(); circleRenderState = StandardRenderState.New() .SetLineWidth(2) .SetCullFace(CullFace.Front) .FromGlobalCache(); lineRenderState = StandardRenderState.New().SetLineWidth(3).FromGlobalCache(); }
public MoveInPlaceVrNavigationMode(IStoryService storyService, IGlobalObjectService globalObjectService, ICoroutineService coroutineService) { this.storyService = storyService; this.globalObjectService = globalObjectService; this.coroutineService = coroutineService; }
public UserQueryService(IEventRoutingService eventRoutingService, ICoroutineService coroutineService) { this.coroutineService = coroutineService; this.eventRoutingService = eventRoutingService; queries = new List <IUserQuery>(); }
public BuildingStoryLayout(ICoroutineService coroutineService, IEmbeddedResources embeddedResources, IInputService inputService, Lazy <INavigationService> navigationServiceLazy) { this.embeddedResources = embeddedResources; this.inputService = inputService; this.navigationServiceLazy = navigationServiceLazy; this.coroutineService = coroutineService; planeModel = embeddedResources.SimplePlaneXzModel(); lineModel = embeddedResources.LineModel(); frustumModel = embeddedResources.SimpleFrustumModel(); colorMaterials = new IMaterial[] { StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 0f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 1f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true), }; frustumMaterial = StandardMaterial.New() .SetDiffuseColor(new Color4(0f, 1f, 0f)) .SetIgnoreLighting(true) .FromGlobalCache(); lineMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.White) .SetIgnoreLighting(true) .FromGlobalCache(); currentLineMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Red) .SetIgnoreLighting(true) .FromGlobalCache(); lineRenderState = StandardRenderState.New().SetLineWidth(3).FromGlobalCache(); var mirrorSampler = new ImageSampler { AddressModeU = ImageSamplerAddressMode.Mirror, AddressModeV = ImageSamplerAddressMode.Mirror, AddressModeW = ImageSamplerAddressMode.Mirror, }.FromGlobalCache(); floorMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_floor.jpg")) .SetNoSpecular(true) .SetSampler(mirrorSampler) .FromGlobalCache(); ceilingMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_ceiling.jpg")) .SetNoSpecular(true) .SetSampler(mirrorSampler) .FromGlobalCache(); wallMaterial = StandardMaterial.New() .SetDiffuseMap(embeddedResources.Image("Textures/museum_wall.jpg")) .SetDiffuseColor(new Color4(92, 82, 72)) //.SetNoSpecular(true) .SetNormalMap(embeddedResources.Image("Textures/museum_wall_2_norm.jpg")) .FromGlobalCache(); rawWallMaterial = StandardMaterial.New() .SetDiffuseColor(Color4.Green) .SetIgnoreLighting(true) .FromGlobalCache(); }
public Player(ICoroutineService coroutineService) { _coroutineService = coroutineService; }
public FreeTeleportVrNavigationMode(IStoryService storyService, IGlobalObjectService globalObjectService, ICoroutineService coroutineService) { this.storyService = storyService; this.globalObjectService = globalObjectService; this.coroutineService = coroutineService; }
public void Setup(ICoroutineService coroutineService) { _coroutineService = coroutineService; }
public RegisterCoroutineServiceSystem(Contexts contexts, ICoroutineService coroutineService) { _context = contexts.game; _coroutineService = coroutineService; }