Пример #1
0
 public RadiusSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] { typeof(ImpactRadius) }));
     World.Get <RulesSystem>().AddHandler <ImpactEvent>(this);
 }
Пример #2
0
 public UnityParticleSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(HitParticlesComponent), typeof(ParticleTrailComponent),
     }));
 }
Пример #3
0
 public static void DebugStatus(int entity)
 {
     DebugStatus(EntityController.GetEntity(entity));
 }
Пример #4
0
 public static void RegisterToEntity(Collider collider, int entId)
 {
     EntityController.Get(entId).Tags.Set(EntityTags.CanUnityCollide, 1);
     _colliderToDictionary.AddOrUpdate(collider, entId);
 }
Пример #5
0
 public PhysicsSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(PhysicsOnDamageComponent)
     }));
 }
Пример #6
0
 public TransformSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new [] { typeof(DisableTrOnDeath) }));
 }
Пример #7
0
        public DirectionalSpriteSystem()
        {
            NodeFilter <DirectionalSpriteNode> .Setup(DirectionalSpriteNode.GetTypes());

            _directionalComponents = EntityController.GetNodeList <DirectionalSpriteNode>();
        }
Пример #8
0
 public CachedStat(int entity, string statId)
 {
     _entityId = entity;
     _statId   = statId;
     _stat     = EntityController.Get(_entityId)?.Get <StatsContainer>()?.Get <T>(_statId);
 }
Пример #9
0
        public CollisionCheckSystem()
        {
            NodeFilter <CollisionCheckForwardNode> .Setup(CollisionCheckForwardNode.GetTypes());

            _list = EntityController.GetNodeList <CollisionCheckForwardNode>();
        }
        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);
            }
        }
Пример #11
0
 public ActionFxSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(ActionFxComponent), typeof(SpawnPrefabOnDeath),
     }));
 }
Пример #12
0
 public CollisionEventSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(DespawnOnCollision)
     }));
 }
Пример #13
0
 public void Handle(ActionStateEvent arg)
 {
     if (arg.State == ActionStateEvents.Start)
     {
         Triggered = false;
     }
     else if (arg.State == ActionStateEvents.Impact && !Triggered)
     {
         Triggered = true;
         World.Get <RadiusSystem>().HandleRadius(EntityController.GetEntity(arg.Origin), EntityController.GetEntity(arg.Focus), Radius);
     }
 }
Пример #14
0
        public void OnPeriodicUpdate()
        {
            if (_visibleNodes == null)
            {
                _visibleNodes = EntityController.GetNodeList <UnitOccupyingCellNode>();
            }
            if (_sensorList == null)
            {
                _sensorList = EntityController.GetNodeList <SensorDetectingNode>();
            }
            if (_visibleNodes == null || _sensorList == null || !Game.GameActive || Game.Paused)
            {
                return;
            }
            var ls = World.Get <LineOfSightSystem>();

            for (int n = 0; n < _sensorList.Count; n++)
            {
                var node   = _sensorList[n];
                var sensor = node.Sensor.c;
                sensor.DetectedCells.Clear();
                var start = node.Position.c.Position;
                sensor.LastDetectedCenter = start;
                var fwd = node.Entity.Tr.ForwardDirection2D();
                for (int i = 0; i < DirectionsExtensions.Length2D; i++)
                {
                    var dir            = (Directions)i;
                    var maxRowDistance = dir == fwd ? sensor.MaxVisionDistance : sensor.MaxHearDistance;
                    var adjacent       = dir.Adjacent();
                    ShadowFloodFill.CheckRow(ref sensor.DetectedCells,
                                             start, start, maxRowDistance, new[] { adjacent[0].ToPoint3(), adjacent[1].ToPoint3() }, dir.ToPoint3());
                }
                for (int i = 0; i < _visibleNodes.Count; i++)
                {
                    var visible = _visibleNodes[i];
                    if (visible.Entity == node.Entity)
                    {
                        continue;
                    }
                    if (!sensor.DetectedCells.Contains(visible.Position.c))
                    {
                        continue;
                    }
                    var isVision = true;
                    if (CheckVision)
                    {
                        ls.CanSeeOrHear(node.Entity, visible.Entity, out isVision);
                    }
                    sensor.AddWatch(visible.Entity, isVision);
                }
                for (int w = sensor.WatchTargets.Count - 1; w >= 0; w--)
                {
                    if (sensor.WatchTargets[w].Target == null)
                    {
                        sensor.RemoveWatch(sensor.WatchTargets[w]);
                        continue;
                    }
                    sensor.WatchTargets[w].LastSensedTurnCount++;
                    if (sensor.WatchTargets[w].LastSensedTurnCount > MaxTurnsNpcVisible)
                    {
                        sensor.RemoveWatch(sensor.WatchTargets[w]);
                    }
                }
            }
        }
