示例#1
0
 public static ItemBase getCurrentHotBarItem()
 {
     if (SurvivalHotBarManager.instance == null)
     {
         VicisMod.log("MassGiver", "SurvivalHotBarManager.instance is null??");
         return(null);
     }
     SurvivalHotBarManager.HotBarEntry currentHotBarEntry = SurvivalHotBarManager.instance.GetCurrentHotBarEntry();
     if (currentHotBarEntry == null)
     {
         return(null);
     }
     if (currentHotBarEntry.state == SurvivalHotBarManager.HotBarEntryState.Empty)
     {
         return(null);
     }
     if (currentHotBarEntry.cubeType != 0)
     {
         return(ItemManager.SpawnCubeStack(currentHotBarEntry.cubeType, currentHotBarEntry.cubeValue, 1));
     }
     if (currentHotBarEntry.itemType >= 0)
     {
         return(ItemManager.SpawnItem(currentHotBarEntry.itemType));
     }
     VicisMod.log("MassGiver", "No cube and no item in hotbar?");
     return(null);
 }
示例#2
0
    public PowWow(ModCreateSegmentEntityParameters parameters) :
        base(eSegmentEntity.Mod,
             SpawnableObjectEnum.ExperimentalAssembler,
             parameters.X,
             parameters.Y,
             parameters.Z,
             parameters.Cube,
             parameters.Flags,
             parameters.Value,
             parameters.Position,
             parameters.Segment)
    {
        currentPower    = 0;
        totalTransfered = 0;
        radius          = 3;
        transferCap     = 10000;
        maxPower        = 10000;
        for (int i = 0; i < ROLLING_AVG_LENGTH; ++i)
        {
            transfers[i] = 0;
        }

        // Trigger the searching of PCIs
        lastSearch                = 0;
        lastTransfer1             = 0;
        lastTransfer2             = 0;
        powerSource               = null;
        linkedToGo                = false;
        mbNeedsLowFrequencyUpdate = true;
        mbNeedsUnityUpdate        = true;
        this.cubeColor            = Color.white;
        VicisMod.log(getPrefix(), "Created");
    }
示例#3
0
 public override void UnityUpdate()
 {
     if (!linkedToGo)
     {
         if (mWrapper != null && mWrapper.mGameObjectList != null)
         {
             gameObject = mWrapper.mGameObjectList[0].gameObject;
             GameObject plate = gameObject.transform.Search("Docking_Port").gameObject;
             plate.SetActive(false);
             GameObject     crate      = gameObject.transform.Search("StorageCratePivot").gameObject;
             MeshRenderer[] components = crate.GetComponentsInChildren <MeshRenderer>();
             if (components != null && components.Length > 0)
             {
                 foreach (MeshRenderer mesh in components)
                 {
                     mesh.material.SetColor("_Color", cubeColor);
                 }
             }
             else
             {
                 VicisMod.log(getPrefix(), "Could not establish MeshRenderers for gameobject!");
             }
             linkedToGo = true;
         }
     }
 }
示例#4
0
    protected void recordStats(float transfered)
    {
        lastTransfer2 += LowFrequencyThread.mrPreviousUpdateTimeStep;
        if (transfered == 0 && lastTransfer2 < transferFrequency)
        {
            return;
        }
        if (transfered > 0)
        {
            MarkDirtyDelayed();
        }
        string msg = "current counts = [";

        for (int i = 0; i < ROLLING_AVG_LENGTH; ++i)
        {
            if (i > 0)
            {
                msg += ", ";
            }
            msg += transfers[i];
        }
        msg += "], Lifo = " + lifo + ", currentSum = " + sumTransfers + ", transfered now = " + transfered;
        VicisMod.log(getPrefix() + ".recordStats", msg);
        sumTransfers       -= transfers[lifo];
        sumTimes           -= transfersTime[lifo];
        transfersTime[lifo] = lastTransfer2;
        lastTransfer2       = 0;
        sumTimes           += transfersTime[lifo];
        transfers[lifo]     = transfered;
        sumTransfers       += transfers[lifo++];
        lifo %= ROLLING_AVG_LENGTH;
    }
