static FallingBlockParticlesModSystem()
        {
            dustParticles             = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.3f, 0.3f, EnumParticleModel.Quad);
            dustParticles.AddQuantity = 5;
            dustParticles.MinVelocity.Set(-0.05f, -0.4f, -0.05f);
            dustParticles.AddVelocity.Set(0.1f, 0.2f, 0.1f);
            dustParticles.WithTerrainCollision = true;
            dustParticles.ParticleModel        = EnumParticleModel.Quad;
            dustParticles.OpacityEvolve        = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -16f);
            dustParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 3f);
            dustParticles.GravityEffect        = 0;
            dustParticles.MaxSize       = 1.3f;
            dustParticles.LifeLength    = 3f;
            dustParticles.SelfPropelled = true;
            dustParticles.AddPos.Set(1.4, 1.4, 1.4);


            bitsParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
            bitsParticles.AddPos.Set(1.4, 1.4, 1.4);
            bitsParticles.AddQuantity = 20;
            bitsParticles.MinVelocity.Set(-0.25f, 0, -0.25f);
            bitsParticles.AddVelocity.Set(0.5f, 1, 0.5f);
            bitsParticles.WithTerrainCollision = true;
            bitsParticles.ParticleModel        = EnumParticleModel.Cube;
            bitsParticles.LifeLength           = 1.5f;
            bitsParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.5f);
            bitsParticles.GravityEffect        = 2.5f;
            bitsParticles.MinSize = 0.5f;
            bitsParticles.MaxSize = 1.5f;
        }
        protected override void didTeleport(Entity entity)
        {
            if (entity is EntityPlayer)
            {
                manager.DidTranslocateServer((entity as EntityPlayer).Player as IServerPlayer);
            }

            activated = false;

            ownBlock.teleportParticles.MinPos.Set(Pos.X, Pos.Y, Pos.Z);
            ownBlock.teleportParticles.AddPos.Set(1, 1.8, 1);
            ownBlock.teleportParticles.MinVelocity.Set(-1, -1, -1);
            ownBlock.teleportParticles.AddVelocity.Set(2, 2, 2);
            ownBlock.teleportParticles.MinQuantity = 150;
            ownBlock.teleportParticles.AddQuantity = 0.5f;


            int r = 53;
            int g = 221;
            int b = 172;

            ownBlock.teleportParticles.Color = (r << 16) | (g << 8) | (b << 0) | (100 << 24);

            ownBlock.teleportParticles.BlueEvolve    = null;
            ownBlock.teleportParticles.RedEvolve     = null;
            ownBlock.teleportParticles.GreenEvolve   = null;
            ownBlock.teleportParticles.MinSize       = 0.1f;
            ownBlock.teleportParticles.MaxSize       = 0.2f;
            ownBlock.teleportParticles.SizeEvolve    = null;
            ownBlock.teleportParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -10f);

            Api.World.SpawnParticles(ownBlock.teleportParticles);
        }
Beispiel #3
0
        static ItemKnife()
        {
            particlesStab = new SimpleParticleProperties(
                1, 1,
                ColorUtil.ToRgba(50, 220, 220, 220),
                new Vec3d(),
                new Vec3d(),
                new Vec3f(-0.1f, -0.1f, -0.1f),
                new Vec3f(0.1f, 0.1f, 0.1f),
                1.5f,
                0,
                0.5f,
                0.75f,
                EnumParticleModel.Cube
                );

            particlesStab.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f);
            particlesStab.AddPos.Set(0.1f, 0.1f, 0.1f);
            particlesStab.addLifeLength        = 0.5f;
            particlesStab.RandomVelocityChange = true;
            particlesStab.MinQuantity          = 200;
            particlesStab.AddQuantity          = 50;
            particlesStab.MinSize       = 0.2f;
            particlesStab.ParticleModel = EnumParticleModel.Quad;
            particlesStab.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, -150);
        }