Пример #15
0
 public StateGraphSystem()
 {
     _animationGraphComponents = EntityController.GetComponentArray <AnimationGraphComponent>();
     _animationDel             = UpdateGraphComponent;
 }
Пример #16
0
 public InventorySystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(InventoryItem)
     }));
 }
Пример #17
0
 public StatusUpdateSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(StatusUpdateComponent), typeof(FloatingTextStatusComponent), typeof(FloatingTextCombatComponent),
     }));
 }
Пример #18
0
        public FlightPhysicsSystem()
        {
            NodeFilter <FlyingNode> .Setup(FlyingNode.GetTypes());

            _flyingList = EntityController.GetNodeList <FlyingNode>();
        }
Пример #19
0
 public SpawnSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(DespawnTimer)
     }));
 }
Пример #20
0
        private static CollisionEvent?CheckRayList(Entity originEntity, Ray ray, int limit, bool limitEnemy)
        {
            for (int i = 0; i < limit; i++)
            {
                if (originEntity.IsDestroyed())
                {
                    return(null);
                }
                var hit = _rayHits[i];

                Entity hitEntity     = EntityController.GetEntity(UnityToEntityBridge.GetEntityId(hit.collider));
                bool   isEnvironment = hitEntity == null && hit.transform.IsEnvironment();

#if DEBUG_RAYCAST
                Color pointColor = Color.white;
                if (isEnvironment)
                {
                    pointColor = Color.green;
                }
                else if (hit.transform.CompareTag(StringConst.TagInvalidCollider))
                {
                    pointColor = Color.magenta;
                }
                else if (hitEntity != null)
                {
                    pointColor = Color.red;
                }
                DebugExtension.DrawPoint(_rayHits[i].point + (Vector3.up * (i * 0.1f)), pointColor, 0.25f, 2.5f);
#endif
                if (isEnvironment)
                {
#if DEBUG
                    DebugLog.Add(originEntity.DebugId + " hit environment " + _rayHits[i].transform.name);
#endif
                    originEntity.Post(new EnvironmentCollisionEvent(originEntity, _rayHits[i].point, _rayHits[i].normal));
                    return(null);
                }
                if (hitEntity == null)
                {
                    continue;
                }
                if (IsValidCollision(originEntity, limitEnemy, hitEntity, _rayHits[i].collider, out var sourceNode, out var targetNode))
                {
                    if (targetNode.DetailCollider != null)
                    {
                        var detailTr   = targetNode.DetailCollider.Collider.transform;
                        var localPoint = hit.transform.InverseTransformPoint(ray.origin);
                        var localDir   = hit.transform.InverseTransformDirection(ray.direction);
                        var rayCast    = new Ray(detailTr.TransformPoint(localPoint), detailTr.TransformDirection(localDir));
                        if (!targetNode.DetailCollider.Collider.Raycast(rayCast, out var childHit, 500))
                        {
                            DebugExtension.DrawPoint(childHit.point, Color.yellow, 0.25f, 2.5f);
                            continue;
                        }
                    }
                    var ce = new CollisionEvent(originEntity, sourceNode, targetNode, _rayHits[i].point, _rayHits[i].normal);
                    hitEntity.Post(ce);
                    originEntity.Post(new PerformedCollisionEvent(sourceNode, targetNode, _rayHits[i].point, _rayHits[i].normal));
                    return(ce);
                }
            }
            return(null);
        }
Пример #21
0
 public static Entity GetEntity(Collider collider)
 {
     return(_colliderToDictionary.TryGetValue(collider, out var id) ? EntityController.GetEntity(id) : null);
 }
Пример #22
0
 public static Entity GetEntity <T>(this T component) where T : IComponent
 {
     return(EntityController.GetComponentArray <T>().GetEntity(component));
 }
Пример #23
0
 public ConfuseSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(ConfuseImpact)
     }));
 }
Пример #24
0
 public MoveTargetSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(MoveTarget)
     }));
 }
Пример #25
0
 public SpellSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(SpellsContainer)
     }));
 }
Пример #26
0
 public ModelSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(ModelLoaderComponent)
     }));
 }
Пример #27
0
 public EntityFlightSystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(FlightMoveInput)
     }));
 }
Пример #28
0
 public SpriteAnimationSystem()
 {
     _arraySpriteAnimation = EntityController.GetComponentArray <SpriteAnimationComponent>();
 }
Пример #29
0
 public static void PostSignal(int entity, int message)
 {
     EntityController.GetEntity(entity)?.Post(message);
 }
Пример #30
0
 public CurrencySystem()
 {
     EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] {
         typeof(CurrencyItem)
     }));
 }