Beispiel #1
0
        public static bool Enter(Entity actor, CellMovementContext context)
        {
            if (!actor.TryGetBouncing(out var bouncing) || actor.IsDead())
            {
                return(false); // Remove this listener
            }

            // TODO: maybe separate the handlers by order to automate this?
            if (actor.IsCurrentOrderFavorable() && context.transform.layer.HasEitherFlag(_targetedLayer))
            {
                // If the set already contained that element
                if (!bouncing._bouncedEntities.Add(context.actor.id))
                {
                    bouncing._isPressedDown = true;
                }

                // If the trap is not pressed down, try pushing the entity
                else if (!bouncing._isPressedDown)
                {
                    // This will be unset, if the entity gets pushed
                    bouncing._isPressedDown = true;
                    bouncing.TryPushTarget(actor.GetTransform(), context.transform);
                }

                // otherwise, an entity has already been on top of us, so do nothing
            }

            return(true); // Keep this listener
        }
        private static void HitEntered(Entity projectile, CellMovementContext context)
        {
            if (!projectile.IsDead() &&
                !context.actor.IsDead() &&
                context.transform.layer.HasEitherFlag(projectile.GetProjectileComponent().targetedLayer))
            {
                projectile.GetStats().Get(Attack.Index, out var attack);

                if (context.actor.TryBeAttacked(projectile, attack, projectile.GetTransform().orientation))
                {
                    projectile.Die(); // For now, just die. Add a do chain later.
                }
            }
        }
Beispiel #3
0
        public static bool Leave(Entity actor, CellMovementContext context)
        {
            if (!actor.TryGetBouncing(out var bouncing) || actor.IsDead())
            {
                return(false);
            }

            if (actor.IsCurrentOrderFavorable() &&
                World.Global.Grid.HasNoUndirectedTransformAt(context.initialPosition, _targetedLayer))
            {
                bouncing._isPressedDown = false;
            }

            return(true);
        }
Beispiel #4
0
        public static bool Enter(Entity actor, CellMovementContext context)
        {
            if (!actor.TryGetSlipperyComponent(out var slippery) || actor.IsDead())
            {
                return(false);
            }

            // TODO: check stats
            if (context.transform.layer.HasEitherFlag(TargetedLayer) && context.HasNotMoved())
            {
                SlidingEntityModifier.TryApplyTo(context.transform, context.direction);
            }

            return(true);
        }
        public bool Enter(Entity actor, CellMovementContext ctx)
        {
            if (!actor.TryGetPinningComponent(out var pinning) || actor.IsDead())
            {
                return(false); // Remove this listener
            }

            if (ctx.actor.HasPinnedEntityModifier() || ctx.HasMoved())
            {
                return(true);
            }

            actor.GetStats().GetLazy(Stat.PinStat.Index, out var pinStat);

            if (ctx.actor.CanNotResist(Stat.PinStat.Source, pinStat.power))
            {
                PinnedEntityModifier.AddTo(ctx.actor, pinStat.amount, actor);
                PinnedEntityModifier.Preset(ctx.actor);
            }
            return(true);
        }