示例#5
0
        public static ItemBase newInstance(ItemBase a)
        {
            VicisMod.log(LOGGER_PREFIX, "Creating new instance of " + a.GetDisplayString());
            switch (a.mType)
            {
            case ItemType.ItemCubeStack:
                ItemCubeStack ics = a as ItemCubeStack;
                return(new ItemCubeStack(ics.mCubeType, ics.mCubeValue, ics.mnAmount));

            case ItemType.ItemStack:
                ItemStack its = a as ItemStack;
                return(new ItemStack(its.mnItemID, its.mnAmount));

            case ItemType.ItemCharge:
                ItemCharge ic = a as ItemCharge;
                return(new ItemCharge(ic.mnItemID, (int)ic.mChargeLevel));

            case ItemType.ItemDurability:
                ItemDurability id = a as ItemDurability;
                return(new ItemDurability(id.mnItemID, id.mnCurrentDurability, id.mnMaxDurability));

            case ItemType.ItemLocation:
                ItemLocation il = a as ItemLocation;
                return(new ItemLocation(il.mnItemID, il.mLocX, il.mLocY, il.mLocZ, il.mLookVector));

            case ItemType.ItemSingle:
                return(new ItemSingle(a.mnItemID));
            }
            return(null);
        }
示例#6
0
    protected virtual void LookForAttachedModules()
    {
        VicisMod.log(getPrefix(), "Looking neigbors");

        List <MassCrateModule> list = VicisMod.checkSurrounding <MassCrateModule>(this, out encounteredNullSegment);

        foreach (MassCrateModule m in list)
        {
            if (manager == null)
            {
                m.manager.Add(this);
            }
            else if (manager != m.manager)
            {
                manager.Merge(m.manager);
            }
            m.AddNeighbor(this);
            AddNeighbor(m);
        }

        VicisMod.log(getPrefix(), "I now have " + neighbors.Count + " neighbors");

        // FIRST!
        if (manager == null)
        {
            VicisMod.log(getPrefix(), "Creating a new manager for myself");
            MassCrateModuleManager newManager = new MassCrateModuleManager();
            newManager.Add(this);
        }
    }
示例#7
0
 protected void attemptGiveMorePower()
 {
     VicisMod.log(getPrefix(), "Attempting to give more power to " + mk4AndMk5Bats.Count + " batteries with " + mrCurrentPower + " power left");
     foreach (PowerConsumerInterface pci in mk4AndMk5Bats)
     {
         if (pci.WantsPowerFromEntity(this))
         {
             // We purposely ignore the max delivery rate for T4 and T5 batteries
             float transfer = Math.Min(mrCurrentPower, pci.GetRemainingPowerCapacity());
             VicisMod.log(getPrefix(), "Giving " + transfer + " power");
             if (transfer > 0 && pci.DeliverPower(transfer))
             {
                 VicisMod.log(getPrefix(), "Success in giving " + transfer + " power");
                 mrCurrentPower      -= transfer;
                 mrNormalisedPower    = mrCurrentPower / mrMaxPower;
                 mrRemainingCapacity  = mrMaxPower - mrCurrentPower;
                 mrSparePowerCapacity = mrMaxPower - mrCurrentPower;
                 MarkDirtyDelayed();
             }
         }
         if (mrCurrentPower <= 0)
         {
             return;
         }
     }
 }
