public void FillFactionEnemiesList(List <Entity> entityList, int faction) { if (!_factionToEnemies.TryGetValue(faction, out var list)) { return; } var factionList = EntityController.GetComponentArray <FactionComponent>(); foreach (FactionComponent f in factionList) { if (list.Contains(f.Value)) { var entity = f.GetEntity(); if (entity != null) { entityList.Add(entity); } } } //factionList.RunAction( // f => { // if (list.Contains(f.Faction)) { // entityList.Add(f.GetEntity()); // } // }); }
public CachedAnimator(IAnimator value) { _value = value; if (value is UnityEngine.Component unityComponent) { var prefab = PrefabEntity.FindPrefabRoot(unityComponent.transform); if (prefab != null) { _serializedId = prefab.Metadata.SerializationId; _transformChild = unityComponent.transform.GetPath(); } else { Debug.LogErrorFormat("{0}: unable to find prefab root on {1}", value.GetType(), unityComponent.gameObject.name); } return; } if (value is IComponent ecsComponent) { _componentType = value.GetType(); _entityId = EntityController.GetComponentArray(_componentType).GetEntity(ecsComponent); return; } Debug.LogErrorFormat("{0} is not a valid type of animator", value.GetType()); }
public void Set(T component) { _value = component; if (_value == null) { Clear(); return; } if (component is UnityEngine.Component unityComponent) { var prefab = PrefabEntity.FindPrefabRoot(unityComponent.transform); if (prefab != null) { _serializedId = prefab.PrefabId; _transformChild = unityComponent.transform.GetPath(); } else { Debug.LogErrorFormat("{0}: unable to find prefab root on {1}", component.GetType(), unityComponent.gameObject.name); } return; } if (component is IComponent ecsComponent) { _componentType = component.GetType(); _entityId = EntityController.GetComponentArray(_componentType).GetEntity(ecsComponent); return; } Debug.LogErrorFormat("{0} is not a valid type of animator", component.GetType()); }
public AnimationGraphSystem() { EntityController.RegisterReceiver(new EventReceiverFilter(this, new [] { typeof(AnimationGraphComponent) })); _graphList = EntityController.GetComponentArray <AnimationGraphComponent>(); _graphDel = RunUpdate; }
public static bool IsDestroyed <T>(this T component) where T : IComponent { var entity = EntityController.GetComponentArray <T>().GetEntity(component); if (entity == null) { return(true); } return(entity.IsDestroyed()); }
private void CheckRigidbodies() { if (_rbList == null) { _rbList = EntityController.GetComponentArray <RigidbodyComponent>(); } if (_rbList != null) { _rbList.Run(CheckPaused); } }
public void OnSystemUpdate(float dt) { if (_list == null) { _list = EntityController.GetComponentArray <CollisionCheckForward>(); } if (_list != null) { _list.Run(_del); } }
public void OnSystemUpdate(float dt) { if (_list == null) { _list = EntityController.GetComponentArray <AnimatorData>(); } if (_list != null) { _list.Run(_del); } }
public void OnSystemUpdate(float dt) { if (_list == null) { _list = EntityController.GetComponentArray <ModifiersContainer>(); } if (_list != null) { _list.Run(_del); MessageKit.post(Messages.ModifiersUpdated); } }
public void HandleGlobal(SaveGameLoaded arg) { var equipArray = EntityController.GetComponentArray <Equipment>(); foreach (Equipment equipment in equipArray) { if (equipment.Mods == null) { continue; } for (int i = 0; i < equipment.Mods.Length; i++) { equipment.Mods[i].Restore(); } } }
public void FillFactionFriendsList(List <Entity> entityList, int faction) { if (!_factionToAllies.TryGetValue(faction, out var list)) { return; } var factionList = EntityController.GetComponentArray <FactionComponent>(); factionList.RunAction( f => { if (list.Contains(f.Faction)) { entityList.Add(f.GetEntity()); } }); }
public SpriteRenderingSystem() { TemplateFilter <SpriteRendererTemplate> .Setup(); _rendererList = EntityController.GetTemplateList <SpriteRendererTemplate>(); _rendererDel = RunUpdate; TemplateFilter <SpriteRendererInstancedTemplate> .Setup(); _rendererInstancedList = EntityController.GetTemplateList <SpriteRendererInstancedTemplate>(); _rendererInstancedDel = RunUpdate; _simpleRenderers = EntityController.GetComponentArray <SpriteSimpleRendererComponent>(); _simpleRendererDel = RunUpdate; ItemPool.LoadAsset <Material>(MaterialAddress, (m) => _material = m); }
public void OnSystemUpdate(float dt) { for (int i = _moveTweens.Count - 1; i >= 0; i--) { _moveTweens[i].Tr.position = _moveTweens[i].Tween.Get(); if (_moveTweens[i].Owner.Tags.Contain(EntityTags.RotateToMoveTarget)) { RotateTowardsMoveTarget(_moveTweens[i].Tr, _moveTweens[i].Tween.EndValue, _moveTweens[i].Owner.Get <RotationSpeed>()?.Speed ?? 10); } if (!_moveTweens[i].Tween.Active) { FinishMove(_moveTweens[i].Owner, _moveTweens[i].Tween.EndValue); _moveTweens.RemoveAt(i); } } if (_rotateList == null) { _rotateList = EntityController.GetComponentArray <RotateToTarget>(); } if (_rotateList != null) { _rotateList.Run(_rotateDel); } if (_simpleMoveList == null) { _simpleMoveList = EntityController.GetComponentArray <SimplerMover>(); } if (_simpleMoveList != null) { _simpleMoveList.Run(_simpleMoveDel); } if (_arcMoverList == null) { _arcMoverList = EntityController.GetComponentArray <ArcMover>(); } if (_arcMoverList != null) { _arcMoverList.Run(_arcMoveDel); } }
public void OnSystemUpdate(float dt, float unscaledDt) { if (_despawnArray == null) { _despawnArray = EntityController.GetComponentArray <DespawnTimer>(); } if (_despawnArray != null) { foreach (DespawnTimer despawnTimer in _despawnArray) { if (despawnTimer.FinishItem < 0) { continue; } var compareTime = despawnTimer.Unscaled ? TimeManager.TimeUnscaled : TimeManager.Time; if (despawnTimer.FinishItem <= compareTime) { despawnTimer.GetEntity().Destroy(); } } } }
public PoseAnimationSystem() { _array = EntityController.GetComponentArray <PoseAnimatorComponent>(); _del = UpdateList; }
private void OnGUI() { if (!Application.isPlaying) { Close(); return; } if (_inPointStyle == null || _nodeStyle == null || _nodeTextStyle == null) { SetupStyles(); } var list = EntityController.GetComponentArray <AnimationGraphComponent>(); _entityListing.Clear(); _smallerList.Clear(); int currentIndex = -1; foreach (var graphComponent in list) { if (graphComponent == _graph) { currentIndex = _entityListing.Count; } _entityListing.Add(graphComponent.GetEntity().DebugId); _smallerList.Add(graphComponent); } var newIndex = EditorGUILayout.Popup(currentIndex, _entityListing.ToArray()); if (newIndex != currentIndex) { _graph = _smallerList[newIndex]; } _scrollRect = new Rect(0, 0, position.width - Border, position.height); _scrollPosition = GUI.BeginScrollView(_scrollRect, _scrollPosition, new Rect(0, 0, MaxRectSize, MaxRectSize)); DrawGrid(20, 0.2f, Color.gray); DrawGrid(100, 0.4f, Color.gray); if (_graph == null) { EditorGUILayout.LabelField("No Graph Selected of " + _entityListing.Count); GUI.EndScrollView(); return; } if (_graph.Value == null) { EditorGUILayout.LabelField("Component has no Graph " + _graph.GetEntity()?.DebugId ?? "None"); GUI.EndScrollView(); return; } if (_graph.Value.Current is ExternalGraphNode.RuntimeNode externalGraphNode) { DrawGraph(externalGraphNode.ExternalGraph); } else if (_graph.Value.Current is SwitchExternalNode.RuntimeNode switchGraphNode) { DrawGraph(switchGraphNode.ExternalGraph); } else { DrawGraph(_graph.Value); } }
public static Entity GetEntity <T>(this T component) where T : IComponent { return(EntityController.GetComponentArray <T>().GetEntity(component)); }
public StateGraphSystem() { _animationGraphComponents = EntityController.GetComponentArray <AnimationGraphComponent>(); _animationDel = UpdateGraphComponent; }
public SpriteAnimationSystem() { _arraySpriteAnimation = EntityController.GetComponentArray <SpriteAnimationComponent>(); }