Beispiel #4
0
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            base.Initialize(api, properties);

            bepu = Blockentity as BEPulverizer;


            Matrixf mat = bepu.mat;

            leftOffset  = mat.TransformVector(new Vec4f(4.5f / 16f - 0.5f, 4 / 16f, -4.5f / 16f, 0f));
            rightOffset = mat.TransformVector(new Vec4f(11.5f / 16f - 0.5f, 4 / 16f, -4.5f / 16f, 0f));


            slideDustParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.2f, EnumParticleModel.Quad);
            slideDustParticles.AddPos.Set(2 / 32f, 1 / 32f, 2 / 32f);
            slideDustParticles.WithTerrainCollision = false;
            slideDustParticles.ParticleModel        = EnumParticleModel.Quad;
            slideDustParticles.LifeLength           = 0.75f;
            slideDustParticles.SelfPropelled        = true;
            slideDustParticles.GravityEffect        = 0f;
            slideDustParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 0.4f);
            slideDustParticles.OpacityEvolve        = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -16f);
            slideDustParticles.MinQuantity          = 1;
            slideDustParticles.AddQuantity          = 3;

            Vec4f vec = mat.TransformVector(new Vec4f(-0.1f, -0.1f, 0.2f, 0f));

            slideDustParticles.MinVelocity.Set(vec.X, vec.Y, vec.Z);

            vec = mat.TransformVector(new Vec4f(0.2f, -0.05f, 0.2f, 0f));
            slideDustParticles.AddVelocity.Set(vec.X, vec.Y, vec.Z);

            leftSlidePos  = mat.TransformVector(new Vec4f(4.5f / 16f - 0.5f, 4 / 16f, -2.5f / 16f, 0f)).XYZ.ToVec3d().Add(Position).Add(0.5, 0, 0.5);
            rightSlidePos = mat.TransformVector(new Vec4f(11.5f / 16f - 0.5f, 4 / 16f, -2.5f / 16f, 0f)).XYZ.ToVec3d().Add(Position).Add(0.5, 0, 0.5);
        }
        public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            if (byEntity.World is IClientWorldAccessor)
            {
                ModelTransform tf = new ModelTransform();
                tf.EnsureDefaultValues();

                tf.Origin.Set(0, -0.1f, 0);
                tf.Rotation.Z = Math.Min(30, secondsUsed * 40);
                byEntity.Controls.UsingHeldItemTransformAfter = tf;

                if (secondsUsed > 0.6)
                {
                    Vec3d pos =
                        byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight, 0)
                        .Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw)
                    ;

                    Vec3f speedVec = new Vec3d(0, 0, 0).Ahead(5, byEntity.Pos.Pitch, byEntity.Pos.Yaw).ToVec3f();
                    particles.MinVelocity = speedVec;
                    Random rand = new Random();
                    particles.Color  = ColorUtil.ToRgba(255, 176, 176, 176);
                    particles.MinPos = pos.AddCopy(-0.05, -0.05, -0.05);
                    particles.AddPos.Set(0.1, 0.1, 0.1);
                    particles.MinSize    = 0.1F;
                    particles.MaxSize    = 0.5f;
                    particles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 1);
                    byEntity.World.SpawnParticles(particles);
                }
            }
            return(true);
        }
Beispiel #6
0
        public static SimpleParticleProperties TemporalEffectAtPos(this BlockPos pos, ICoreAPI api)
        {
            SimpleParticleProperties p = TemporalEffect;
            Vec3d posvec = pos.DownCopy().MidPoint();
            int   r      = 53;
            int   g      = 221;
            int   b      = 172;

            p.Color = (r << 16) | (g << 8) | (b << 0) | (50 << 24);

            p.AddPos.Set(0, 0, 0);
            p.BlueEvolve    = null;
            p.RedEvolve     = null;
            p.GreenEvolve   = null;
            p.MinSize       = 0.1f;
            p.MaxSize       = 0.2f;
            p.SizeEvolve    = null;
            p.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 100f);

            double xpos = rndPos.nextFloat();
            double ypos = 1.9 + api.World.Rand.NextDouble() * 0.2;
            double zpos = rndPos.nextFloat();

            p.LifeLength = GameMath.Sqrt(xpos * xpos + zpos * zpos) / 10;
            p.MinPos.Set(posvec.X + xpos, posvec.Y + ypos, posvec.Z + zpos);
            p.MinVelocity.Set(-(float)xpos, -1 - (float)api.World.Rand.NextDouble() / 2, -(float)zpos);
            p.MinQuantity = 0.25f;
            p.AddQuantity = 0;

            return(p);
        }
        public override void OnAsyncClientParticleTick(IAsyncParticleManager manager, BlockPos pos, float windAffectednessAtPos, float secondsTicking)
        {
            if (api.World.Rand.NextDouble() > particleQuantity)
            {
                return;
            }

            AdvancedParticleProperties bps = ParticleProperties[0];

            bps.basePos.X = pos.X;
            bps.basePos.Y = pos.Y;
            bps.basePos.Z = pos.Z;

            bps.Velocity[0].avg = (float)PushVector.X * 500;
            bps.Velocity[1].avg = (float)PushVector.Y * 1000;
            bps.Velocity[2].avg = (float)PushVector.Z * 500;

            bps.GravityEffect.avg = 0.5f;

            bps.HsvaColor[3].avg = 180 * Math.Min(1, secondsTicking / 7f);
            bps.Quantity.avg     = 1;

            bps.PosOffset[1].avg = 2 / 16f;
            bps.PosOffset[1].var = LiquidLevel / 8f * 0.75f;
            bps.SwimOnLiquid     = true;

            bps.Size.avg   = 0.05f;
            bps.Size.var   = 0f;
            bps.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 0.8f);

            manager.Spawn(bps);
        }