示例#8
0
    protected void findMk4AndMk5Bats()
    {
        VicisMod.log(getPrefix(), "Looking for T4 and T5 batteries");
        long[] coords = new long[3];
        for (int i = 0; i < 3; ++i)
        {
            for (int j = -1; j <= 1; j += 2)
            {
                Array.Clear(coords, 0, 3);
                coords[i] = j;

                long x = mnX + coords[0];
                long y = mnY + coords[1];
                long z = mnZ + coords[2];

                Segment segment = base.AttemptGetSegment(x, y, z);
                // Check if segment was generated (skip this point if it doesn't
                if (segment == null)
                {
                    continue;
                }
                ushort cube = segment.GetCube(x, y, z);
                // If this isn't an entity, skip it
                if (!CubeHelper.HasEntity((int)cube))
                {
                    continue;
                }
                PowerConsumerInterface pci = segment.SearchEntity(x, y, z) as PowerConsumerInterface;
                if (pci == null)
                {
                    continue;
                }
                // We're only looking for T4 and T5 batteries
                if (!(pci is T4_Battery) && !(pci is T5_Battery))
                {
                    continue;
                }
                VicisMod.log(getPrefix(), "Found one: " + pci.ToString());
                // Let's only keep track of PCIs that will accept power from the PowWow
                if (!pci.WantsPowerFromEntity(this))
                {
                    continue;
                }
                for (int l = mk4AndMk5Bats.Count - 1; l >= 0 && pci != null; --l)
                {
                    PowerConsumerInterface pci2 = mk4AndMk5Bats[l];
                    if (pci2 != null && !(pci2 as SegmentEntity).mbDelete && pci2 == pci)
                    {
                        pci = null;
                    }
                }
                VicisMod.log(getPrefix(), "End, checking " + pci);
                if (pci != null)
                {
                    mk4AndMk5Bats.Add(pci);
                }
            }
        }
    }
示例#9
0
 protected virtual void retrievingDrone(float timeJump)
 {
     if (headTo == null)
     {
         VicisMod.log(getPrefix(), "Retrieving drone");
         retrieveDrone(mUnityDroneRestPos, timeJump);
     }
 }
示例#10
0
 public override void LowFrequencyUpdate()
 {
     // If we somehow lost our manager (how?) or we found a null segment last time,
     // re-check for neighbors
     if (manager == null || encounteredNullSegment)
     {
         VicisMod.log(getPrefix(), "looking for neighbors again. manager == null => " + (manager == null) + ", encounteredNullSegment = " + encounteredNullSegment);
         LookForAttachedModules();
     }
 }
示例#11
0
 public override void Write(BinaryWriter writer)
 {
     VicisMod.log(getPrefix(), "Currently holding: " + GetPopupText());
     writer.Write(items.Count);
     for (int i = 0; i < items.Count; ++i)
     {
         VicisMod.log(getPrefix(), "Writing to file " + items[i].GetDisplayString());
         ItemFile.SerialiseItem(items[i], writer);
     }
 }
 public bool DeliverPower(float amount)
 {
     VicisMod.log(getPrefix(), "Attempting to receive power of " + amount + ", I have " + currentPower + " / " + maxPower);
     if (amount > GetRemainingPowerCapacity())
     {
         VicisMod.log(getPrefix(), "Returning false for power delivery");
         return(false);
     }
     currentPower += amount;
     VicisMod.log(getPrefix(), "Now have " + currentPower);
     return(true);
 }
示例#13
0
 public bool DeliverPower(float amount)
 {
     VicisMod.log(getPrefix(), "receiving power of " + amount + " amount");
     if (amount > GetRemainingPowerCapacity())
     {
         VicisMod.log(getPrefix(), "Rejected");
         return(false);
     }
     currentPower += amount;
     VicisMod.log(getPrefix(), "Now have " + currentPower + " power");
     return(true);
 }
示例#14
0
        protected virtual void LookForAttachedModules()
        {
            VicisMod.log(getPrefix(), "Looking for storage");
            bool ignore;
            List <MassCrateModule> list = VicisMod.checkSurrounding <MassCrateModule>(this, out ignore);

            if (list.Count > 0)
            {
                mcm       = list[0];
                mcm.taker = this;
            }
        }
