Example #1
0
        public virtual void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {                               //this is where we handle skills
            OptionsListDialogResult dialogResult = secondaryResult as OptionsListDialogResult;

            switch (dialogResult.SecondaryResult)
            {
            case "PickPlant":
                PickPlant(true);
                break;

            default:
                break;
            }
        }
Example #2
0
        public void OnPlayerUseWorldItemSecondary(object result)
        {
            OptionsListDialogResult secondaryResult = result as OptionsListDialogResult;

            switch (secondaryResult.SecondaryResult)
            {
            case "Eat":
            case "Drink":
                Eat(this);
                break;

            default:
                break;
            }
        }
Example #3
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            OptionsListDialogResult dialogResult = secondaryResult as OptionsListDialogResult;

            if (dialogResult.SecondaryResult.Contains("Drink"))
            {
                WorldItem worlditem = null;
                if (WorldItems.Get.PackPrefab(mGenericLiquid.PackName, mGenericLiquid.PrefabName, out worlditem))
                {
                    FoodStuff foodStuff = null;
                    if (worlditem.gameObject.HasComponent <FoodStuff>(out foodStuff))
                    {
                        FoodStuff.Drink(foodStuff);
                    }
                }
            }
            else
            {
                LiquidContainer liquidContainer = null;
                if (Player.Local.Tool.IsEquipped && Player.Local.Tool.worlditem.Is <LiquidContainer>(out liquidContainer))
                {
                    LiquidContainerState liquidContainerState = liquidContainer.State;
                    int    numFilled    = 0;
                    string errorMessage = string.Empty;
                    if (liquidContainerState.TryToFillWith(mGenericLiquid, Int32.MaxValue, out numFilled, out errorMessage))
                    {
                        GUIManager.PostInfo("Filled " + liquidContainer.worlditem.DisplayName + " with " + numFilled.ToString() + " " + mGenericLiquid.PrefabName + "(s)");
                        MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                    }
                }
//				IWIBase qsItem = null;
//				if (mOptionsListItems.TryGetValue (dialogResult.SecondaryResult, out qsItem)) {
//					System.Object liquidContainerStateObject = null;
//					if (qsItem.GetStateOf <LiquidContainer> (out liquidContainerStateObject)) {
//						LiquidContainerState liquidContainerState = liquidContainerStateObject as LiquidContainerState;
//						if (liquidContainerState != null) {
//							int numFilled = 0;
//							string errorMessage = string.Empty;
//							if (liquidContainerState.TryToFillWith (mGenericLiquid, Int32.MaxValue, out numFilled, out errorMessage)) {
//								GUIManager.PostInfo ("Filled " + qsItem.DisplayName + " with " + numFilled.ToString () + " " + mGenericLiquid.PrefabName + "(s)");
//								MasterAudio.PlaySound (MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
//							}
//						}
//					}
//				}
            }
            mOptionsListItems.Clear();
        }
Example #4
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            OptionsListDialogResult dialogResult = secondaryResult as OptionsListDialogResult;

            switch (dialogResult.SecondaryResult)
            {
            case "PourOnSelf":
                MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                Player.Local.Status.RemoveCondition("BurnedByFire");
                Player.Local.Status.AddCondition("Wet");
                State.Contents.Clear();
                break;

            case "Drink":
                WorldItem liquid = null;
                if (WorldItems.Get.PackPrefab(State.Contents.PackName, State.Contents.PrefabName, out liquid))                                                                  //this is tricky - we want to drink it without destroying the prefab
                {
                    FoodStuff foodstuff = null;
                    if (liquid.Is <FoodStuff>(out foodstuff))                                                                                   //DON'T consume the foodstuff!
                    {
                        FoodStuff.Drink(foodstuff);
                        State.Contents.InstanceWeight--;
                        GUIManager.PostInfo("Drank 1 " + State.Contents.PrefabName + ", " + State.Contents.InstanceWeight.ToString() + "/" + State.Capacity.ToString() + " left.");
                    }
                }
                break;

            case "Pour Out":
                //two options here
                //if we're in the inventory then we want to add our contents to the selected stack
                //if we're in the world we want to dump it into the world
                bool playSound = false;
                if (PrimaryInterface.IsMaximized("Inventory"))
                {
                    WIStack selectedStack = Player.Local.Inventory.SelectedStack;
                    if (Stacks.Can.Stack(selectedStack, State.Contents))
                    {
                        WIStackError error = WIStackError.None;
                        for (int i = 0; i < State.Contents.InstanceWeight; i++)
                        {
                            StackItem contents = State.Contents.ToStackItem();
                            if (!Stacks.Push.Item(selectedStack, contents, ref error))
                            {
                                break;
                            }
                            else
                            {
                                playSound = true;
                            }
                        }
                    }
                }
                else
                {
                    State.Contents.Clear();
                    GUIManager.PostInfo("Discarded contents");
                    if (Player.Local.Surroundings.IsWorldItemInRange)
                    {
                        Flammable flammable = null;
                        if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) && flammable.IsOnFire)
                        {
                            flammable.Extinguish();
                        }
                    }
                    playSound = true;
                }
                if (playSound)
                {
                    MasterAudio.PlaySound(MasterAudio.SoundType.PlayerInterface, "FillLiquidContainer");
                }
                break;

            default:
                break;
            }
        }