Beispiel #8
0
        static BlockEntityQuern()
        {
            // 1..20 per tick
            FlourParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
            FlourParticles.AddPos.Set(1 + 2 / 32f, 0, 1 + 2 / 32f);
            FlourParticles.AddQuantity = 20;
            FlourParticles.MinVelocity.Set(-0.25f, 0, -0.25f);
            FlourParticles.AddVelocity.Set(0.5f, 1, 0.5f);
            FlourParticles.WithTerrainCollision = true;
            FlourParticles.ParticleModel        = EnumParticleModel.Cube;
            FlourParticles.LifeLength           = 1.5f;
            FlourParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.4f);

            // 1..5 per tick
            FlourDustParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
            FlourDustParticles.AddPos.Set(1 + 2 / 32f, 0, 1 + 2 / 32f);
            FlourDustParticles.AddQuantity = 5;
            FlourDustParticles.MinVelocity.Set(-0.05f, 0, -0.05f);
            FlourDustParticles.AddVelocity.Set(0.1f, 0.2f, 0.1f);
            FlourDustParticles.WithTerrainCollision = false;
            FlourDustParticles.ParticleModel        = EnumParticleModel.Quad;
            FlourDustParticles.LifeLength           = 1.5f;
            FlourDustParticles.SelfPropelled        = true;
            FlourDustParticles.GravityEffect        = 0;
            FlourDustParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 0.4f);
            FlourDustParticles.OpacityEvolve        = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -16f);
        }
        public override void StartClientSide(ICoreClientAPI api)
        {
            this.capi = api;
            this.api  = api;

            clientChannel =
                api.Network.RegisterChannel("gameeffects")
                .RegisterMessageType(typeof(GameEffectsPacket))
                .SetMessageHandler <GameEffectsPacket>(OnGameEffectToggle)
            ;

            blackAirParticles = new SimpleParticleProperties()
            {
                color                = ColorUtil.ToRgba(150, 50, 25, 15),
                model                = EnumParticleModel.Quad,
                minSize              = 0.1f,
                maxSize              = 1f,
                gravityEffect        = 0,
                lifeLength           = 1.2f,
                WithTerrainCollision = false,
                ShouldDieInLiquid    = true,
                minVelocity          = new Vec3f(-5f, 10f, -3f),
                minQuantity          = 1,
                addQuantity          = 0,
            };
            blackAirParticles.addVelocity   = new Vec3f(0f, 30f, 0);
            blackAirParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -8);

            api.Event.RegisterRenderer(this, EnumRenderStage.Before, "gameeffects");
        }
Beispiel #10
0
        static BEMortarAndPestle()
        {
            Vec3d CommonPos = new Vec3d(3 / 32f, 0, 3 / 32f);

            /*
             * FlourParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
             * FlourParticles.addPos.Set(CommonPos);
             * FlourParticles.addQuantity = 20;
             * FlourParticles.minVelocity.Set(-0.25f, 0, -0.25f);
             * FlourParticles.addVelocity.Set(0.5f, 1, 0.5f);
             * FlourParticles.WithTerrainCollision = true;
             * FlourParticles.model = EnumParticleModel.Cube;
             * FlourParticles.lifeLength = 1.5f;
             * FlourParticles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.4f);
             */

            FlourDustParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
            FlourDustParticles.addPos.Set(CommonPos);
            FlourDustParticles.addQuantity = 5;
            FlourDustParticles.minVelocity.Set(-0.05f, 0, -0.05f);
            FlourDustParticles.addVelocity.Set(0.1f, 0.2f, 0.1f);
            FlourDustParticles.WithTerrainCollision = false;
            FlourDustParticles.model         = EnumParticleModel.Quad;
            FlourDustParticles.lifeLength    = 1.5f;
            FlourDustParticles.SelfPropelled = true;
            FlourDustParticles.gravityEffect = 0;
            FlourDustParticles.SizeEvolve    = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 0.4f);
            FlourDustParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -16f);
        }