示例#15
0
    protected float attemptTransferPower()
    {
        VicisMod.log(getPrefix(), "Running LFU");
        lastSearch -= LowFrequencyThread.mrPreviousUpdateTimeStep;
        // Nothing to do
        if (currentPower <= 0)
        {
            return(0);
        }
        lastTransfer1 -= LowFrequencyThread.mrPreviousUpdateTimeStep;
        if (lastTransfer1 > 0)
        {
            return(0);
        }
        lastTransfer1 += transferFrequency;
        VicisMod.log(getPrefix(), "Currently have " + currentPower + " Power");
        cullPCIs();
        if (lastSearch <= 0)
        {
            VicisMod.log(getPrefix(), "Finding PCIs");
            findPCIs();
            lastSearch = scanFrequency;
        }

        VicisMod.log(getPrefix(), "Aware of " + pcis.Count + " PCIs");
        // Now lets charge these guys up!
        float transferedThisTime = 0;

        for (int i = 0; i < pcis.Count; ++i)
        {
            PowerConsumerInterface pci = pcis[i];
            if (pci.WantsPowerFromEntity(this))
            {
                float transfer = transferCap;
                transfer = Math.Min(transfer, currentPower);
                transfer = Math.Min(transfer, pci.GetMaximumDeliveryRate());
                transfer = Math.Min(transfer, pci.GetRemainingPowerCapacity());
                if (transfer > 0 && pci.DeliverPower(transfer))
                {
                    VicisMod.log(getPrefix(), "Adding " + transfer + " to PCI " + pci.ToString());
                    currentPower       -= transfer;
                    totalTransfered    += transfer;
                    transferedThisTime += transfer;
                    // And we're done
                    if (currentPower == 0)
                    {
                        return(transferedThisTime);
                    }
                }
            }
        }
        return(transferedThisTime);
    }
示例#16
0
 public static void decrementStack(this ItemBase a, int amount)
 {
     if (a.mType == ItemType.ItemCubeStack)
     {
         (a as ItemCubeStack).mnAmount -= amount;
     }
     else if (a.mType == ItemType.ItemStack)
     {
         (a as ItemStack).mnAmount -= amount;
     }
     VicisMod.log(LOGGER_PREFIX, "Tried decrementing a non stacked item! " + amount + ", " + a.GetDisplayString());
 }
示例#17
0
 public static void setAmount(this ItemBase a, int amount)
 {
     if (a.mType == ItemType.ItemCubeStack)
     {
         (a as ItemCubeStack).mnAmount = amount;
     }
     else if (a.mType == ItemType.ItemStack)
     {
         (a as ItemStack).mnAmount = amount;
     }
     VicisMod.log(LOGGER_PREFIX, "Tried setting an amount on a non stacked item! " + a.GetDisplayString());
 }
示例#18
0
    // An item that we'll try taking, and a flag whether we should actually take it or not (we could just be checking if we have space)
    public bool AttemptGiveItem(ItemBase item, int amount = 1, bool actuallyTakeItem = true)
    {
        VicisMod.log(getPrefix(), "Attempting to receive " + amount + " item " + item.GetDisplayString() + " with id = " + item.mnItemID + " and type = " + item.mType);
        // Can we even take this item(s)?
        if (getNumItems() + amount > maxItems)
        {
            return(false);
        }
        for (int i = 0; i < items.Count; ++i)
        {
            if (ItemBaseUtil.compareCubeStack(items[i] as ItemCubeStack, item as ItemCubeStack))
            {
                ItemCubeStack a         = items[i] as ItemCubeStack;
                int           amntTaken = Math.Min(amount, a.mnAmount);
                if (a != null && a.mnAmount < maxBinSize)
                {
                    if (actuallyTakeItem)
                    {
                        a.mnAmount += amount;
                    }
                    MarkDirtyDelayed();
                    return(true);
                }
            }
            else if (ItemBaseUtil.compareStack(items[i] as ItemStack, item as ItemStack))
            {
                ItemStack a = items[i] as ItemStack;
                if (a != null && a.mnAmount < maxBinSize)
                {
                    if (actuallyTakeItem)
                    {
                        a.mnAmount += amount;
                    }
                    MarkDirtyDelayed();
                    return(true);
                }
            }
        }

        if (items.Count < maxBins)
        {
            if (actuallyTakeItem)
            {
                items.Add(item);
            }
            MarkDirtyDelayed();
            return(true);
        }

        VicisMod.log(getPrefix(), "Did not accept item " + item.GetDisplayString());
        return(false);
    }
