public static bool AlterDigState(Mk2Excavator machine, string data)
    {
        Mk2Excavator.ExcavateState newdigstate = Mk2Excavator.ExcavateState.ClearGarbage;
        switch (data)
        {
        case "ClearAll": newdigstate = Mk2Excavator.ExcavateState.ClearAll; break;

        case "ClearGarbage": newdigstate = Mk2Excavator.ExcavateState.ClearGarbage; break;

        case "ClearOre": newdigstate = Mk2Excavator.ExcavateState.ClearOre; break;

        case "Error": Debug.Log("Mk2Excavator: Error while processing NewDigState"); break;

        default: break;
        }
        machine.eExcavateState = newdigstate;
        machine.MarkDirtyDelayed();

        if (!WorldScript.mbIsServer)
        {
            NetworkManager.instance.SendInterfaceCommand("FlexibleGames.Mk2ExcavatorWindow", "AlterDigState", data, null, machine, 0.0f);
        }

        return(true);
    }
Esempio n. 2
0
 public void ChangeFireMode()
 {
     if (this.eExcavateState == ExcavateState.ClearGarbage)
     {
         this.eExcavateState = ExcavateState.ClearOre;
         this.mbDoDigOre     = true;
         this.mrPowerRate    = this.mrPowerRateOre;
     }
     else if (this.eExcavateState == ExcavateState.ClearOre)
     {
         this.eExcavateState = ExcavateState.ClearAll;
         this.mbDoDigOre     = true;
         this.mrPowerRate    = this.mrPowerRateOre;
     }
     else
     {
         this.eExcavateState = ExcavateState.ClearGarbage;
         this.mbDoDigOre     = false;
         this.mrPowerRate    = this.mrPowerRateDefault;
     }
 }
Esempio n. 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);
    }
Esempio n. 4
0
    public override void Read(BinaryReader reader, int entityVersion)
    {
        int modversion = 0;

        modversion = reader.ReadInt32();

        if (modversion >= 6)
        {
            if (modversion <= 9)
            {
                GameManager.DoLocalChat("Mk2Excavator version updated. Please replace all placed Mk2Excavators.");
            }

            // versions match, load normally
            this.eExcavateState    = (ExcavateState)reader.ReadInt32();
            this.eDropState        = (DropState)reader.ReadInt32();
            this.mnDigSizeX        = reader.ReadInt32();
            this.mnDigSizeZ        = mnDigSizeX;
            this.mnDigSizeY        = reader.ReadInt32();
            this.mnCurrentDigSizeY = reader.ReadInt32();

            int OPFlag;
            this.mutePews = reader.ReadInt32();
            OPFlag        = reader.ReadInt32();
            superOPflag   = OPFlag == 0 ? false : true;

            reader.ReadSingle();
            reader.ReadSingle();
            // 10 32bit reads
        }
        else
        {
            // version mismatch, must use defaults or things can get bad
            Debug.Log("Mk2Excavator: Reading modversion: " + modversion + " With entityVersion : " + entityVersion +
                      " And current modversion = " + this.mModVersion);
            GameManager.DoLocalChat("Mk2Excavator version updated. Please replace all placed Mk2Excavators.");

            this.eExcavateState = ExcavateState.ClearGarbage;
            this.eDropState     = DropState.DropSome;

            this.mnDigSizeX        = mnDigSizeZ = 4;
            this.mnDigSizeY        = 64;
            this.mnCurrentDigSizeY = 1;

            // lets get the reads out of the way.
            if (entityVersion < 5)
            {
                reader.ReadSingle();
                reader.ReadBoolean();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                // 10 total reads, one bool
            }
            else
            {
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                reader.ReadSingle();
                // 10 total reads
            }
        }

        UpdateDigSettings();
    }