Beispiel #11
0
        void SpawnParticles(IWorldAccessor world, Vec3d pos, bool final)
        {
            if (final || world.Rand.NextDouble() > 0.8)
            {
                int h = 110 + world.Rand.Next(15);
                int v = 100 + world.Rand.Next(50);
                particlesHeld.MinPos = pos;
                particlesHeld.Color  = ColorUtil.ReverseColorBytes(ColorUtil.HsvToRgba(h, 180, v));

                particlesHeld.MinSize       = 0.2f;
                particlesHeld.ParticleModel = EnumParticleModel.Quad;
                particlesHeld.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, -150);
                particlesHeld.Color         = ColorUtil.ReverseColorBytes(ColorUtil.HsvToRgba(h, 180, v, 150));

                world.SpawnParticles(particlesHeld);
            }
        }
Beispiel #12
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            idleParticles = new SimpleParticleProperties(
                0.5f, 1,
                ColorUtil.ToRgba(150, 34, 47, 44),
                new Vec3d(),
                new Vec3d(),
                new Vec3f(-0.1f, -0.1f, -0.1f),
                new Vec3f(0.1f, 0.1f, 0.1f),
                1.5f,
                0,
                0.5f,
                0.75f,
                EnumParticleModel.Quad
                );

            idleParticles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f);
            idleParticles.addPos.Set(1, 2, 1);
            idleParticles.addLifeLength = 0.5f;
            idleParticles.RedEvolve     = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 80);


            insideParticles = new SimpleParticleProperties(
                0.5f, 1,
                ColorUtil.ToRgba(150, 92, 111, 107),
                new Vec3d(),
                new Vec3d(),
                new Vec3f(-0.2f, -0.2f, -0.2f),
                new Vec3f(0.2f, 0.2f, 0.2f),
                1.5f,
                0,
                0.5f,
                0.75f,
                EnumParticleModel.Quad
                );

            insideParticles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f);
            insideParticles.addPos.Set(1, 2, 1);
            insideParticles.addLifeLength = 0.5f;
        }
Beispiel #13
0
        private void SpawnParticle(int amount, EntityAgent entity)
        {
            for (int i = 0; i < amount; i++)
            {
                Vec3d pos =
                    entity.Pos.XYZ.Add(0, entity.LocalEyePos.Y, 0)
                    .Ahead(1f, entity.Pos.Pitch, entity.Pos.Yaw)
                ;

                Vec3f speedVec = new Vec3d(0, 0, 0).Ahead(5, entity.Pos.Pitch, entity.Pos.Yaw).ToVec3f();
                particles.MinVelocity = speedVec;
                Random rand = new Random();
                particles.Color  = ColorUtil.ToRgba(255, rand.Next(50, 150), rand.Next(50, 150), rand.Next(150, 255));
                particles.MinPos = pos.AddCopy(-0.05, -0.05, -0.05);
                particles.AddPos.Set(0.1, 0.1, 0.1);
                particles.MinSize    = 0.1F;
                particles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.SINUS, 10);
                entity.World.SpawnParticles(particles);
            }
        }
Beispiel #14
0
        public override void OnLoaded(ICoreAPI api)
        {
            base.OnLoaded(api);

            particlesHeld = new SimpleParticleProperties(
                1, 1,
                ColorUtil.ToRgba(50, 220, 220, 220),
                new Vec3d(),
                new Vec3d(),
                new Vec3f(-0.1f, -0.1f, -0.1f),
                new Vec3f(0.1f, 0.1f, 0.1f),
                1.5f,
                0,
                0.5f,
                0.75f,
                EnumParticleModel.Cube
                );

            particlesHeld.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f);
            particlesHeld.addPos.Set(0, 0, 0);
            particlesHeld.addLifeLength = 0.5f;
        }
        public override void OnAsyncClientParticleTick(IAsyncParticleManager manager, BlockPos pos, float windAffectednessAtPos, float secondsTicking)
        {
            if (ParticleProperties != null && ParticleProperties.Length > 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (api.World.Rand.NextDouble() > particleQuantity)
                    {
                        continue;
                    }

                    BlockFacing facing = BlockFacing.HORIZONTALS[i];
                    Block       block  = manager.BlockAccess.GetBlock(pos.X + facing.Normali.X, pos.Y, pos.Z + facing.Normali.Z);
                    if (block.IsLiquid() || block.SideSolid[facing.Opposite.Index])
                    {
                        continue;
                    }

                    AdvancedParticleProperties bps = ParticleProperties[i];
                    bps.basePos.X       = pos.X + TopMiddlePos.X;
                    bps.basePos.Y       = pos.Y;
                    bps.basePos.Z       = pos.Z + TopMiddlePos.Z;
                    bps.WindAffectednes = windAffectednessAtPos * 0.25f;

                    bps.HsvaColor[3].avg = 180 * Math.Min(1, secondsTicking / 7f);
                    bps.Quantity.avg     = 1;
                    bps.Velocity[1].avg  = -0.4f;
                    bps.Velocity[0].avg  = API.Config.GlobalConstants.CurrentWindSpeedClient.X * windAffectednessAtPos;
                    bps.Velocity[2].avg  = API.Config.GlobalConstants.CurrentWindSpeedClient.Z * windAffectednessAtPos;

                    bps.Size.avg   = 0.05f;
                    bps.Size.var   = 0f;
                    bps.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 0.8f);

                    manager.Spawn(bps);
                }
            }
        }