示例#19
0
    public override void LowFrequencyUpdate()
    {
        base.LowFrequencyUpdate();

        cullBats();
        lastScan -= LowFrequencyThread.mrPreviousUpdateTimeStep;

        // Did we didn't collect anything, don't try to collect anymore
        if (!mbCollecting)
        {
            return;
        }

        if (lastScan <= 0)
        {
            findMk4AndMk5Bats();
            lastScan = scanFrequency;
        }

        // Get the last amount power generated
        float newGenerated = mrLastPowerGain * LowFrequencyThread.mrPreviousUpdateTimeStep;

        VicisMod.log(getPrefix(), "Already collected " + newGenerated + " power");

        // Generate however more power we need
        newGenerated *= multiplier;
        // Make sure we have the space for it
        newGenerated = Math.Min(newGenerated, mrSparePowerCapacity);
        VicisMod.log(getPrefix(), "Now generated " + newGenerated + " power");
        // Add it together
        if (newGenerated > 0)
        {
            mrLastPowerGain     += newGenerated / LowFrequencyThread.mrPreviousUpdateTimeStep;
            mrCurrentPower      += newGenerated;
            mrNormalisedPower    = mrCurrentPower / mrMaxPower;
            mrRemainingCapacity  = mrMaxPower - mrCurrentPower;
            mrSparePowerCapacity = mrMaxPower - mrCurrentPower;
            VicisMod.log(getPrefix(), "Current Power now " + mrCurrentPower + " with " + mrRemainingCapacity + " capacity left");
            GameManager.PowerGenerated(newGenerated);
            GameManager.mrTotalSolarPower += newGenerated;
            if (PlayerStats.mbCreated)
            {
                PlayerStats.instance.AddPowerToStats(newGenerated);
            }
        }

        // If we still have power, attempt to give all of it to adjacent T4 and T5 batteries
        if (mrCurrentPower > 0)
        {
            attemptGiveMorePower();
        }
    }
 public bool AttemptGiveItem(ItemBase item)
 {
     foreach (MassCrateModule mcm in modules.Keys)
     {
         VicisMod.log(LOGGER_PREFIX, "Attempting to give " + item.GetDisplayString() + " to a module");
         if (mcm.AttemptGiveItem(item))
         {
             return(true);
         }
         VicisMod.log(LOGGER_PREFIX, "Failed, will attempt again");
     }
     VicisMod.log(LOGGER_PREFIX, "Could not give item " + item.GetDisplayString());
     return(false);
 }
示例#21
0
        // An item that we'll try taking, and a flag whether we should actually take it or not (we could just be checking if we have space)
        public bool AttemptGiveItem(ItemBase item, int amount, bool actuallyTakeItem = true)
        {
            VicisMod.log(getPrefix(), "Attempting to receive " + amount + " item " + item.GetDisplayString() + " with id = " + item.mnItemID + " and type = " + item.mType);
            // Can we even take this item(s)?
            if (getNumItems() + amount > maxItems)
            {
                return(false);
            }
            if (claimed != null && !claimed.compareBaseDeep(item))
            {
                return(false);
            }
            if (!actuallyTakeItem && getNumItems() == 0 && maxItems > 0 && maxBins > 0 && maxBinSize > 0)
            {
                return(true);
            }
            for (int i = 0; item.isStack() && i < items.Count; ++i)
            {
                if (items[i].isStackAndSame(item))
                {
                    if ((items[i].getAmount() + amount) <= maxBinSize)
                    {
                        if (actuallyTakeItem)
                        {
                            items[i].incrementStack(amount);
                            MarkDirtyDelayed();
                        }
                        return(true);
                    }
                }
            }
            if (item.isStack() && items.Count >= maxBins)
            {
                VicisMod.log(getPrefix(), "Couldn't find stack for " + item.GetDisplayString() + ", returning false");
                return(false);
            }

            if (items.Count < maxBins)
            {
                if (actuallyTakeItem)
                {
                    items.Add(item);
                    MarkDirtyDelayed();
                }
                return(true);
            }

            VicisMod.log(getPrefix(), "Did not accept item " + item.GetDisplayString());
            return(false);
        }
