public WIStack HoldTemporaryItem(IWIBase itemToHold) { //create a temporary item stack if we don't have one if (mTemporaryItemEnabler == null) { if (CharacterInventoryGroup == null) { //if we don't have a character group, we'll need to create it to store our stuff CharacterInventoryGroup = WIGroups.GetOrAdd(worlditem.FileName, WIGroups.Get.World, worlditem); } //make sure the group is loaded CharacterInventoryGroup.Load(); mTemporaryItemEnabler = Stacks.Create.StackEnabler(CharacterInventoryGroup); mTemporaryItemEnabler.UseRawContainer = true; } else { //drop anything we're holding currently DropTemporaryItem(); } return(Stacks.Display.ItemInContainer(itemToHold, mTemporaryItemEnabler.EnablerContainer)); }
public static int CalculateLocalPrice(int baseValue, IWIBase item) { if (item == null) { return(baseValue); } object weaponStateObject = null; if (item.GetStateOf <Weapon>(out weaponStateObject)) { WeaponState w = (WeaponState)weaponStateObject; if (w != null) { //Debug.Log("Adding to base value of weapon, " + baseValue.ToString()); float delays = w.BaseSwingDelay + w.BaseWindupDelay + w.BaseEquipInterval + w.BaseHitInterval + w.BaseSwingDuration + w.BaseSwingRate + w.BaseImpactTime; baseValue += Mathf.CeilToInt(Mathf.Clamp(20f - delays, 0f, Mathf.Infinity) * Globals.BaseValueWeaponDelayInterval); baseValue += Mathf.CeilToInt(w.BaseDamagePerHit * Globals.BaseValueWeaponDamagePerHit); baseValue += Mathf.CeilToInt(w.BaseForcePerHit * Globals.BaseValueWeaponForcePerHit); baseValue += Mathf.CeilToInt(0.5f - w.BaseStrengthDrain * Globals.BaseValueWeaponStrengthDrain); if (w.HasBeenImproved) { baseValue = baseValue * w.NumTimesImproved; } baseValue += w.NumTimesUsedSuccessfully; baseValue += w.NumTimesKilledTarget * 10; if (!string.IsNullOrEmpty(w.ProjectileType)) { baseValue = Mathf.CeilToInt(baseValue * Globals.BaseValueWeaponProjectileMultiplier); } } } else { Debug.Log("Couldn't get state"); } return(baseValue); }
public void FinishChecking(IWIBase iwiBase) { mLoadingStackItem = false; if (iwiBase == null) { FinishedChecking = true; HasCompleted = false; return; } System.Object structureStateObject = null; if (iwiBase.GetStateOf <Structure> (out structureStateObject)) { StructureState structureState = (StructureState)structureStateObject; HasCompleted = Flags.Check((uint)LoadState, (uint)structureState.LoadState, Flags.CheckType.MatchAll); if (HasCompleted) { Status |= MissionStatus.Completed; } } FinishedChecking = true; }
public override void SetProperties() { DisplayMode = SquareDisplayMode.Empty; MouseoverHover = false; DopplegangerMode = WIMode.Stacked; ShowDoppleganger = false; DopplegangerProps.State = "Default"; if (IsEnabled) { DisplayMode = SquareDisplayMode.Enabled; if (HasItemsToOffer) { MouseoverHover = true; ShowDoppleganger = true; IWIBase topItem = Goods.TopItem; DopplegangerProps.CopyFrom(topItem); if (IsStolen) { DisplayMode = SquareDisplayMode.Error; } } } }
protected override void OnUseFinish() { if (ProgressCanceled) { LastCallback.SafeInvoke(); return; } if (LastUseImmune) { //don't do anything if skill immunity was used return; } bool removedItem = false; bool attachScript = false; IWIBase finalItem = null; string scriptToAttach = string.Empty; if (State.HasBeenMastered && !string.IsNullOrEmpty(Extensions.AttachScriptOnUseUnmastered)) { scriptToAttach = Extensions.AttachScriptOnUseMastered; } else if (!string.IsNullOrEmpty(Extensions.AttachScriptOnUseUnmastered)) { scriptToAttach = Extensions.AttachScriptOnUseUnmastered; } //if we only target certain scripts for failure and this one doesn't have at least one of those scripts, treat it as a win if (Extensions.FailureTargetScripts.Count > 0) { if (MoveItemToInventory) { if (!LastItemToMove.HasAtLeastOne(Extensions.FailureTargetScripts)) { LastSkillResult = true; } } else { if (!LastFromStack.TopItem.HasAtLeastOne(Extensions.FailureTargetScripts)) { LastSkillResult = true; } } } try { WIStackError error = WIStackError.None; if (LastSkillResult) { attachScript = Extensions.AttachScriptOnSuccess; //we either add it based on inventory or else stacks if (MoveItemToInventory) { Debug.Log("Adding to inventory, we were successful"); //convert it to a stack item BEFORE pushing it so we know we'll have the actual copy finalItem = LastItemToMove.GetStackItem(WIMode.Unloaded); StartCoroutine(LastInventory.AddItem(finalItem)); removedItem = true; } else { finalItem = LastFromStack.TopItem; removedItem = (Stacks.Pop.AndPush(LastFromStack, LastToStack, ref error)); } if (State.HasBeenMastered) { GUIManager.PostSuccess(Extensions.GUIMessageOnSuccessMastered); } else { GUIManager.PostSuccess(Extensions.GUIMessageOnSuccessUnmastered); } } else { attachScript = Extensions.AttachScriptOnFail; if (MoveItemToInventory) { //we're moving things into our inventory if (Extensions.DestroyItemOnFail) { //Debug.Log("Destroying item on failure"); LastItemToMove.RemoveFromGame(); removedItem = true; //don't attach a script because there's nothing to attach it to } else if (Extensions.SubstituteItemOnFail) { //Debug.Log("Adding substitution instead"); LastItemToMove.RemoveFromGame(); finalItem = Extensions.Substitution.ToStackItem(); StartCoroutine(LastInventory.AddItem(finalItem)); removedItem = true; } else if (Extensions.MoveItemOnFail) { Debug.Log("Failed, but still moving item - item null? " + (LastItemToMove == null).ToString()); finalItem = LastItemToMove.GetStackItem(WIMode.Unloaded); StartCoroutine(LastInventory.AddItem(finalItem)); removedItem = true; } } else { //we're moving things from stack to stack if (Extensions.DestroyItemOnFail) { //just get rid of it Stacks.Pop.AndToss(LastFromStack); removedItem = true; } else if (Extensions.SubstituteItemOnFail) { //just get rid of it Stacks.Pop.AndToss(LastFromStack); removedItem = true; //then put substitute item in other stack //only attach a script if we actually push the item finalItem = Extensions.Substitution.ToStackItem(); removedItem = Stacks.Push.Item(LastToStack, finalItem, ref error); } else if (Extensions.MoveItemOnFail) { finalItem = LastFromStack.TopItem; removedItem = Stacks.Pop.AndPush(LastFromStack, LastToStack, ref error); } } if (finalItem == null) { Debug.Log("Final item was null in remove item skill, not applying extensions"); } else { if (Extensions.UnskilledRepPenaltyOnFail > 0 || Extensions.SkilledRepPenaltyOnFail > 0) { //only do this if we CAN suffer a rep loss int globalRepLoss = 0; int ownerRepLoss = 0; if (State.HasBeenMastered) { globalRepLoss = Mathf.Max(1, Mathf.FloorToInt( (finalItem.BaseCurrencyValue * Globals.BaseCurrencyToReputationMultiplier) * Mathf.Lerp(Extensions.UnskilledRepPenaltyOnFail, Extensions.SkilledRepPenaltyOnFail, State.NormalizedMasteryLevel) * Extensions.MasterRepPenaltyOnFail)); ownerRepLoss = Mathf.Max(1, Mathf.FloorToInt( (finalItem.BaseCurrencyValue * Globals.BaseCurrencyToReputationMultiplier) * Mathf.Lerp(Extensions.UnskilledOwnerRepPenaltyOnFail, Extensions.SkilledOwnerRepPenaltyOnFail, State.NormalizedMasteryLevel) * Extensions.MasterOwnerRepPenaltyOnFail)); GUIManager.PostDanger(Extensions.GUIMessageOnFailureMastered); } else { globalRepLoss = Mathf.Max(1, Mathf.FloorToInt( (finalItem.BaseCurrencyValue * Globals.BaseCurrencyToReputationMultiplier) * Mathf.Lerp(Extensions.UnskilledRepPenaltyOnFail, Extensions.SkilledRepPenaltyOnFail, State.NormalizedMasteryLevel))); ownerRepLoss = Mathf.Max(1, Mathf.FloorToInt( (finalItem.BaseCurrencyValue * Globals.BaseCurrencyToReputationMultiplier) * Mathf.Lerp(Extensions.UnskilledOwnerRepPenaltyOnFail, Extensions.SkilledOwnerRepPenaltyOnFail, State.NormalizedMasteryLevel))); GUIManager.PostDanger(Extensions.GUIMessageOnFailureUnmastered); } Profile.Get.CurrentGame.Character.Rep.LoseGlobalReputation(globalRepLoss); //see if we've just stolen from a character Character character = null; if (LastSkillTarget != null && LastSkillTarget.IOIType == ItemOfInterestType.WorldItem && LastSkillTarget.worlditem.Is <Character>(out character)) { Profile.Get.CurrentGame.Character.Rep.LosePersonalReputation(character.worlditem.FileName, character.worlditem.DisplayName, ownerRepLoss); } } } } } catch (Exception e) { Debug.LogWarning("Couldn't move item because: " + e.ToString()); } if (attachScript && finalItem != null && !string.IsNullOrEmpty(scriptToAttach)) { //Debug.Log("Attaching script " + scriptToAttach + " to final item"); finalItem.Add(scriptToAttach); } if (removedItem) { if (LastSkillResult) { MasterAudio.PlaySound(Extensions.SoundTypeOnSuccess, Extensions.SoundOnSuccess); } else { MasterAudio.PlaySound(Extensions.SoundTypeOnFailure, Extensions.SoundOnFailure); } } LastCallback.SafeInvoke(); }
public override void OnClickSquare() { if (!IsEnabled) { return; } bool result = false; bool pickUp = false; bool playSound = false; bool playErrorSound = false; WIStackError error = WIStackError.None; if (Player.Local.Inventory.SelectedStack.HasTopItem) { Wearable wearable = null; IWIBase topItem = Player.Local.Inventory.SelectedStack.TopItem; if (Wearable.CanWear(Type, BodyPart, Orientation, topItem)) { if (mStack.HasTopItem) { if (Stacks.Swap.Stacks(mStack, Player.Local.Inventory.SelectedStack, ref error)) { pickUp = true; playSound = true; result = true; } else { result = false; playSound = true; } } else { Stacks.Add.Items(Player.Local.Inventory.SelectedStack, mStack, ref error); playSound = true; result = true; } } else { result = false; playErrorSound = true; } } else { Stacks.Add.Items(mStack, Player.Local.Inventory.SelectedStack, ref error); pickUp = true; playSound = true; result = true; } if (playSound) { if (pickUp) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "InventoryPickUpStack"); } else { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "InventoryPlaceStack"); } } else if (playErrorSound) { MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "ButtonClickDisabled"); } RefreshRequest(); }
public void AddCreature(IWIBase creature) { return; }
public void AquireLastOffer() { if (LastOfferItems == null || string.IsNullOrEmpty(LastOfferType)) { return; } Player.Local.Inventory.InventoryBank.AddBaseCurrencyOfType(LastOfferMade, WICurrencyType.A_Bronze); for (int i = 0; i < LastOfferItems.Count; i++) { mLastOfferItem = LastOfferItems[i]; //update which items we've aquired switch (LastOfferType) { case "UndatedShard": ActiveMuseum.UndatedShardAquired++; break; case "UndatedSmall": ActiveMuseum.UndatedSmallAquired++; break; case "DatedShard": if (mLastOfferItem.GetStateOf <ArtifactShard>(out mArtifactStateObject)) { mArtifactShardState = (ArtifactShardState)mArtifactStateObject; ActiveMuseum.DatedShardsAquired.Add(mArtifactShardState.Age); } break; case "DatedSmall": if (mLastOfferItem.GetStateOf <Artifact>(out mArtifactStateObject)) { mArtifactState = (ArtifactState)mArtifactStateObject; ArtifactQuality currentQuality; if (!ActiveMuseum.SmallArtifactsAquired.TryGetValue(mArtifactState.Age, out currentQuality)) { //if we haven't alread aquired this age add it now ActiveMuseum.SmallArtifactsAquired.Add(mArtifactState.Age, mArtifactState.Quality); } else if (IsOfHigherQuality(mArtifactState.Quality, currentQuality)) { //set the existing entry to the newer level of quality ActiveMuseum.SmallArtifactsAquired[mArtifactState.Age] = mArtifactState.Quality; } } break; case "DatedLarge": if (mLastOfferItem.GetStateOf <Artifact>(out mArtifactStateObject)) { mArtifactState = (ArtifactState)mArtifactStateObject; ArtifactQuality currentQuality; if (!ActiveMuseum.LargeArtifactsAquired.TryGetValue(mArtifactState.Age, out currentQuality)) { //if we haven't alread aquired this age add it now ActiveMuseum.LargeArtifactsAquired.Add(mArtifactState.Age, mArtifactState.Quality); } else if (IsOfHigherQuality(mArtifactState.Quality, currentQuality)) { //set the existing entry to the newer level of quality ActiveMuseum.LargeArtifactsAquired[mArtifactState.Age] = mArtifactState.Quality; } } break; default: Debug.Log("Couldn't find artifact type " + LastOfferType); break; } //destroy it - the curator will disply a doppleganger mLastOfferItem.RemoveFromGame(); } Mods.Get.Runtime.SaveMod(ActiveMuseum, "Museum", ActiveMuseum.Name); LastOfferItems.Clear(); UndatedShard.Clear(); UndatedSmall.Clear(); DatedShard.Clear(); DatedSmall.Clear(); DatedLarge.Clear(); //this will force the containers to update their newly missing items GUI.GUIInventoryInterface.Get.RefreshContainers(); RefreshCuratedItems(); }
public IEnumerator AddItem(IWIBase item) { yield break; }
//this is used in a lot of places //eg in player inventory squares for crafting to check if the thing you've put in the square meets requirements public static bool AreRequirementsMet(IWIBase item, GenericWorldItem template, BlueprintStrictness strictness, int numItemsInStack, out int maxItemsToCraft) { maxItemsToCraft = 1; if (item != null && item.IsQuestItem) { return(false); } bool prefabReqsMet = true; bool stackReqsMet = true; bool stateReqsMet = true; bool subCatReqsMet = true; //first we need to get the thing we're crafting from //if it's a liquid container we need to get the state data if (item.Is <LiquidContainer> ()) { LiquidContainerState stateData = null; bool foundState = false; if (item.IsWorldItem) { stateData = item.worlditem.Get <LiquidContainer> ().State; foundState = true; } else { if (item.GetStackItem(WIMode.None).GetStateData <LiquidContainerState> (out stateData)) { foundState = true; } } if (foundState) { //see if the liquid container contains what's needed mCheckRequirements.CopyFrom(stateData.Contents); mCheckRequirements.InstanceWeight = stateData.Contents.InstanceWeight; } } else { //if it's not a liquid container just get it from the item mCheckRequirements.CopyFrom(item); mCheckRequirements.InstanceWeight = numItemsInStack; } if (Flags.Check((uint)strictness, (uint)BlueprintStrictness.PrefabName, Flags.CheckType.MatchAny)) { prefabReqsMet = string.Equals(mCheckRequirements.PrefabName, template.PrefabName, StringComparison.InvariantCultureIgnoreCase); } if (Flags.Check((uint)strictness, (uint)BlueprintStrictness.StackName, Flags.CheckType.MatchAny)) { stackReqsMet = string.Equals(mCheckRequirements.StackName, template.StackName, StringComparison.InvariantCultureIgnoreCase); if (!stackReqsMet) { try { //check for the rare case where a non-numbered item is compared against a numbered item //'x #' vs 'x' //'x' vs 'x #' bool isReqDigit = char.IsDigit(mCheckRequirements.StackName, mCheckRequirements.StackName.Length - 1); bool isItemDigit = char.IsDigit(template.StackName, template.StackName.Length - 1); if (isReqDigit != isItemDigit) { string nonNumbered = isItemDigit ? mCheckRequirements.StackName : template.StackName; string numbered = isReqDigit ? mCheckRequirements.StackName.Substring(0, mCheckRequirements.StackName.Length - 2) : template.StackName.Substring(0, template.StackName.Length - 2); stackReqsMet = nonNumbered.Equals(numbered); #if UNITY_EDITOR Debug.Log("Checking numbered against non-numbered in crafting: " + mCheckRequirements.StackName + " vs " + template.StackName + " - check " + nonNumbered + ", " + numbered + " - " + stackReqsMet.ToString()); #endif } } catch (Exception e) { Debug.LogError("Error when checking for item digits in crafting skill: " + e.ToString()); } } } if (Flags.Check((uint)strictness, (uint)BlueprintStrictness.StateName, Flags.CheckType.MatchAny)) { if ((string.IsNullOrEmpty(mCheckRequirements.State) || string.IsNullOrEmpty(template.State)) || (mCheckRequirements.State.Equals("Default") || template.State.Equals("Default"))) { stateReqsMet = true; } else { stateReqsMet = string.Equals(mCheckRequirements.State, template.State, StringComparison.InvariantCultureIgnoreCase); } } if (Flags.Check((uint)strictness, (uint)BlueprintStrictness.Subcategory, Flags.CheckType.MatchAny)) { if (string.IsNullOrEmpty(mCheckRequirements.Subcategory) || string.IsNullOrEmpty(template.Subcategory)) { subCatReqsMet = true; } else { subCatReqsMet = string.Equals(mCheckRequirements.Subcategory, template.Subcategory, StringComparison.InvariantCultureIgnoreCase); } } #if UNITY_EDITOR Debug.Log(template.PrefabName + " prefab reqs met: " + prefabReqsMet.ToString() + "\nstackReqsMet: " + stackReqsMet.ToString() + "\nstateReqsMet: " + stateReqsMet.ToString() + "\nsubCatReqsMet: " + subCatReqsMet.ToString()); #endif //max items to craft is the instance weight divided by instance weight of the template //instance weight of template tells us how many we need in that stack to craft maxItemsToCraft = mCheckRequirements.InstanceWeight / template.InstanceWeight; //if we have enough items to craft, we can proceed return(prefabReqsMet && stackReqsMet && stateReqsMet && subCatReqsMet && maxItemsToCraft >= template.InstanceWeight); }
public bool AddItems(IWIBase item, int numToAdd, ref int numAdded) { return(false); }
public void RecalculateValueOfGoods(BarterParty party, bool recalculateItems) { if (!IsActive) { TotalValueCharacterGoods = 0; TotalValuePlayerGoods = 0; BaseValueCharacterGoods = 0; BaseValuePlayerGoods = 0; return; } List <BarterGoods> goods = CharacterGoods; if (party == BarterParty.Player) { goods = PlayerGoods; } if (goods.Count == 0) { BaseValueCharacterGoods = 0; BaseValuePlayerGoods = 0; } else if (recalculateItems) { float baseValueOfGoods = 0; foreach (BarterGoods good in goods) { int numItems = good.NumItems; if (numItems > 0) { IWIBase topItem = good.TopItem; float goodBaseValue = topItem.BaseCurrencyValue; if (topItem.Is <Stolen> ()) { goodBaseValue *= Globals.StolenGoodsValueMultiplier; } baseValueOfGoods += goodBaseValue * numItems; } } if (party == BarterParty.Player) { BaseValuePlayerGoods = baseValueOfGoods; } else { BaseValueCharacterGoods = baseValueOfGoods; } } float repPriceModifier = 0f; ReputationState rep = null; if (IsBarteringWithCharacter) { rep = Profile.Get.CurrentGame.Character.Rep.GetReputation(BarteringCharacter.worlditem.FileName); repPriceModifier = rep.NormalizedOffsetReputation; //this will be a value from -1 to 1 } else { repPriceModifier = Profile.Get.CurrentGame.Character.Rep.NormalizedOffsetGlobalReputation; } float skillPriceModifier = BarterManager.State.NormalizedOffsetUsageLevel; //this will be a value from -1 to 1 float regionPriceModifier = 0f; float goodsPriceModifier = (repPriceModifier + skillPriceModifier + regionPriceModifier) / 2f; if (BarterManager.HasBeenMastered) { //mastering the barter skill reduces all penalties to zero goodsPriceModifier = Mathf.Max(0, goodsPriceModifier); } goodsPriceModifier *= Globals.BarterMaximumPriceModifier; //divide the final modifier by 2 to get its effects on both sets of goods TotalValuePlayerGoods = Mathf.FloorToInt(BaseValuePlayerGoods + (BaseValuePlayerGoods * (goodsPriceModifier / 2f))); TotalValueCharacterGoods = Mathf.FloorToInt(BaseValueCharacterGoods - (BaseValueCharacterGoods * (goodsPriceModifier / 2f))); //the value of currency is not affected by reputation or skill TotalValuePlayerGoods += PlayerGoodsBank.BaseCurrencyValue; TotalValueCharacterGoods += CharacterGoodsBank.BaseCurrencyValue; ReputationPriceModifier = repPriceModifier; SkillPriceModifier = skillPriceModifier; FinalPriceModifier = goodsPriceModifier; RefreshAction.SafeInvoke(); }
public override void TryToRemoveItem(IStackOwner skillUseTarget, IWIBase worldItemToMove, IInventory toInventory, Action callBack, int flavor) { //instead of attempting to remove it now //this skill launched the barter dialog //and sets up a session if (flavor == BuyFlavor) { int baseCurrencyValue = Mathf.CeilToInt(worldItemToMove.BaseCurrencyValue); if (Player.Local.Inventory.InventoryBank.CanAfford(baseCurrencyValue)) { Player.Local.Inventory.InventoryBank.TryToRemove(baseCurrencyValue); worldItemToMove.Add("OwnedByPlayer"); WIStackError error = WIStackError.None; if (!Player.Local.Inventory.AddItems(worldItemToMove, ref error)) { Player.Local.ItemPlacement.ItemForceCarry(worldItemToMove.worlditem); } //improve rep with shopkeeper Profile.Get.CurrentGame.Character.Rep.GainPersonalReputation(skillUseTarget.FileName, skillUseTarget.DisplayName, Globals.ReputationChangeTiny); return; } else { GUIManager.PostInfo("You can't afford that."); return; } } else { IInventory barterInventory = null; Character character = null; //this only works with character-owned items if (skillUseTarget.IsWorldItem && skillUseTarget.worlditem.Is <Character> (out character)) { barterInventory = character; //make sure we can actually barter with the player ReputationState rep = Profile.Get.CurrentGame.Character.Rep.GetReputation(character.worlditem.FileName); if (rep.NormalizedReputationDifference(Profile.Get.CurrentGame.Character.Rep.GlobalReputation) > Extensions.MaxNormaliedReputationDifference) { GUIManager.PostWarning(character.worlditem.DisplayName + " is not interested in bartering with you."); return; } if (mCurrentSession == null) { mCurrentSession = new BarterSession(this, mCharacterGoods, mPlayerGoods); } mCurrentSession.Reset(Player.Local.Inventory, barterInventory); mCurrentSession.BarteringCharacter = character; //add the selected goods to the current session immediately //so it's there when we start bartering mCurrentSession.CharacterStartupItem = worldItemToMove; WIStack startupStack = null; //if the startup item is already in the character's inventory //no need to create a startup stack //but if it isn't we'll need the startup stack to display it if (!character.HasItem(worldItemToMove, out startupStack)) { //TODO put entire container in inventory Debug.Log("Item " + worldItemToMove.FileName + " was NOT in character's inventory, creating temporary startup stack"); mCurrentSession.CharacterStartupStack = character.HoldTemporaryItem(worldItemToMove); } SpawnBarterDialog(); } } }
public bool RemoveGoods(BarterParty party, IWIBase goodToRemove, int numToRemove) { if (goodToRemove == null || numToRemove == 0) { return(false); } List <BarterGoods> goods = null; if (party == BarterParty.Player) { goods = PlayerGoods; } else { goods = CharacterGoods; } List <KeyValuePair <BarterGoods, WIStack> > goodStacksToRemove = new List <KeyValuePair <BarterGoods, WIStack> > (); List <KeyValuePair <KeyValuePair <BarterGoods, WIStack>, int> > goodStacksToUpdate = new List <KeyValuePair <KeyValuePair <BarterGoods, WIStack>, int> > (); foreach (BarterGoods good in goods) { foreach (KeyValuePair <WIStack, int> goodPair in good) { if (Stacks.Can.Stack(goodPair.Key, goodToRemove)) { if (numToRemove <= 1) { //simple removal int numItems = goodPair.Value; numItems--; if (numItems <= 0) { goodStacksToRemove.Add(new KeyValuePair <BarterGoods, WIStack> (good, goodPair.Key)); } else { goodStacksToUpdate.Add(new KeyValuePair <KeyValuePair <BarterGoods, WIStack>, int> (new KeyValuePair <BarterGoods, WIStack> (good, goodPair.Key), numItems)); } break; } else { //TODO removal of multiple items across multiple stacks } } } } foreach (KeyValuePair <BarterGoods, WIStack> goodStackToRemove in goodStacksToRemove) { goodStackToRemove.Key.Remove(goodStackToRemove.Value); } foreach (KeyValuePair <KeyValuePair <BarterGoods, WIStack>, int> goodToUpdate in goodStacksToUpdate) { goodToUpdate.Key.Key [goodToUpdate.Key.Value] = goodToUpdate.Value; } //recaluclate our total values RecalculateValueOfGoods(party, true); //update squares and interface RefreshAction.SafeInvoke(); return(true); }
public static int CalculateLocalPrice(int basePrice, IWIBase item) { if (item == null) { Debug.Log("Local price in recepticle null, returning"); return(basePrice); } int sizeMult = (int)item.Size; int matMult = 1; WIMaterialType mat = WIMaterialType.Dirt; if (item.IsWorldItem) { mat = item.worlditem.Props.Global.MaterialType; } else { mat = item.GetStackItem(WIMode.None).GlobalProps.MaterialType; } switch (mat) { case WIMaterialType.Stone: matMult = 10; break; case WIMaterialType.Bone: matMult = 15; break; case WIMaterialType.Crystal: matMult = 20; break; case WIMaterialType.Fabric: matMult = 3; break; case WIMaterialType.Glass: matMult = 8; break; case WIMaterialType.Wood: matMult = 7; break; case WIMaterialType.Plant: matMult = 11; break; case WIMaterialType.Metal: matMult = 13; break; default: break; } basePrice *= sizeMult; basePrice *= matMult; if (item.IsStackContainer) { for (int i = 0; i < item.StackContainer.StackList.Count; i++) { for (int j = 0; j < item.StackContainer.StackList [i].Items.Count; j++) { basePrice += Mathf.CeilToInt(item.StackContainer.StackList [i].Items [j].BaseCurrencyValue); } } } return(basePrice); }
public void RefreshAvailableArtifacts() { UndatedShard.Clear(); UndatedSmall.Clear(); DatedShard.Clear(); DatedSmall.Clear(); DatedLarge.Clear(); mAvailableArtifacts.Clear(); //this goes through the player's inventory and looks for //anything they can sell to the museum //this is used by converstions to search the player's inventory once //instead of for every exchange Player.Local.Inventory.FindItemsOfType("Artifact", mAvailableArtifacts); for (int i = 0; i < mAvailableArtifacts.Count; i++) { mCurrentArtifact = mAvailableArtifacts[i]; if (mCurrentArtifact.GetStateOf <Artifact>(out mArtifactStateObject)) { mArtifactState = (ArtifactState)mArtifactStateObject; //check if it's dated or not if (mArtifactState.HasBeenDated) { if (mCurrentArtifact.StackName.Contains("Large")) { DatedLarge.SafeAdd(mCurrentArtifact); } else { DatedSmall.SafeAdd(mCurrentArtifact); } } else { UndatedSmall.SafeAdd(mCurrentArtifact); } } } mAvailableArtifacts.Clear(); Player.Local.Inventory.FindItemsOfType("ArtifactShard", mAvailableArtifacts); for (int i = 0; i < mAvailableArtifacts.Count; i++) { mCurrentArtifact = mAvailableArtifacts[i]; if (mCurrentArtifact.GetStateOf <ArtifactShard>(out mArtifactStateObject)) { mArtifactShardState = (ArtifactShardState)mArtifactStateObject; //check if it's dated or not if (mArtifactState.HasBeenDated) { DatedShard.SafeAdd(mCurrentArtifact); } else { UndatedShard.SafeAdd(mCurrentArtifact); } } } /* * Debug.Log("Found " + UndatedShardAvailable.ToString() + " Undated Shard Available"); * Debug.Log("Found " + UndatedSmallAvailable.ToString() + " Undated Small Available"); * Debug.Log("Found " + DatedShardAvailable.ToString() + " Dated Shard Available"); * Debug.Log("Found " + DatedSmallAvailable.ToString() + " Dated Small Available"); * Debug.Log("Found " + DatedLargeAvailable.ToString() + " Dated Large Available"); */ }
public static bool CanWear(WearableType type, BodyPartType bodyPart, BodyOrientation orientation, IWIBase itemBase) { WorldItem item = null; if (itemBase.IsWorldItem) { item = itemBase.worlditem; } else { //use the item to get the template WorldItem prefab = null; WorldItems.Get.PackPrefab(itemBase.PackName, itemBase.PrefabName, out item); } if (item == null) { //whoops, not sure what went wrong here return(false); } bool result = false; Wearable wearable = null; if (item.worlditem.Is <Wearable>(out wearable)) { bool matchesType = Flags.Check((uint)wearable.Type, (uint)type, Flags.CheckType.MatchAny); bool matchesOrientation = (wearable.Orientation == BodyOrientation.None && orientation == BodyOrientation.None) || Flags.Check((uint)wearable.Orientation, (uint)orientation, Flags.CheckType.MatchAny); bool matchesBodyPart = wearable.BodyPart == bodyPart; //Debug.Log("Matches type? " + matchesType.ToString() + " matches orientation? " + matchesOrientation.ToString() + " matchesBodyPart? " + matchesBodyPart.ToString()); result = matchesType & matchesOrientation & matchesBodyPart; } else { Debug.Log("World item " + itemBase.FileName + " is not wearable"); } return(result); }
public int CalculateValueOfArtifact(IWIBase artifact) { return(Mathf.FloorToInt(artifact.BaseCurrencyValue)); }
public void OpenStackContainer(IWIBase containerItem) { Visible = true; StartCoroutine(OpenStackContainerOverTime(containerItem)); }
public bool IsCraftable(IWIBase craftableItem, out string blueprintName) { blueprintName = string.Empty; return(false); }