Beispiel #16
0
        static BEBehaviorMPPulverizer()
        {
            float dustMinQ      = 1;
            float dustAddQ      = 5;
            float flourPartMinQ = 1;
            float flourPartAddQ = 20;

            // 1..20 per tick
            bitsParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.4f, EnumParticleModel.Quad);
            bitsParticles.AddPos.Set(2 / 32f, 1 / 32f, 2 / 32f);
            bitsParticles.AddQuantity = 20;
            bitsParticles.MinVelocity.Set(-1f, 0, -1f);
            bitsParticles.AddVelocity.Set(2f, 2, 2f);
            bitsParticles.WithTerrainCollision = false;
            bitsParticles.ParticleModel        = EnumParticleModel.Cube;
            bitsParticles.LifeLength           = 1.5f;
            bitsParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.4f);
            bitsParticles.AddQuantity          = flourPartAddQ;
            bitsParticles.MinQuantity          = flourPartMinQ;

            // 1..5 per tick
            dustParticles = new SimpleParticleProperties(1, 3, ColorUtil.ToRgba(40, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, -0.25f, -0.25f), new Vec3f(0.25f, 0.25f, 0.25f), 1, 1, 0.1f, 0.3f, EnumParticleModel.Quad);
            dustParticles.AddPos.Set(2 / 32f, 1 / 32f, 2 / 32f);
            dustParticles.AddQuantity = 5;
            dustParticles.MinVelocity.Set(-0.1f, 0, -0.1f);
            dustParticles.AddVelocity.Set(0.2f, 0.1f, 0.2f);
            dustParticles.WithTerrainCollision = false;
            dustParticles.ParticleModel        = EnumParticleModel.Quad;
            dustParticles.LifeLength           = 1.5f;
            dustParticles.SelfPropelled        = true;
            dustParticles.GravityEffect        = 0;
            dustParticles.SizeEvolve           = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, 0.4f);
            dustParticles.OpacityEvolve        = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -16f);
            dustParticles.MinQuantity          = dustMinQ;
            dustParticles.AddQuantity          = dustAddQ;
        }