示例#22
0
    public void setDrone(GameObject drone)
    {
        VicisMod.log(LOGGER_PREFIX, "Drone pos is currently = " + dronePos + ", drone is = " + drone.transform.position);
        if (dronePos == Vector3.zero)
        {
            dronePos = drone.transform.position;
        }
        else
        {
            drone.transform.position = dronePos;
        }
        VicisMod.log(LOGGER_PREFIX, "Drone pos is now = " + dronePos);

        this.drone = drone;
    }
示例#23
0
        protected override bool FinishGiveItem()
        {
            if (carriedItems.Count == 0)
            {
                return(false);
            }

            VicisMod.log(getPrefix(), "Attempting to give item " + carriedItems[0].GetDisplayString());
            if (headTo.AttemptGiveItem(carriedItems[0], getCarriedItemCount()))
            {
                carriedItems.RemoveAt(0);
                mbCarriedCubeNeedsConfiguring = true;
                return(true);
            }
            return(false);
        }
    public ItemBase AttemptTakeItem(ItemBase item)
    {
        foreach (MassCrateModule mcm in modules.Keys)
        {
            VicisMod.log(LOGGER_PREFIX, "Attempting to take " + item.GetDisplayString() + " to a module");
            ItemBase ret = mcm.AttemptTakeItem(item);
            if (ret != null)
            {
                return(ret);
            }

            VicisMod.log(LOGGER_PREFIX, "Failed, will attempt again");
        }
        VicisMod.log(LOGGER_PREFIX, "Could not give take " + item.GetDisplayString());
        return(null);
    }
示例#25
0
        // An item that we're going to give, or check that we can give
        public ItemBase AttemptTakeItem(ItemBase item, int amount = 1, bool actuallyGiveItem = true)
        {
            VicisMod.log(getPrefix(), "Attempting to give " + amount + " item " + item.GetDisplayString() + " with id = " + item.mnItemID + " and type = " + item.mType);
            if (getNumItems() == 0)
            {
                return(null);
            }
            bool itemIsStack = item.isStack();

            for (int i = 0; i < items.Count; ++i)
            {
                if (itemIsStack && items[i].isStackAndSame(item))
                {
                    VicisMod.log(getPrefix(), "Found a CubeStack " + items[i].GetDisplayString() + ", which is storing " + items[i].getAmount() + " blocks");
                    int      amntTaken = Math.Min(amount, items[i].getAmount());
                    ItemBase ret       = ItemBaseUtil.newInstance(items[i]);
                    ret.setAmount(amntTaken);
                    if (actuallyGiveItem)
                    {
                        VicisMod.log(getPrefix(), "Taking Away");
                        items[i].decrementStack(amntTaken);
                        if (items[i].getAmount() == 0)
                        {
                            VicisMod.log(getPrefix(), "There are " + items[i].getAmount() + " items for " + items[i].GetDisplayString() + ", removing it from items");
                            items.RemoveAt(i);
                        }
                        MarkDirtyDelayed();
                    }
                    return(ret);
                }
                else if (!item.isStack() && items[i].compareBase(item))
                {
                    ItemBase ret = items[i];
                    VicisMod.log(getPrefix(), "Found a " + ret.GetDisplayString() + ", with id = " + ret.mnItemID + " and type = " + ret.mType);
                    if (actuallyGiveItem)
                    {
                        VicisMod.log(getPrefix(), "Removing from items");
                        items.RemoveAt(i);
                        MarkDirtyDelayed();
                    }
                    return(ret);
                }
            }

            return(null);
        }
