예제 #1
0
        private static IMyPistonTop FindTop(IMyPistonBase block)
        {
            if (block.CubeGrid == null)
            {
                return(null);
            }

            MatrixD topMatrix;

            if (!GetTopMatrix(block, block.CubeGrid.GridSizeEnum, out topMatrix))
            {
                return(null);
            }

            Vector3D        pos  = topMatrix.Translation;
            BoundingSphereD area = new BoundingSphereD(pos, 1);

            foreach (IMyEntity e in MyAPIGateway.Entities.GetTopMostEntitiesInSphere(ref area))
            {
                IMyCubeGrid g = e as IMyCubeGrid;
                if (g != null)
                {
                    foreach (IMySlimBlock slim in g.GetBlocksInsideSphere(ref area))
                    {
                        IMyPistonTop top = slim.FatBlock as IMyPistonTop;
                        if (top != null && (top.Base == null || top.Base.Top == null) && TrySetDir(top, block, out top))
                        {
                            return(top);
                        }
                    }
                }
            }
            return(null);
        }
    protected override void Action(float multiplier, BoundingSphereD sphere, IMyCubeGrid targetGrid, IMyCubeBlock thisBlock)
    {
        var inventory = ((MyEntity)thisBlock).GetInventory();
        var amount    = MyAPIGateway.Session.GrinderSpeedMultiplier * multiplier;
        var blocks    = targetGrid.GetBlocksInsideSphere(ref sphere);

        foreach (var block in blocks)
        {
            block.DecreaseMountLevel(amount, inventory);
        }
    }
    protected override void Action(float multiplier, BoundingSphereD sphere, IMyCubeGrid targetGrid, IMyCubeBlock welderBlock)
    {
        var inventory  = ((MyEntity)welderBlock).GetInventory();
        bool isHelping = ((IMyShipWelder)welderBlock).HelpOthers;
        var amount     = MyAPIGateway.Session.WelderSpeedMultiplier * multiplier;
        var blocks     = targetGrid.GetBlocksInsideSphere(ref sphere);

        foreach (var block in blocks)
        {
            block.IncreaseMountLevel(amount, welderBlock.OwnerId, inventory, 0.6f, isHelping);
        }
    }