private void onPhysicsTickCallback(float dtFac)
        {
            if (ShouldDespawn || !Alive)
            {
                return;
            }
            if (World is IClientWorldAccessor || World.ElapsedMilliseconds <= msCollide + 500)
            {
                return;
            }

            Cuboidd projectileBox = CollisionBox.ToDouble().Translate(ServerPos.X, ServerPos.Y, ServerPos.Z);

            if (ServerPos.Motion.X < 0)
            {
                projectileBox.X1 += ServerPos.Motion.X * dtFac;
            }
            else
            {
                projectileBox.X2 += ServerPos.Motion.X * dtFac;
            }
            if (ServerPos.Motion.Y < 0)
            {
                projectileBox.Y1 += ServerPos.Motion.Y * dtFac;
            }
            else
            {
                projectileBox.Y2 += ServerPos.Motion.Y * dtFac;
            }
            if (ServerPos.Motion.Z < 0)
            {
                projectileBox.Z1 += ServerPos.Motion.Z * dtFac;
            }
            else
            {
                projectileBox.Z2 += ServerPos.Motion.Z * dtFac;
            }

            ep.WalkEntities(ServerPos.XYZ, 5f, (e) => {
                if (e.EntityId == this.EntityId || !e.IsInteractable)
                {
                    return(false);
                }
                Cuboidd eBox = e.CollisionBox.ToDouble().Translate(e.ServerPos.X, e.ServerPos.Y, e.ServerPos.Z);
                if (eBox.IntersectsOrTouches(projectileBox))
                {
                    if (FiredBy != null && e.EntityId == FiredBy.EntityId && World.ElapsedMilliseconds - msLaunch < 500)
                    {
                        return(true);
                    }

                    impactOnEntity(e);

                    return(false);
                }
                return(true);
            });
        }
Beispiel #2
0
        bool entityInRange()
        {
            if (stopRange <= 0)
            {
                return(false);
            }

            bool found = false;

            partitionUtil.WalkEntities(entity.ServerPos.XYZ, stopRange, (e) => {
                if (!e.Alive || !e.IsInteractable || e.EntityId == this.entity.EntityId)
                {
                    return(true);
                }

                for (int i = 0; i < stopOnNearbyEntityCodesExact.Length; i++)
                {
                    if (e.Code.Path == stopOnNearbyEntityCodesExact[i])
                    {
                        if (e.Code.Path == "player")
                        {
                            IPlayer player = entity.World.PlayerByUid(((EntityPlayer)e).PlayerUID);
                            if (player == null || (player.WorldData.CurrentGameMode != EnumGameMode.Creative && player.WorldData.CurrentGameMode != EnumGameMode.Spectator))
                            {
                                found = true;
                                return(false);
                            }

                            return(false);
                        }

                        found = true;
                        return(false);
                    }
                }

                for (int i = 0; i < stopOnNearbyEntityCodesBeginsWith.Length; i++)
                {
                    if (e.Code.Path.StartsWithFast(stopOnNearbyEntityCodesBeginsWith[i]))
                    {
                        found = true;
                        return(false);
                    }
                }

                return(true);
            });

            return(found);
        }