示例#26
0
    protected override bool AttemptTakeItem()
    {
        if ((batch + getStoredItemsCount()) > maxItems)
        {
            return(false);
        }

        VicisMod.log(getPrefix(), "Attempting to get item " + chosen.GetDisplayString());
        ItemBase item = headTo.AttemptTakeItem(chosen, batch);

        if (item != null)
        {
            carriedItems.Add(item);
            mbCarriedCubeNeedsConfiguring = true;
            return(true);
        }
        return(false);
    }
示例#27
0
    protected virtual void pickUpFromConveyors()
    {
        bool ignore;
        List <ConveyorEntity> list = VicisMod.checkSurrounding <ConveyorEntity>(this, out ignore);

        VicisMod.log(getPrefix(), "Found " + list.Count + " ConveyorEntities");
        for (int i = 0; i < list.Count && getStoredItemsCount() < maxItems; ++i)
        {
            ConveyorEntity c = list[i];
            if (!isConveyorFacingMe(c))
            {
                continue;
            }
            if (!c.mbReadyToConvey && c.mrCarryTimer <= 0.2f)
            {
                ItemBase item = null;
                if (c.mCarriedItem != null)
                {
                    item = c.mCarriedItem;
                }
                if (c.mCarriedCube != 0)
                {
                    item = ItemManager.SpawnCubeStack(c.mCarriedCube, c.mCarriedValue, 1);
                }
                // Wha... How?
                if (item == null)
                {
                    continue;
                }

                // Check if I can add it to the items list
                if (!addItem(item))
                {
                    return;
                }

                c.mCarriedItem  = null;
                c.mCarriedCube  = 0;
                c.mCarriedValue = 0;
                c.RemoveCube();
                c.FinaliseOffloadingCargo();
            }
        }
    }
示例#28
0
 public MassCrateModule(ModCreateSegmentEntityParameters parameters) :
     base(eSegmentEntity.Mod,
          SpawnableObjectEnum.MassStorageCrate,
          parameters.X,
          parameters.Y,
          parameters.Z,
          parameters.Cube,
          parameters.Flags,
          parameters.Value,
          parameters.Position,
          parameters.Segment)
 {
     VicisMod.log(getPrefix(), "Being created at [" + parameters.X + ", " + parameters.Y + ", " + parameters.Z + "], loaded from disk = " + parameters.LoadFromDisk);
     mbNeedsLowFrequencyUpdate = true;
     mbNeedsUnityUpdate        = true;
     cubeColor = Color.white;
     LookForAttachedModules();
     items = new List <ItemBase>();
 }
示例#29
0
    protected virtual void sendingDrone(float timeJump)
    {
        if (carriedItems.Count == 0 && headTo != null && items.Count < maxItems)
        {
            VicisMod.log(getPrefix(), "Sending drone to pick up " + chosen.GetDisplayString() + " from location " +
                         VicisMod.getPosString(headTo.mnX, headTo.mnY, headTo.mnZ) + ", I'm at " + VicisMod.getPosString(mnX, mnY, mnZ) +
                         ", which is " + MassCrateModuleManager.calcDist(headTo, this) + "m away");

            getTargetCoords();

            VicisMod.log(getPrefix(), "Target coords are " + targetCoords + ", drone is at " + drone.getPos());

            if (targetCoords == Vector3.zero)
            {
                return;
            }
            sendDrone(targetCoords, timeJump);
        }
    }
示例#30
0
    public override void Read(BinaryReader reader, int entityVersion)
    {
        VicisMod.VicisModVersion version = (VicisMod.VicisModVersion)entityVersion;
        items.Clear();
        switch (version)
        {
        case VicisMod.VicisModVersion.Version1:
        case VicisMod.VicisModVersion.Version2:
        case VicisMod.VicisModVersion.Version3:
            break;

        default:
            int count = reader.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                ItemBase item = ItemFile.DeserialiseItem(reader);
                VicisMod.log(getPrefix(), "Reading from file " + item.GetDisplayString());
                items.Add(item);
            }
            break;
        }
    }