Beispiel #17
0
        private void OnClientGameTick(float dt)
        {
            if (block == null || api?.World == null || !canTeleport || !Activated)
            {
                return;
            }

            bool playerInside = (api.World.ElapsedMilliseconds > 100 && api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer < 100);

            SimpleParticleProperties currentParticles = playerInside ?
                                                        block.insideParticles :
                                                        block.idleParticles
            ;

            if (playerInside)
            {
                animUtil.StartAnimation(new AnimationMetaData()
                {
                    Animation = "idle", Code = "idle", AnimationSpeed = 1, EaseInSpeed = 100, EaseOutSpeed = 100, BlendMode = EnumAnimationBlendMode.Average
                });
                animUtil.StartAnimation(new AnimationMetaData()
                {
                    Animation = "teleport", Code = "teleport", AnimationSpeed = 1, EaseInSpeed = 8, EaseOutSpeed = 8, BlendMode = EnumAnimationBlendMode.Add
                });
            }
            else
            {
                animUtil.StopAnimation("teleport");
            }

            if (api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer > 3000)
            {
                animUtil.StopAnimation("idle");
            }

            //int color = temporalGearStack.Collectible.GetRandomColor(api as ICoreClientAPI, temporalGearStack); - not working o.O

            int r = 53;
            int g = 221;
            int b = 172;

            currentParticles.color = (r << 16) | (g << 8) | (b << 0) | (50 << 24);

            currentParticles.addPos.Set(0, 0, 0);
            currentParticles.BlueEvolve    = null;
            currentParticles.RedEvolve     = null;
            currentParticles.GreenEvolve   = null;
            currentParticles.minSize       = 0.1f;
            currentParticles.maxSize       = 0.2f;
            currentParticles.SizeEvolve    = null;
            currentParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 100f);

            double xpos = rndPos.nextFloat();
            double ypos = 1.9 + api.World.Rand.NextDouble() * 0.2;
            double zpos = rndPos.nextFloat();

            currentParticles.lifeLength = GameMath.Sqrt(xpos * xpos + zpos * zpos) / 10;
            currentParticles.minPos.Set(posvec.X + xpos, posvec.Y + ypos, posvec.Z + zpos);
            currentParticles.minVelocity.Set(-(float)xpos, -1 - (float)api.World.Rand.NextDouble() / 2, -(float)zpos);
            currentParticles.minQuantity = playerInside ? 2 : 0.25f;
            currentParticles.addQuantity = 0;

            api.World.SpawnParticles(currentParticles);
        }
        void initSoundsAndEffects()
        {
            capi   = entity.Api as ICoreClientAPI;
            isSelf = capi.World.Player.Entity.EntityId == entity.EntityId;
            if (!isSelf)
            {
                return;
            }

            // Effects
            fogNoise = NormalizedSimplexNoise.FromDefaultOctaves(4, 1, 0.9, 123);

            rustParticles = new SimpleParticleProperties()
            {
                Color                = ColorUtil.ToRgba(150, 50, 25, 15),
                ParticleModel        = EnumParticleModel.Quad,
                MinSize              = 0.1f,
                MaxSize              = 0.5f,
                GravityEffect        = 0,
                LifeLength           = 2f,
                WithTerrainCollision = false,
                ShouldDieInLiquid    = false,
                RandomVelocityChange = true,
                MinVelocity          = new Vec3f(-1f, -1f, -1f),
                AddVelocity          = new Vec3f(2f, 2f, 2f),
                MinQuantity          = 1,
                AddQuantity          = 0,
            };

            rustParticles.AddVelocity   = new Vec3f(0f, 30f, 0);
            rustParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -8);


            float b = 0.25f;

            capi.Ambient.CurrentModifiers["brownrainandfog"] = rainfogAmbient = new AmbientModifier()
            {
                AmbientColor = new WeightedFloatArray(new float[] { 0.5f * 132 / 255f, 0.5f * 115 / 255f, 0.5f * 112f / 255f, 1 }, 0),
                FogColor     = new WeightedFloatArray(new float[] { b * 132 / 255f, b * 115 / 255f, b * 112f / 255f, 1 }, 0),
                FogDensity   = new WeightedFloat(0.05f, 0),
            }.EnsurePopulated();



            // Sounds
            tempStabSoundDrain = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-drain.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });

            tempStabSoundLow = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-low.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });

            tempStabSoundVeryLow = capi.World.LoadSound(new SoundParams()
            {
                Location         = new AssetLocation("sounds/effect/tempstab-verylow.ogg"),
                ShouldLoop       = true,
                RelativePosition = true,
                DisposeOnFinish  = false,
                SoundType        = EnumSoundType.SoundGlitchunaffected,
                Volume           = 0f
            });
        }
 static ExplosionParticles()
 {
     ExplosionFireParticles.RedEvolve     = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, -255f);
     ExplosionFireParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -12.4f);
     ExplosionFireParticles.AddPos.Set(1, 1, 1);
 }
        void HandleTeleporting(float dt)
        {
            toremove.Clear();

            bool wasTeleporting = somebodyIsTeleporting;

            somebodyIsTeleporting &= tpingEntities.Count > 0;

            foreach (var val in tpingEntities)
            {
                if (val.Value.Entity.Teleporting)
                {
                    continue;
                }

                val.Value.SecondsPassed += Math.Min(0.5f, dt);

                if (Api.World.ElapsedMilliseconds - val.Value.LastCollideMs > 100)
                {
                    // Make sure its not just server lag
                    Block block = Api.World.CollisionTester.GetCollidingBlock(Api.World.BlockAccessor, val.Value.Entity.CollisionBox, val.Value.Entity.Pos.XYZ, true);
                    if (!(block is BlockStaticTranslocator))
                    {
                        toremove.Add(val.Key);
                        continue;
                    }
                }

                if (val.Value.SecondsPassed > 0.1 && !somebodyIsTeleporting)
                {
                    somebodyIsTeleporting = true;
                    MarkDirty();
                }

                if (val.Value.SecondsPassed > 1.5 && tpLocation != null)
                {
                    // Preload the chunk
                    IWorldChunk chunk = sapi.World.BlockAccessor.GetChunkAtBlockPos(tpLocation);
                    if (chunk != null)
                    {
                        chunk.MapChunk.MarkFresh();
                    }
                    else
                    {
                        sapi.WorldManager.LoadChunkColumnPriority((int)tpLocation.X / Api.World.BlockAccessor.ChunkSize, (int)tpLocation.Z / Api.World.BlockAccessor.ChunkSize, new ChunkLoadOptions()
                        {
                            KeepLoaded = false
                        });
                    }
                }

                if (val.Value.SecondsPassed > 4.4 && tpLocation != null)
                {
                    val.Value.Entity.TeleportTo(tpLocation.ToVec3d().Add(-0.3, 1, -0.3)); // Fugly, need some better exit pos thing

                    Entity e = val.Value.Entity;
                    if (e is EntityPlayer)
                    {
                        Api.World.Logger.Debug("Teleporting player {0} to {1}", (e as EntityPlayer).GetBehavior <EntityBehaviorNameTag>().DisplayName, tpLocation);
                        manager.DidTranslocateServer((e as EntityPlayer).Player as IServerPlayer);
                    }
                    else
                    {
                        Api.World.Logger.Debug("Teleporting entity {0} to {1}", e.Code, tpLocation);
                    }

                    toremove.Add(val.Key);

                    activated             = false;
                    somebodyIsTeleporting = false;
                    somebodyDidTeleport   = true;

                    ownBlock.teleportParticles.MinPos.Set(Pos.X, Pos.Y, Pos.Z);
                    ownBlock.teleportParticles.AddPos.Set(1, 1.8, 1);
                    ownBlock.teleportParticles.MinVelocity.Set(-1, -1, -1);
                    ownBlock.teleportParticles.AddVelocity.Set(2, 2, 2);
                    ownBlock.teleportParticles.MinQuantity = 150;
                    ownBlock.teleportParticles.AddQuantity = 0.5f;


                    int r = 53;
                    int g = 221;
                    int b = 172;
                    ownBlock.teleportParticles.Color = (r << 16) | (g << 8) | (b << 0) | (100 << 24);

                    ownBlock.teleportParticles.BlueEvolve    = null;
                    ownBlock.teleportParticles.RedEvolve     = null;
                    ownBlock.teleportParticles.GreenEvolve   = null;
                    ownBlock.teleportParticles.MinSize       = 0.1f;
                    ownBlock.teleportParticles.MaxSize       = 0.2f;
                    ownBlock.teleportParticles.SizeEvolve    = null;
                    ownBlock.teleportParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -10f);


                    Api.World.SpawnParticles(ownBlock.teleportParticles);


                    MarkDirty();
                }
            }

            foreach (long entityid in toremove)
            {
                tpingEntities.Remove(entityid);
            }

            if (wasTeleporting && !somebodyIsTeleporting)
            {
                MarkDirty();
            }
        }
