Exemple #1
0
    public void UpdateDigSettings()
    {
        this.mnCurrentDigSizeX = mnDigSizeX; // 9;
        if (mnDigSizeY < 20)
        {
            this.mnCurrentDigSizeY = mnDigSizeY;
        }
        else
        {
            this.mnCurrentDigSizeY = (mnDigSizeY / 4) - 1; // 31;
        }

        this.mnCurrentDigSizeZ = mnDigSizeX; // 9;

        digArea           = null;
        digArea           = new DigArea(origin, 0, mnDigSizeX, mnDigSizeY, machineFlags);
        digAreaEnumerator = null;
        currentCube       = null;

        if (superOPflag)
        {
            this.mrPowerRate    = 1f;
            this.mrPowerRateOre = 1f;
        }
        else
        {
            this.mrPowerRate    = powerDefaultBackup;
            this.mrPowerRateOre = powerOreBackup;
        }

        mbWorkComplete       = false;
        mnBlocksDestroyed    = 0;
        mnTotalBlocksScanned = 0;
        this.RequestImmediateNetworkUpdate();
    }
 public void digAnimFinished()
 {
     GameObject[] array = GameObject.FindGameObjectsWithTag("DiggingArea");
     foreach (GameObject item in array)
     {
         DigArea  da  = item.GetComponent <DigArea>();
         DigArea2 da2 = item.GetComponent <DigArea2>();
         if (da)
         {
             da.completeDiggingAction();
         }
         else
         {
             da2.completeDiggingAction();
         }
     }
 }
Exemple #3
0
    public Mk2Excavator(Segment segment, long x, long y, long z, ushort cube, byte flags, ushort lValue,
                        bool lbFromDisk, int powerDefault, int powerOre, int digRadius, int digHeight, int maxPower, int opBlocks)
        : base(eSegmentEntity.Mod, SpawnableObjectEnum.AutoExcavator, x, y, z, cube, flags, lValue, Vector3.zero,
               segment)
    {
        this.mrPowerRate               = powerDefault;
        this.mrPowerRateDefault        = this.mrPowerRate;
        this.powerDefaultBackup        = powerDefault;
        this.mrPowerRateOre            = powerOre;
        this.powerOreBackup            = powerOre;
        this.mbNeedsLowFrequencyUpdate = true;
        this.mbNeedsUnityUpdate        = true;
        this.mbWorkComplete            = false;

        this.mnDigSizeX        = digRadius; // 9;
        this.mnDigSizeY        = digHeight; // 128;
        this.mnDigSizeZ        = digRadius; // 9;
        this.mnCurrentDigSizeX = digRadius; // 9;
        this.mnCurrentDigSizeY = 1;
        this.mnCurrentDigSizeZ = digRadius; // 9;
        this.mRand             = new System.Random();
        this.mbLocatedBlock    = false;
        this.mbDoDigOre        = false;
        this.eExcavateState    = ExcavateState.ClearGarbage;
        this.eDropState        = DropState.DropSome;
        this.mfCommandDebounce = 0.02f;
        this.mCubeColor        = Color.blue;
        this.mbDoDropBlocks    = true;
        this.mrMaxPower        = maxPower;
        this.mutePews          = 0;
        // New DigArea object should go in here
        OPBlockCount = opBlocks;
        machineFlags = flags;
        origin       = new CubeCoord(x, y, z);
        digArea      = new DigArea(origin, 0, digRadius, digHeight, machineFlags);
    }
Exemple #4
0
    public override void LowFrequencyUpdate()
    {
        if (mbWorkComplete)
        {
            return;
        }

        if (this.mrDigDelay > 0f)
        {
            this.mrDigDelay -= LowFrequencyThread.mrPreviousUpdateTimeStep;
            return;
        }

        if (digArea == null)
        {
            digArea = new DigArea(origin, mnCurrentDigSizeY, mnDigSizeX, mnDigSizeY, machineFlags);
        }

        PercentScanned = (float)mnTotalBlocksScanned / digArea.Volume;
        if (digAreaEnumerator == null)
        {
            digAreaEnumerator = digArea.GetRemainingDigArea();
        }

        if (mrCurrentPower < mrPowerRate)
        {
            mrOutOfPowerTime += LowFrequencyThread.mrPreviousUpdateTimeStep;
            return;
        }

        mrOutOfPowerTime = 0f;
        int skipCounter = 0;
        int OPCounter   = 0;

        while (true)
        {
            // Get the next cube in our dig area
            if (!currentCube.HasValue)
            {
                if (digAreaEnumerator.MoveNext())
                {
                    currentCube = digAreaEnumerator.Current;
                }
                else // enumerator has no more cubes for us
                {
                    mbWorkComplete = true;
                    return;
                }
            }

            if (!(currentCube is CubeCoord))
            {
                return;
            }
            CubeCoord cubeCoord = (CubeCoord)currentCube;
            DigResult result    = DigResult.Fail;
            if (WorldScript.mbIsServer)
            {
                result = AttemptToDig(cubeCoord.x, cubeCoord.y, cubeCoord.z);
            }

            if (result == DigResult.Fail)
            {
                return;
            }

            mnTotalBlocksScanned++;

            switch (result)
            {
            case DigResult.Dig:
                // Success, we reset and come back again next tick
                if (!superOPflag)
                {
                    currentCube = null;
                    return;
                }
                else
                {
                    OPCounter++;
                    currentCube = null;
                    if (OPCounter > OPBlockCount)
                    {
                        return;
                    }
                    continue;
                }

            case DigResult.Skip:
                // A block we want to skip ... let's do up to 32 per tick
                skipCounter++;
                currentCube = null;
                if (skipCounter > 32)
                {
                    return;
                }
                continue;

            case DigResult.Fail:
                // Fail, we try this cube again next tick
                return;
            }
        }
    }