Beispiel #1
0
    private void OnParticleCollision(GameObject other)
    {
        Flammable flammable = other.GetComponent <Flammable>();

        if (flammable)
        {
            flammable.Extinguish(power);
        }
    }
Beispiel #2
0
    private void ExtinguishFireFlammable(Vector3Int startPos, int floor)
    {
        Queue <Vector3Int>   searchQueue   = new Queue <Vector3Int>();
        HashSet <Vector3Int> searchHistory = new HashSet <Vector3Int>();

        searchQueue.Enqueue(startPos);
        searchHistory.Add(startPos);

        while (searchQueue.Count > 0)
        {
            Vector3Int pos = searchQueue.Dequeue();
            Vector3Int nPos;

            Flammable flammable = GetFlammable(pos, floor);
            flammable.Extinguish();

            nPos = pos + Vector3Int.up;
            if (flammable.isConnectedUp && !searchHistory.Contains(nPos))
            {
                searchQueue.Enqueue(nPos);
                searchHistory.Add(nPos);
            }

            nPos = pos + Vector3Int.down;
            if (flammable.isConnectedDown && !searchHistory.Contains(nPos))
            {
                searchQueue.Enqueue(nPos);
                searchHistory.Add(nPos);
            }

            nPos = pos + Vector3Int.left;
            if (flammable.isConnectedLeft && !searchHistory.Contains(nPos))
            {
                searchQueue.Enqueue(nPos);
                searchHistory.Add(nPos);
            }

            nPos = pos + Vector3Int.right;
            if (flammable.isConnectedRight && !searchHistory.Contains(nPos))
            {
                searchQueue.Enqueue(nPos);
                searchHistory.Add(nPos);
            }
        }
    }
Beispiel #3
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;
            }
        }