Beispiel #1
0
        public override void OnGameTick(float deltaTime)
        {
            base.OnGameTick(deltaTime);

            if (this.Api.Side == EnumAppSide.Server)
            {
                elapsedTimeInMilliseconds = this.Api.World.ElapsedMilliseconds;

                if (elapsedTimeInMilliseconds - spawnTimeInMilliseconds > currentLifespan)
                {
                    //-- Combusted, in this case, represents the meteor exploding in mid-air --//
                    this.Die(EnumDespawnReason.Combusted);
                }
                else if (this.World.CollisionTester.IsColliding(this.World.BlockAccessor, this.CollisionBox, this.ServerPos.XYZ, false))
                {
                    EnumBlockMaterial material = this.World.BlockAccessor.GetBlock(this.ServerPos.XYZ.AsBlockPos).BlockMaterial;

                    //-- Don't kill the entity on plant matter, causing the meteor to explode. It just looks silly... --//
                    if (material != EnumBlockMaterial.Plant && material != EnumBlockMaterial.Wood && material != EnumBlockMaterial.Leaves && material != EnumBlockMaterial.Air)
                    {
                        //-- Death represents the meteor colliding with terrain and creating a crater --//
                        this.Die(EnumDespawnReason.Death);
                    }
                }
            }
        }
        public override void OnGameTick(float deltaTime)
        {
            base.OnGameTick(deltaTime);

            if (this.Api.Side == EnumAppSide.Server)
            {
                ElapsedLifetime = this.Api.World.ElapsedMilliseconds;

                if (ElapsedLifetime - MeteorSpawnTime > CurrentLifespan)
                {
                    //-- Fire, in this case, represents the meteor exploding in mid-air --//
                    this.Die(EnumDespawnReason.Death, new DamageSource()
                    {
                        Type = EnumDamageType.Fire
                    });
                }
                else if (this.World.CollisionTester.IsColliding(this.World.BlockAccessor, this.CollisionBox, this.ServerPos.XYZ, false))
                {
                    EnumBlockMaterial material = this.World.BlockAccessor.GetBlock(this.ServerPos.XYZ.AsBlockPos, BlockLayersAccess.SolidBlocks).BlockMaterial;

                    //-- Don't kill the entity on plant matter, causing the meteor to explode. It just looks silly... --//
                    if (material != EnumBlockMaterial.Plant && material != EnumBlockMaterial.Wood && material != EnumBlockMaterial.Leaves && material != EnumBlockMaterial.Air)
                    {
                        //-- Gravity represents the meteor colliding with terrain and creating a crater --//
                        this.Die(EnumDespawnReason.Death, new DamageSource()
                        {
                            Type = EnumDamageType.Gravity
                        });
                    }
                }
            }
        }
        public PhysicsBlock getFrictionTableElement(ICoreAPI api, EnumBlockMaterial material)
        {
            PhysicsModConfig config = api.ModLoader.GetModSystem <BlockPhysicsMod>().Config;

            if (config.FrictionTable.TryGetValue(material, out double friction))
            {
                return(new PhysicsBlock(friction));
            }

            return(new PhysicsBlock(0.0));
        }
Beispiel #4
0
        private bool SuitablePosition(IBlockAccessor blockAccessor, BlockSelection blockSel)
        {
            Block attachingBlock = blockAccessor.GetBlock(blockSel.Position);

            if (attachingBlock.SideSolid[blockSel.Face.Index] || (attachingBlock is BlockMicroBlock && (blockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityMicroBlock).sideAlmostSolid[blockSel.Face.Index]))
            {
                EnumBlockMaterial targetMaterial = attachingBlock.GetBlockMaterial(blockAccessor, blockSel.Position);
                for (int i = 0; i < paintableOnBlockMaterials.Length; i++)
                {
                    if (targetMaterial == paintableOnBlockMaterials[i])
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Calculates the blast drop chance of a given material.
 /// </summary>
 /// <param name="blastType">The blast type the material is being it with.</param>
 /// <param name="material">The material of the block.</param>
 /// <returns>the resulting drop chance.</returns>
 public static double MaterialBlastDropChances(EnumBlastType blastType, EnumBlockMaterial material)
 {
     return(blastDropChances[(int)blastType][(int)material]);
 }