Beispiel #21
0
        public void Render(float dt)
        {
            GameTick(dt);

            capi.Render.CurrentActiveShader.Uniform("color", color);
            capi.Render.CurrentActiveShader.Uniform("lineWidth", linewidth);

            var   plr    = capi.World.Player;
            Vec3d camPos = plr.Entity.CameraPos;

            capi.Render.CurrentActiveShader.Uniform("origin", new Vec3f((float)(origin.X - camPos.X), (float)(origin.Y - camPos.Y), (float)(origin.Z - camPos.Z)));

            double cntRel = GameMath.Clamp(secondsAlive * 10, 0, 1);

            int instanceCount = (int)(cntRel * points.Count) - 1;

            if (instanceCount > 0)
            {
                capi.Render.RenderMeshInstanced(quadRef, instanceCount);
            }

            if (cntRel >= 0.9 && !soundPlayed)
            {
                soundPlayed = true;
                var   lp   = points[points.Count - 1];
                Vec3d pos  = origin + lp;
                float dist = (float)plr.Entity.Pos.DistanceTo(pos);

                if (dist < 150)
                {
                    var loc = new AssetLocation("sounds/weather/lightning-nodistance.ogg");
                    capi.World.PlaySoundAt(loc, 0, 0, 0, null, EnumSoundType.Weather, 1, 32, Math.Max(0.1f, 1 - dist / 70));
                }

                if (dist < 100)
                {
                    (weatherSys as WeatherSystemClient).simLightning.lightningTime      = 0.3f + (float)rand.NextDouble() * 0.17f;
                    (weatherSys as WeatherSystemClient).simLightning.lightningIntensity = 1.5f + (float)rand.NextDouble() * 0.4f;

                    int sub = Math.Max(0, (int)dist - 5) * 3;

                    int color = ColorUtil.ToRgba(255, 255, 255, 200);

                    SimpleParticleProperties props = new SimpleParticleProperties(500 / 2 - sub, 600 / 2 - sub, color, pos.AddCopy(-0.5f, 0, -0.5f), pos.AddCopy(0.5f, 1f, 0.5f), new Vec3f(-5, 0, -5), new Vec3f(5, 10, 5), 3, 0.3f, 0.4f, 2f);
                    props.VertexFlags       = 255;
                    props.ShouldDieInLiquid = true;
                    props.SizeEvolve        = EvolvingNatFloat.create(EnumTransformFunction.LINEARREDUCE, 1f);

                    capi.World.SpawnParticles(props);

                    props.ParticleModel = EnumParticleModel.Quad;
                    props.MinSize      /= 2f;
                    props.MaxSize      /= 2f;
                    capi.World.SpawnParticles(props);
                }
            }

            flashAccum += dt;
            if (flashAccum > rndVal)
            {
                rndVal     = (float)rand.NextDouble() / 10;
                flashAccum = 0;
                float bnorm = (float)rand.NextDouble();
                float b     = 50 + bnorm * 150;
                pointLights[0].Color.Set(b, b, b);

                linewidth = (0.4f + 0.6f * bnorm) / 3f;

                if (cntRel < 1)
                {
                    b = 0;
                }
                pointLights[1].Color.Set(b, b, b);
            }
        }
        private void OnClientGameTick(float dt)
        {
            if (ownBlock == null || Api?.World == null || !canTeleport || !Activated)
            {
                return;
            }

            if (Api.World.ElapsedMilliseconds - somebodyIsTeleportingReceivedTotalMs > 6000)
            {
                somebodyIsTeleporting = false;
            }

            HandleSoundClient(dt);

            bool selfInside   = (Api.World.ElapsedMilliseconds > 100 && Api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer < 100);
            bool playerInside = selfInside || somebodyIsTeleporting;
            bool active       = animUtil.activeAnimationsByAnimCode.ContainsKey("teleport");

            if (!selfInside && playerInside)
            {
                manager.lastTranslocateCollideMsOtherPlayer = Api.World.ElapsedMilliseconds;
            }

            SimpleParticleProperties currentParticles = active ?
                                                        ownBlock.insideParticles :
                                                        ownBlock.idleParticles
            ;

            if (playerInside)
            {
                var meta = new AnimationMetaData()
                {
                    Animation = "teleport", Code = "teleport", AnimationSpeed = 1, EaseInSpeed = 1, EaseOutSpeed = 2, Weight = 1, BlendMode = EnumAnimationBlendMode.Add
                };
                animUtil.StartAnimation(meta);
                animUtil.StartAnimation(new AnimationMetaData()
                {
                    Animation = "idle", Code = "idle", AnimationSpeed = 1, EaseInSpeed = 1, EaseOutSpeed = 1, Weight = 1, BlendMode = EnumAnimationBlendMode.Average
                });
            }
            else
            {
                animUtil.StopAnimation("teleport");
            }


            if (animUtil.activeAnimationsByAnimCode.Count > 0 && Api.World.ElapsedMilliseconds - lastCollideMsOwnPlayer > 10000 && Api.World.ElapsedMilliseconds - manager.lastTranslocateCollideMsOtherPlayer > 10000)
            {
                animUtil.StopAnimation("idle");
            }


            //int color = temporalGearStack.Collectible.GetRandomColor(api as ICoreClientAPI, temporalGearStack); - not working o.O

            int r = 53;
            int g = 221;
            int b = 172;

            currentParticles.Color = (r << 16) | (g << 8) | (b << 0) | (50 << 24);

            currentParticles.AddPos.Set(0, 0, 0);
            currentParticles.BlueEvolve    = null;
            currentParticles.RedEvolve     = null;
            currentParticles.GreenEvolve   = null;
            currentParticles.MinSize       = 0.1f;
            currentParticles.MaxSize       = 0.2f;
            currentParticles.SizeEvolve    = null;
            currentParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, 100f);


            bool rot = Block.Variant["side"] == "east" || Block.Variant["side"] == "west";

            particleAngle = active ? particleAngle + 5 * dt : 0;


            double dx = GameMath.Cos(particleAngle + (rot ? GameMath.PIHALF : 0)) * 0.35f;
            double dy = 1.9 + Api.World.Rand.NextDouble() * 0.2;
            double dz = GameMath.Sin(particleAngle + (rot ? GameMath.PIHALF : 0)) * 0.35f;

            currentParticles.LifeLength = GameMath.Sqrt(dx * dx + dz * dz) / 10;
            currentParticles.MinPos.Set(posvec.X + dx, posvec.Y + dy, posvec.Z + dz);
            currentParticles.MinVelocity.Set(-(float)dx / 2, -1 - (float)Api.World.Rand.NextDouble() / 2, -(float)dz / 2);
            currentParticles.MinQuantity = active ? 3 : 0.25f;
            currentParticles.AddVelocity.Set(0, 0, 0);
            currentParticles.AddQuantity = 0.5f;

            Api.World.SpawnParticles(currentParticles);

            currentParticles.MinPos.Set(posvec.X - dx, posvec.Y + dy, posvec.Z - dz);
            currentParticles.MinVelocity.Set((float)dx / 2, -1 - (float)Api.World.Rand.NextDouble() / 2, (float)dz / 2);
            Api.World.SpawnParticles(currentParticles);
        }