private static Color ItemColor(ItemBase itemBase) { Color lCol = Color.green; if (itemBase.mType == ItemType.ItemCubeStack) { ItemCubeStack itemCubeStack = itemBase as ItemCubeStack; if (CubeHelper.IsGarbage(itemCubeStack.mCubeType)) { lCol = Color.red; } if (CubeHelper.IsSmeltableOre(itemCubeStack.mCubeType)) { lCol = Color.green; } } if (itemBase.mType == ItemType.ItemStack) { lCol = Color.cyan; } if (itemBase.mType == ItemType.ItemSingle) { lCol = Color.white; } if (itemBase.mType == ItemType.ItemCharge) { lCol = Color.magenta; } if (itemBase.mType == ItemType.ItemDurability) { lCol = Color.yellow; } if (itemBase.mType == ItemType.ItemLocation) { lCol = Color.gray; } return(lCol); }
public void BoreTunnelV(HashSet <Segment> touchedSegments) { for (var layer = 0; layer < 10; layer++) { for (var rightOffset = -2 - layer; rightOffset <= 2 + layer; rightOffset++) { var posX = (long)Forward.x * BoreDistance; var posY = (long)Forward.y * BoreDistance; var posZ = (long)Forward.z * BoreDistance; // Adjust for "up" layers posX += (long)((double)layer * Up.x); posY += (long)((double)layer * Up.y); posZ += (long)((double)layer * Up.z); // Adjust for left/right cut width posX += (long)((double)rightOffset * Right.x); posY += (long)((double)rightOffset * Right.y); posZ += (long)((double)rightOffset * Right.z); // Now add our current position to get the target offset posX += mnX; posY += mnY; posZ += mnZ; // Now let's try to get the segment Segment segment; if (this.mFrustrum != null) { segment = AttemptGetSegment(posX, posY, posZ); if (segment == null) { return; } } else { segment = WorldScript.instance.GetSegment(posX, posY, posZ); if (segment == null || !segment.mbInitialGenerationComplete || segment.mbDestroyed) { return; } } // Diggy Diggy Hole var cube = segment.GetCube(posX, posY, posZ); if (!CubeHelper.IsGarbage(cube)) { continue; } if (CurrentPower - PowerPerBlock < 0) { return; } if (!touchedSegments.Contains(segment)) { segment.BeginProcessing(); touchedSegments.Add(segment); } CurrentPower -= PowerPerBlock; WorldScript.instance.BuildFromEntity(segment, posX, posY, posZ, eCubeTypes.Air, 0); } } BoreDistance++; }
public static bool StoreItems(Player player, ExtraStorageHoppers hopper, ItemBase itemToStore) { if ((player == WorldScript.mLocalPlayer) && !WorldScript.mLocalPlayer.mInventory.RemoveItemByExample(itemToStore, true)) { Debug.Log(string.Concat(new object[] { "Player ", player.mUserName, " doesnt have ", player.GetItemName(itemToStore) })); return(false); } if (!hopper.AddItem(itemToStore)) { Debug.LogWarning("Bad thing that used to be unhandled! Thread interaccess probably caused this to screw up!"); if (player == WorldScript.mLocalPlayer) { WorldScript.mLocalPlayer.mInventory.AddItem(itemToStore); return(false); } player.mInventory.AddItem(itemToStore); return(false); } if (player.mbIsLocalPlayer) { Color green = Color.green; ItemBase lItem = itemToStore; if (lItem.mType == ItemType.ItemCubeStack) { ItemCubeStack stack = lItem as ItemCubeStack; if (CubeHelper.IsGarbage(stack.mCubeType)) { green = Color.red; } if (CubeHelper.IsSmeltableOre(stack.mCubeType)) { green = Color.green; } } if (lItem.mType == ItemType.ItemStack) { green = Color.cyan; } if (lItem.mType == ItemType.ItemSingle) { green = Color.white; } if (lItem.mType == ItemType.ItemCharge) { green = Color.magenta; } if (lItem.mType == ItemType.ItemDurability) { green = Color.yellow; } if (lItem.mType == ItemType.ItemLocation) { green = Color.gray; } if (hopper.GetCubeValue() == 0) { green = Color.red; FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 0.75f, "Sent " + player.GetItemName(lItem) + " to the void!", green, 1.5f); } else { FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 0.75f, "Stored " + player.GetItemName(lItem), green, 1.5f); } } player.mInventory.VerifySuitUpgrades(); if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand("ExtraStorageHopperWindow", "StoreItems", null, itemToStore, hopper, 0f); } return(true); }
public static bool TakeItems(Player player, ExtraStorageHoppers_OT hopper) { if (hopper.mnStorageUsed > 0) { ItemBase lItemToAdd = hopper.RemoveFirstInventoryItem(); if (lItemToAdd != null) { Debug.Log("RemovingFirstInventoryItem from for " + player.mUserName); if (!player.mInventory.AddItem(lItemToAdd)) { if (!hopper.AddItem(lItemToAdd)) { ItemManager.instance.DropItem(lItemToAdd, player.mnWorldX, player.mnWorldY, player.mnWorldZ, Vector3.zero); } return(false); } if (player.mbIsLocalPlayer) { Color green = Color.green; if (lItemToAdd.mType == ItemType.ItemCubeStack) { ItemCubeStack stack = lItemToAdd as ItemCubeStack; if (CubeHelper.IsGarbage(stack.mCubeType)) { green = Color.red; } if (CubeHelper.IsSmeltableOre(stack.mCubeType)) { green = Color.green; } } if (lItemToAdd.mType == ItemType.ItemStack) { green = Color.cyan; } if (lItemToAdd.mType == ItemType.ItemSingle) { green = Color.white; } if (lItemToAdd.mType == ItemType.ItemCharge) { green = Color.magenta; } if (lItemToAdd.mType == ItemType.ItemDurability) { green = Color.yellow; } if (lItemToAdd.mType == ItemType.ItemLocation) { green = Color.gray; } FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, player.GetItemName(lItemToAdd), green, 1.5f); } player.mInventory.VerifySuitUpgrades(); if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand("ExtraStorageHopperWindow_OT", "TakeItems", null, lItemToAdd, hopper, 0f); } return(true); } } return(false); }
public static bool TakeItems(Player player, ExtraStorageHoppers hopper) { //ENABLE/DISABLE FEEDING OF HIVEBIND - ONLY FOR VOID HOPPER if (hopper.GetCubeValue() == 0) { if (hopper.FeedHiveMind) { hopper.FeedHiveMind = false; FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, "Not Feeding Hivemind!", Color.green, 2f); } else { hopper.FeedHiveMind = true; FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, "Feeding Hivemind!", Color.red, 2f); } return(true); } //******************** TAKE ITEMS FROM HOPPER AND ADD THEM TO INVENTORY ******************** if (hopper.mnStorageUsed > 0) { ItemBase lItemToAdd = hopper.RemoveFirstInventoryItem(); if (lItemToAdd != null) { Debug.Log("RemovingFirstInventoryItem from for " + player.mUserName); if (!player.mInventory.AddItem(lItemToAdd)) { if (!hopper.AddItem(lItemToAdd)) { ItemManager.instance.DropItem(lItemToAdd, player.mnWorldX, player.mnWorldY, player.mnWorldZ, Vector3.zero); } return(false); } if (player.mbIsLocalPlayer) { Color green = Color.green; if (lItemToAdd.mType == ItemType.ItemCubeStack) { ItemCubeStack stack = lItemToAdd as ItemCubeStack; if (CubeHelper.IsGarbage(stack.mCubeType)) { green = Color.red; } if (CubeHelper.IsSmeltableOre(stack.mCubeType)) { green = Color.green; } } if (lItemToAdd.mType == ItemType.ItemStack) { green = Color.cyan; } if (lItemToAdd.mType == ItemType.ItemSingle) { green = Color.white; } if (lItemToAdd.mType == ItemType.ItemCharge) { green = Color.magenta; } if (lItemToAdd.mType == ItemType.ItemDurability) { green = Color.yellow; } if (lItemToAdd.mType == ItemType.ItemLocation) { green = Color.gray; } FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, player.GetItemName(lItemToAdd), green, 1.5f); } player.mInventory.VerifySuitUpgrades(); if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand("ExtraStorageHopperWindow", "TakeItems", null, lItemToAdd, hopper, 0f); } return(true); } } return(false); }
public static bool IsGarbage(ItemBase i) { return(i is ItemCubeStack && CubeHelper.IsGarbage((i as ItemCubeStack).mCubeType)); }
public static bool TakeItems(Player player, StorageHopper hopper) { if (hopper.mnStorageUsed > 0) { // ushort lCube, lValue; // lSelectedHopper.GetSpecificCube(eHopperRequestType.eAny, out lCube, out lValue);//this also reduces CubeStacks // if (lCube != eCubeTypes.NULL) // { // Debug.Log("Transferring "+ TerrainData.mEntries[lCube].Name +" from StorageHopper to player inventory"); // WorldScript.mLocalPlayer.mInventory.CollectValue(lCube, lValue, 1); // WorldScript.mLocalPlayer.mInventory.VerifySuitUpgrades();//we may have just taken a suit upgrade OUT. // return; // } //only remove Items now //This is really ficking stupid, we should duplicate the item and ASK if it'll fit and THEN remove it. Please god someone change this. ItemBase lItem = hopper.RemoveFirstInventoryItem(); if (lItem != null) { Debug.Log("RemovingFirstInventoryItem from StorageHopper for " + player.mUserName); //This has a potential issue where the server and client diverge //TODO: ensure it fits? if (!player.mInventory.AddItem(lItem)) { //Do we know why it didn't fit? //Doesn't fit, put it back in if (!hopper.AddItem(lItem)) //oh dear god threading { //THROW IT TO THE GROUND ItemManager.instance.DropItem(lItem, player.mnWorldX, player.mnWorldY, player.mnWorldZ, Vector3.zero); } return(false); } else { if (player.mbIsLocalPlayer == true) { //if we know what sort of item it was, colour the text! Color lCol = Color.green; if (lItem.mType == ItemType.ItemCubeStack) { ItemCubeStack lCubeStack = lItem as ItemCubeStack; if (CubeHelper.IsGarbage(lCubeStack.mCubeType)) { lCol = Color.red; } if (CubeHelper.IsSmeltableOre(lCubeStack.mCubeType)) { lCol = Color.green; } } if (lItem.mType == ItemType.ItemStack) { //probably a crafted item of some sort; we could introspect further into bar types lCol = Color.cyan; } if (lItem.mType == ItemType.ItemSingle) { //Minecart lCol = Color.white; } if (lItem.mType == ItemType.ItemCharge) { //Drill head/Minecart lCol = Color.magenta; } if (lItem.mType == ItemType.ItemDurability) { //Drill head lCol = Color.yellow; } if (lItem.mType == ItemType.ItemLocation) { lCol = Color.gray; } FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1, hopper.mnZ, 1.0f, player.GetItemName(lItem), lCol, 1.5f); } } player.mInventory.VerifySuitUpgrades(); //we may have just taken a suit upgrade OUT. if (!WorldScript.mbIsServer) //Tell the server we took the items { NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceTakeItems, null, lItem, hopper, 0); } return(true); } } return(false); }
public static bool StoreItems(Player player, StorageHopper hopper, ItemBase itemToStore) { if (player == WorldScript.mLocalPlayer) { if (!WorldScript.mLocalPlayer.mInventory.RemoveItemByExample(itemToStore, true)) { // player didn't have this item Debug.Log("Player " + player.mUserName + " doesnt have " + itemToStore); return(false); } } //stored first to reduce the gap - the VSU below could take several hundred MS due to logging. if (!hopper.AddItem(itemToStore)) { Debug.LogWarning("Bad thing that used to be unhandled! Thread interaccess probably caused this to screw up!"); if (player == WorldScript.mLocalPlayer) { WorldScript.mLocalPlayer.mInventory.AddItem(itemToStore); return(false); } else { //Give the NETWORK player their items back! player.mInventory.AddItem(itemToStore); //This needs to be communicated to the player, NOT just added to the local version of the inventory return(false); } } if (player.mbIsLocalPlayer) { Color lCol = Color.green; ItemBase lItem = itemToStore; if (lItem.mType == ItemType.ItemCubeStack) { ItemCubeStack lCubeStack = lItem as ItemCubeStack; if (CubeHelper.IsGarbage(lCubeStack.mCubeType)) { lCol = Color.red; } if (CubeHelper.IsSmeltableOre(lCubeStack.mCubeType)) { lCol = Color.green; } } if (lItem.mType == ItemType.ItemStack) { //probably a crafted item of some sort; we could introspect further into bar types lCol = Color.cyan; } if (lItem.mType == ItemType.ItemSingle) { //Minecart lCol = Color.white; } if (lItem.mType == ItemType.ItemCharge) { //Drill head/Minecart lCol = Color.magenta; } if (lItem.mType == ItemType.ItemDurability) { //Drill head lCol = Color.yellow; } if (lItem.mType == ItemType.ItemLocation) { lCol = Color.gray; } FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1, hopper.mnZ, 0.75f, "Stored " + player.GetItemName(lItem), lCol, 1.5f); } player.mInventory.VerifySuitUpgrades(); //we may have just taken a suit upgrade OUT. if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand(InterfaceName, InterfaceStoreItems, null, itemToStore, hopper, 0); } return(true); }
private DigResult AttemptToDig(long checkX, long checkY, long checkZ) { mnCurrentDigSizeY = digArea.CurrentHeight; var segment = mFrustrum != null ? AttemptGetSegment(checkX, checkY, checkZ) : WorldScript.instance.GetSegment(checkX, checkY, checkZ); if (segment == null || !segment.mbInitialGenerationComplete || segment.mbDestroyed) { mrDigDelay = 1f; return(DigResult.Fail); } ushort cube = segment.GetCube(checkX, checkY, checkZ); if (cube == eCubeTypes.CentralPowerHub) { return(DigResult.Dig); } if (cube == mReplaceType) { return(DigResult.Skip); } if (CubeHelper.IsReinforced(cube) && eExcavateState != ExcavateState.ClearAll) { return(DigResult.Dig); } if (CubeHelper.HasEntity((int)cube) && eExcavateState != ExcavateState.ClearAll) { if (cube != eCubeTypes.AlienPlant && cube != eCubeTypes.ArachnidRock) { return(DigResult.Dig); } } if (TerrainData.GetHardness(cube, 0) > 500f) { return(DigResult.Dig); } if (eExcavateState == ExcavateState.ClearGarbage) { if (CubeHelper.IsOre(cube)) { return(DigResult.Dig); } } // Tranqs Creative Survival mod really breaks this call as nearly everything in the game is craftable. if (CraftingManager.IsCraftable(cube) && cube != eCubeTypes.Giger && eExcavateState != ExcavateState.ClearAll) { // ore should never ever be craftable if (!CubeHelper.IsOre(cube)) { return(DigResult.Dig); } } int num = (int)(checkX - segment.baseX); int num2 = (int)(checkY - segment.baseY); int num3 = (int)(checkZ - segment.baseZ); if (num == 0 && base.AttemptGetSegment(checkX - 1L, checkY, checkZ) == null) { return(DigResult.Fail); } if (num == 15 && base.AttemptGetSegment(checkX + 1L, checkY, checkZ) == null) { return(DigResult.Fail); } if (num2 == 0 && base.AttemptGetSegment(checkX, checkY - 1L, checkZ) == null) { return(DigResult.Fail); } if (num2 == 15 && base.AttemptGetSegment(checkX, checkY + 1L, checkZ) == null) { return(DigResult.Fail); } if (num3 == 0 && base.AttemptGetSegment(checkX, checkY, checkZ - 1L) == null) { return(DigResult.Fail); } if (num3 == 15 && base.AttemptGetSegment(checkX, checkY, checkZ + 1L) == null) { return(DigResult.Fail); } ushort mValue = segment.GetCubeData(checkX, checkY, checkZ).mValue; WorldScript.instance.BuildFromEntity(segment, checkX, checkY, checkZ, this.mReplaceType, TerrainData.GetDefaultValue(this.mReplaceType)); this.mrCurrentPower -= this.mrPowerRate; this.mbLocatedBlock = true; this.mnBlocksDestroyed++; if (segment.mbInLocalFrustrum) { if (eDropState == DropState.DropSome) { bool flag = true; if (CubeHelper.IsGarbage(cube) && this.mRand.Next(100) > 5) { flag = false; } if (flag) { Vector3 velocity = new Vector3((float)this.mRand.NextDouble() - 0.5f, 0f, (float)this.mRand.NextDouble() - 0.5f); velocity.x *= 5f; velocity.z *= 5f; ItemManager.DropNewCubeStack(cube, mValue, 1, checkX, checkY, checkZ, velocity); } } if (eDropState == DropState.DropAll) { Vector3 velocity = new Vector3((float)this.mRand.NextDouble() - 0.5f, 0f, (float)this.mRand.NextDouble() - 0.5f); velocity.x *= 5f; velocity.z *= 5f; ItemManager.DropNewCubeStack(cube, mValue, 1, checkX, checkY, checkZ, velocity); } if (eDropState == DropState.DropOre && CubeHelper.IsOre(cube)) { Vector3 velocity = new Vector3((float)this.mRand.NextDouble() - 0.5f, 0f, (float)this.mRand.NextDouble() - 0.5f); velocity.x *= 5f; velocity.z *= 5f; ItemManager.DropNewCubeStack(cube, mValue, 1, checkX, checkY, checkZ, velocity); } this.mrTimeSinceShoot = 0f; } return(DigResult.Dig); }
public static bool TakeItems(Player player, ExtraStorageHoppers hopper, ItemBase item) { //ENABLE/DISABLE FEEDING OF HIVEBIND - ONLY FOR VOID HOPPER if (hopper.GetCubeValue() == 0) { if (hopper.FeedHiveMind) { hopper.FeedHiveMind = false; FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, "Not Feeding Hivemind!", Color.green, 2f); } else { hopper.FeedHiveMind = true; FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, "Feeding Hivemind!", Color.red, 2f); } return(true); } else if (hopper.mnStorageUsed > 0) { ItemBase itemBase; if (item == null) { itemBase = hopper.RemoveFirstInventoryItem(); } else if (item.mType == ItemType.ItemCubeStack) { hopper.TryPartialExtractItemsOrCubes(null, item.mnItemID, (item as ItemCubeStack).mCubeType, (item as ItemCubeStack).mCubeValue, ItemManager.GetCurrentStackSize(item), out itemBase); } else { hopper.TryPartialExtractItems(null, item.mnItemID, ItemManager.GetCurrentStackSize(item), out itemBase); } if (itemBase != null) { Debug.Log("Removing Item from StorageHopper for " + player.mUserName); if (!player.mInventory.AddItem(itemBase)) { if (!hopper.AddItem(itemBase)) { ItemManager.instance.DropItem(itemBase, player.mnWorldX, player.mnWorldY, player.mnWorldZ, Vector3.zero); } return(false); } if (player.mbIsLocalPlayer) { Color lCol = Color.green; if (itemBase.mType == ItemType.ItemCubeStack) { ItemCubeStack itemCubeStack = itemBase as ItemCubeStack; if (CubeHelper.IsGarbage(itemCubeStack.mCubeType)) { lCol = Color.red; } if (CubeHelper.IsSmeltableOre(itemCubeStack.mCubeType)) { lCol = Color.green; } } if (itemBase.mType == ItemType.ItemStack) { lCol = Color.cyan; } if (itemBase.mType == ItemType.ItemSingle) { lCol = Color.white; } if (itemBase.mType == ItemType.ItemCharge) { lCol = Color.magenta; } if (itemBase.mType == ItemType.ItemDurability) { lCol = Color.yellow; } if (itemBase.mType == ItemType.ItemLocation) { lCol = Color.gray; } FloatingCombatTextManager.instance.QueueText(hopper.mnX, hopper.mnY + 1L, hopper.mnZ, 1f, player.GetItemName(itemBase), lCol, 1.5f, 64f); } player.mInventory.VerifySuitUpgrades(); if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand("ExtraStorageHopperWindowNew", "TakeItems", null, itemBase, hopper, 0f); } return(true); } } return(false); }