/// <summary> /// Initialise a new instance of the <see cref="AComponentSystem{TState, TComponent}"/> class with the given <see cref="World"/> and <see cref="IParallelRunner"/>. /// </summary> /// <param name="world">The <see cref="World"/> on which to process the update.</param> /// <param name="runner">The <see cref="IParallelRunner"/> used to process the update in parallel if not null.</param> /// <param name="minComponentCountByRunnerIndex">The minimum number of component per runner index to use the given <paramref name="runner"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception> protected AComponentSystem(World world, IParallelRunner runner, int minComponentCountByRunnerIndex) { _runner = runner ?? DefaultParallelRunner.Default; _runnable = new Runnable(this); _components = ComponentManager <TComponent> .GetOrCreate(world.CheckArgumentNullException(nameof(world)).WorldId); _minComponentCountByRunnerIndex = _runner.DegreeOfParallelism > 1 ? minComponentCountByRunnerIndex : int.MaxValue; World = world; }
/// <summary> /// Initialise a new instance of the <see cref="AComponentSystem{TState, TComponent}"/> class with the given <see cref="World"/> and <see cref="IParallelRunner"/>. /// </summary> /// <param name="world">The <see cref="World"/> on which to process the update.</param> /// <param name="runner">The <see cref="IParallelRunner"/> used to process the update in parallel if not null.</param> /// <param name="minComponentCountByRunnerIndex">The minimum number of component per runner index to use the given <paramref name="runner"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception> protected AComponentSystem(World world, IParallelRunner runner, int minComponentCountByRunnerIndex) { _runner = runner ?? DefaultParallelRunner.Default; _runnable = new Runnable(this); _components = ComponentManager <TComponent> .GetOrCreate(world?.WorldId ?? throw new ArgumentNullException(nameof(world))); _minComponentCountByRunnerIndex = minComponentCountByRunnerIndex; World = world; }
private void AddHeader() { var header = ComponentPool.Get <CrosswalkHeaderPanel>(PropertiesPanel, "Header"); header.Init(EditObject.Style.Value.Type, SelectTemplate, false); header.OnSaveTemplate += SaveTemplate; header.OnCopy += CopyStyle; header.OnPaste += PasteStyle; header.OnCut += CutLines; }
private void AddStyleTypeProperty() { Style = ComponentPool.Get <FillerStylePropertyPanel>(PropertiesPanel, nameof(Style)); Style.Text = NodeMarkup.Localize.Editor_Style; Style.Init(); Style.UseWheel = true; Style.WheelTip = true; Style.SelectedObject = EditObject.Style.Value.Type; Style.OnSelectObjectChanged += StyleChanged; }
protected LineAlignmentPropertyPanel AddAlignmentProperty(IDoubleAlignmentLine alignmentStyle, UIComponent parent) { var alignmentProperty = ComponentPool.Get <LineAlignmentPropertyPanel>(parent, nameof(alignmentStyle.Alignment)); alignmentProperty.Text = Localize.StyleOption_Alignment; alignmentProperty.Init(); alignmentProperty.SelectedObject = alignmentStyle.Alignment; alignmentProperty.OnSelectObjectChanged += (value) => alignmentStyle.Alignment.Value = value; return(alignmentProperty); }
public void should_allocate_up_front_components() { var expansionSize = 100; var initialSize = 100; var componentPool = new ComponentPool <TestComponentOne>(initialSize); Assert.Equal(componentPool.Count, initialSize); Assert.Equal(componentPool.Components.Length, initialSize); }
private void AddTemplateName() { NameProperty = ComponentPool.Get <StringPropertyPanel>(PropertiesPanel, "Name"); NameProperty.Text = NodeMarkup.Localize.TemplateEditor_Name; NameProperty.FieldWidth = 230; NameProperty.SubmitOnFocusLost = true; NameProperty.Init(); NameProperty.Value = EditObject.Name; NameProperty.OnValueChanged += (name) => OnChanged(); }
protected BoolListPropertyPanel AddUseGapProperty(UIComponent parent) { var useGapProperty = ComponentPool.Get <BoolListPropertyPanel>(parent, nameof(UseGap)); useGapProperty.Text = Localize.StyleOption_UseGap; useGapProperty.Init(); useGapProperty.SelectedObject = UseGap; useGapProperty.OnSelectObjectChanged += (value) => UseGap.Value = value; return(useGapProperty); }
private void RemovePreview() { if (Preview == null) { return; } ContentPanel.opacity = 1f; ComponentPool.Free(Preview); Preview = null; }
public CharacterCreationInputHandler( ITyperPool typerPool, ComponentPool componentPool, CharacterCreationState state, IScreenNavigation screenNavigation, ICharactersClient charactersClient) : base(typerPool, componentPool) { _screenNavigation = screenNavigation; _charactersClient = charactersClient; _state = state; }
public UnitFactory(Context context) { _context = context; _entityPool = context.entities; _view = _context.services.view; _sprites = new WeakDictionary <string, Sprite>(path => _context.services.resources.ReadFrom <Sprite>(path)); _gameConfig = _context.services.serialize.GetGameConfig(); }
protected override void OnObjectSelect() { Offset = ComponentPool.Get <FloatPropertyPanel>(PropertiesPanel); Offset.Text = NodeMarkup.Localize.PointEditor_Offset; Offset.UseWheel = true; Offset.WheelStep = 0.1f; Offset.WheelTip = WheelTip; Offset.Init(); Offset.Value = EditObject.Offset; Offset.OnValueChanged += OffsetChanged; }
public IEnumerator removeTest() { Transform root = new GameObject("Root").transform; Transform origin = new GameObject("Origin").transform; ComponentPool <Transform> list = new ComponentPool <Transform>(root, origin); Transform component = Object.Instantiate(origin); list.add(component); Assert.True(list.remove(component)); yield return(new WaitForEndOfFrame()); }
protected override void OnObjectSelect(IntersectionTemplate editObject) { base.OnObjectSelect(editObject); ItemsPanel.RemovePreview(); Screenshot = ComponentPool.Get <PropertyGroupPanel>(ContentPanel.Content, nameof(Screenshot)); var info = ComponentPool.Get <IntersectionTemplateInfoProperty>(Screenshot, "Info"); info.Init(EditObject); }
public void should_nullify_class_based_components_on_release() { var componentPool = new ComponentPool <TestComponentOne>(10); var indexToUse = componentPool.IndexPool.AllocateInstance(); componentPool.Components[indexToUse] = new TestComponentOne(); componentPool.Release(indexToUse); Assert.True(componentPool.Components.All(x => x is null)); }
protected virtual void Start() { //Pool componentPool = new ComponentPool(); //Spawn at the start timer = spawnRate; //Remove this so that we can have waves of enemies; //ShouldStartSpawning = true; }
private void AddOffset(MarkupEnterPoint point) { Offset = ComponentPool.Get <FloatPropertyPanel>(PropertiesPanel, nameof(Offset)); Offset.Text = NodeMarkup.Localize.PointEditor_Offset; Offset.UseWheel = true; Offset.WheelStep = 0.1f; Offset.WheelTip = WheelTip; Offset.Init(); Offset.Value = point.Offset; Offset.OnValueChanged += OffsetChanged; }
public MainMenuInputHandler( ITyperPool typerPool, ComponentPool componentPool, MainMenuState state, IScreenNavigation screenNavigation, IConnectionManager connectionManager) : base(typerPool, componentPool) { _screenNavigation = screenNavigation; _connectionManager = connectionManager; _state = state; }
public void RemovePreview() { if (Preview == null) { return; } Editor.AvailableContent = true; ComponentPool.Free(Preview); Preview = null; }
protected BoolListPropertyPanel AddParallelProperty(IParallel parallelStyle, UIComponent parent) { var parallelProperty = ComponentPool.Get <BoolListPropertyPanel>(parent, nameof(parallelStyle.Parallel)); parallelProperty.Text = Localize.StyleOption_ParallelToLanes; parallelProperty.Init(Localize.StyleOption_No, Localize.StyleOption_Yes); parallelProperty.SelectedObject = parallelStyle.Parallel; parallelProperty.OnSelectObjectChanged += (value) => parallelStyle.Parallel.Value = value; return(parallelProperty); }
protected BoolListPropertyPanel AddUseSecondColorProperty(UIComponent parent) { var useSecondColorProperty = ComponentPool.GetBefore <BoolListPropertyPanel>(parent, nameof(Color), nameof(UseSecondColor)); useSecondColorProperty.Text = Localize.StyleOption_ColorCount; useSecondColorProperty.Init(Localize.StyleOption_ColorCountOne, Localize.StyleOption_ColorCountTwo, false); useSecondColorProperty.SelectedObject = UseSecondColor; useSecondColorProperty.OnSelectObjectChanged += (value) => UseSecondColor.Value = value; return(useSecondColorProperty); }
protected sealed override EditorItem AddPrefabProperty(UIComponent parent) { var prefabProperty = ComponentPool.Get <SelectTreeProperty>(parent, nameof(Prefab)); prefabProperty.Text = Localize.StyleOption_AssetTree; prefabProperty.Init(60f); prefabProperty.Prefab = Prefab; prefabProperty.OnValueChanged += (TreeInfo value) => Prefab.Value = value; return(prefabProperty); }
protected PropColorPropertyPanel AddColorOptionProperty(UIComponent parent) { var colorOptionProperty = ComponentPool.GetAfter <PropColorPropertyPanel>(parent, nameof(Prefab), nameof(ColorOption)); colorOptionProperty.Text = Localize.StyleOption_ColorOption; colorOptionProperty.UseWheel = true; colorOptionProperty.Init(); colorOptionProperty.SelectedObject = ColorOption; colorOptionProperty.OnSelectObjectChanged += (value) => ColorOption.Value = value; return(colorOptionProperty); }
private BoolListPropertyPanel AddClipSidewalkProperty(MarkupRegularLine line) { var clipSidewalk = ComponentPool.Get <BoolListPropertyPanel>(LineProperties, nameof(line.ClipSidewalk)); clipSidewalk.Text = NodeMarkup.Localize.LineEditor_ClipSidewalk; clipSidewalk.Init(NodeMarkup.Localize.StyleOption_No, NodeMarkup.Localize.StyleOption_Yes); clipSidewalk.SelectedObject = line.ClipSidewalk; clipSidewalk.OnSelectObjectChanged += (value) => line.ClipSidewalk.Value = value; return(clipSidewalk); }
private LineAlignmentPropertyPanel AddAlignmentProperty(PropertyEnumValue <Alignment> property, string label) { var alignment = ComponentPool.Get <LineAlignmentPropertyPanel>(LineProperties, "LineAlignment"); alignment.Text = label; alignment.Init(); alignment.SelectedObject = property; alignment.OnSelectObjectChanged += (value) => property.Value = value; return(alignment); }
private void ReloadAdditionalProperties() { if (Aditional != null) { foreach (var aditional in Aditional) { ComponentPool.Free(aditional); } } Aditional = AddAditionalProperties().ToArray(); }
private void AddAuthor() { if (EditObject.IsAsset) { var authorProperty = ComponentPool.Get <StringPropertyPanel>(PropertiesPanel, "Author"); authorProperty.Text = NodeMarkup.Localize.TemplateEditor_Author; authorProperty.FieldWidth = 230; authorProperty.EnableControl = false; authorProperty.Init(); authorProperty.Value = EditObject.Asset.Author; } }
protected ColorAdvancedPropertyPanel AddSecondColorProperty(UIComponent parent) { var colorProperty = ComponentPool.GetAfter <ColorAdvancedPropertyPanel>(parent, nameof(Color), nameof(SecondColor)); colorProperty.Text = Localize.StyleOption_Color; colorProperty.WheelTip = Editor.WheelTip; colorProperty.Init(); colorProperty.Value = SecondColor; colorProperty.OnValueChanged += (Color32 color) => SecondColor.Value = color; return(colorProperty); }
private SelectNetworkProperty AddPrefabProperty(UIComponent parent) { var prefabProperty = ComponentPool.Get <SelectNetworkProperty>(parent, nameof(Prefab)); prefabProperty.Text = Localize.StyleOption_AssetNetwork; prefabProperty.Selector = IsValidNetwork; prefabProperty.Init(60f); prefabProperty.Prefab = Prefab; prefabProperty.OnValueChanged += (NetInfo value) => Prefab.Value = value; return(prefabProperty); }
protected ColorAdvancedPropertyPanel AddColorProperty(UIComponent parent) { var colorProperty = ComponentPool.GetAfter <ColorAdvancedPropertyPanel>(parent, nameof(ColorOption), nameof(Color)); colorProperty.Text = Localize.StyleOption_Color; colorProperty.WheelTip = Settings.ShowToolTip; colorProperty.Init(GetDefault()?.Color); colorProperty.Value = Color; colorProperty.OnValueChanged += (Color32 color) => Color.Value = color; return(colorProperty); }
public EntityComponentSystem() { ComponentCollection = new ComponentPool(); systems = new List<ISystem>(); entities = new List<Entity>(); }