public void GlobalSetup() { var componentTypeAssigner = new DefaultComponentTypeAssigner(); var allComponents = componentTypeAssigner.GenerateComponentLookups(); var componentLookup = new ComponentTypeLookup(allComponents); _availableComponents = allComponents.Keys .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); var componentDatabase = new ComponentDatabase(componentLookup); var componentRepository = new ComponentRepository(componentLookup, componentDatabase); var entityFactory = new DefaultEntityFactory(new IdPool(), componentRepository); var poolFactory = new DefaultEntityCollectionFactory(entityFactory); var observableGroupFactory = new DefaultObservableObservableGroupFactory(); _entityCollectionManager = new EntityCollectionManager(poolFactory, observableGroupFactory, componentLookup); _availableComponents = _groupFactory.GetComponentTypes .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); _testGroups = _groupFactory.CreateTestGroups().ToArray(); foreach (var group in _testGroups) { _entityCollectionManager.GetObservableGroup(group); } _defaultEntityCollection = _entityCollectionManager.GetCollection(); }
public SceneManager(IEntityCollectionManager collectionManager, UIManager uiManager) { sceneEntities = new Dictionary <string, IEntity>(); scenes = new List <string>(); var defaultCollection = collectionManager.GetCollection(); SceneLoadedAsObservable().Subscribe(arg => { scenes.Add(arg.Scene.name); var entity = defaultCollection.CreateEntity(); var sceneComponent = new SceneComponent { Scene = arg.Scene }; entity.AddComponents(sceneComponent); sceneEntities.Add(new KeyValuePair <string, IEntity>(arg.Scene.name, entity)); }).AddTo(disposables); SceneUnloadedAsObservable().Subscribe(scene => { if (sceneEntities.ContainsKey(scene.name)) { scenes.Remove(scene.name); defaultCollection.RemoveEntity(sceneEntities[scene.name].Id); sceneEntities.Remove(scene.name); uiManager.CurrentScreen.Value = null; } }).AddTo(disposables); }
public UIManager(IEntityCollectionManager collectionManager, IEventSystem eventSystem) { CurrentScreen = new ReactiveProperty <IEntity>(); defaultConllection = collectionManager.GetCollection(); this.eventSystem = eventSystem; uiGroup = collectionManager.GetObservableGroup(new Group(typeof(UIComponent))); }
/// <inheritdoc /> public override void EventTriggered(PickupEvent eventData) { if (eventData.PickupableEntity.HasComponent <FoodComponent>()) { Debug.Log("[PickupFoodDisplaySystem] EventTriggered"); var foodDisplayEntity = _entityCollectionManager.GetCollection().CreateEntity(new PickupFoodDisplayBlueprint()); var textComponent = foodDisplayEntity.GetGameObject().GetComponentInChildren <TextMeshProUGUI>(); textComponent.SetText($"+{eventData.PickupableEntity.GetComponent<FoodComponent>().Amount}"); textComponent.transform.parent.position = eventData.PickupableEntity.GetGameObject().transform.position; textComponent.GetComponent <Animator>().SetTrigger("PickedFood"); } }
public void GlobalSetup() { _eventSystem = new EventSystem(new MessageBroker()); var entityFactory = new DefaultEntityFactory(_eventSystem); var poolFactory = new DefaultEntityCollectionFactory(entityFactory, _eventSystem); var groupAccessorFactory = new DefaultObservableObservableGroupFactory(_eventSystem); _entityCollectionManager = new EntityCollectionManager(_eventSystem, poolFactory, groupAccessorFactory); _availableComponents = _groupFactory.GetComponentTypes .Select(x => Activator.CreateInstance(x) as IComponent) .ToArray(); _testGroups = _groupFactory.CreateTestGroups().ToArray(); foreach (var group in _testGroups) { _entityCollectionManager.CreateObservableGroup(group); } _defaultEntityCollection = _entityCollectionManager.GetCollection(); }
public SpawnerSystem(IEntityCollectionManager collectionManager) { DefaultCollection = collectionManager.GetCollection(); }
public void AnimationEndedThenRemoveEntity() { _entityCollectionManager.GetCollection().RemoveEntity(GetComponent <EntityView>()?.Entity?.Id ?? GetComponentInParent <EntityView>().Entity.Id); }
public AudioManager(IEntityCollectionManager collectionManager) { defaultCollection = collectionManager.GetCollection(); }
public ShootBulletEventSystem(IEntityCollectionManager entityCollectionManager, IEventSystem eventSystem) : base(eventSystem) { _defaultCollection = entityCollectionManager.GetCollection(); }
public SelfDestructionSystem(IEntityCollectionManager collectionManager) { _defaultCollection = collectionManager.GetCollection(); }