Example #1
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            Flammable flammable = null;

            WIListResult dialogResult = secondaryResult as WIListResult;

            switch (dialogResult.SecondaryResult)
            {
            case "AddFuel":
                //perform the same check
                if (CanAcceptFuel &&
                    worlditem.Is(WIMode.World | WIMode.Frozen | WIMode.Placed) &&
                    Player.Local.Tool.HasWorldItem &&
                    Player.Local.Tool.worlditem.Is <Flammable>(out flammable))
                {
                    AddFuel(flammable);                                                                            //it will take care of the rest
                }
                break;

            case "Ignite":
                if (Player.Local.Surroundings.IsWorldItemInRange &&
                    Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) &&
                    flammable.IsOnFire)
                {
                    Ignite("Default");
                }
                break;

            default:
                break;
            }
        }
Example #2
0
        public void AttachToBomb(Bomb newBomb)
        {
            bomb = newBomb;
            if (bomb != null)
            {
                AttachedToBomb = true;
            }

            if (AttachedToBomb)
            {
                FuseDoppleganger = WorldItems.GetDoppleganger(State.DopplegangerProps, worlditem.tr, FuseDoppleganger, WIMode.World);
                FuseDoppleganger.transform.localPosition = bomb.FuseOffset;
                //don't let our colliders turn off
                worlditem.ActiveState       = WIActiveState.Active;
                worlditem.ActiveStateLocked = true;
            }

            if (!CanBeFlammable)
            {
                Flammable flammable = null;
                if (worlditem.Is <Flammable> (out flammable))
                {
                    flammable.Finish();
                }
            }

            if (!string.IsNullOrEmpty(State.MissionName))
            {
                Player.Get.AvatarActions.Subscribe(AvatarAction.MissionVariableChange, new ActionListener(MissionVariableChange));
            }
        }
Example #3
0
        public override void OnInitialized()
        {
            DamageOnExplode.SenderName = worlditem.DisplayName;
            Flammable flammable = worlditem.Get <Flammable>();

            flammable.OnDepleted   += OnDepleted;
            flammable.DieOnDepleted = false;                                    //just in case
        }
Example #4
0
 public void AddFuel(Flammable fuelSource)
 {
     if (CanAcceptFuel && fuelSource != this)
     {
         State.TotalFuel += fuelSource.TotalFuel;
         fuelSource.worlditem.RemoveFromGame();
     }
 }
Example #5
0
        public void OnAbsorbWorldItem(WorldItem worlditem)
        {
            Flammable flammable = null;

            if (worlditem.Is <Flammable>(out flammable))
            {
                State.TotalFuel += flammable.State.FuelRemaining;
            }
        }
Example #6
0
        public override void PopulateOptionsList(List <WIListOption> options, List <string> message)
        {
            Flammable flammable = null;

            if (CanAcceptFuel &&
                worlditem.Is(WIMode.World | WIMode.Frozen | WIMode.Placed) &&
                Player.Local.Tool.HasWorldItem &&
                Player.Local.Tool.worlditem.Is <Flammable>(out flammable))
            {
                options.Add(new WIListOption("Add " + flammable.worlditem.DisplayName + " to " + worlditem.DisplayName, "AddFuel"));
            }
            if (Player.Local.Surroundings.IsWorldItemInRange &&
                Player.Local.Surroundings.WorldItemFocus.worlditem.Is <Flammable>(out flammable) &&
                flammable.IsOnFire &&
                !IsOnFire)
            {
                options.Add(new WIListOption("Ignite with " + flammable.worlditem.DisplayName, "Ignite"));
            }
        }
Example #7
0
        public void OnPlayerUseWorldItemSecondary(object secondaryResult)
        {
            WIListResult dialogResult = secondaryResult as WIListResult;

            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.DisplayName + ", " + 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;
            }
        }
Example #8
0
 public override void OnInitialized()
 {
     flammable             = worlditem.Get <Flammable>();
     flammable.OnDepleted += OnDepleted;
 }