Example #1
0
        public bool Save()
        {
            Reach.CampaignSave saveData      = _saveManager.SaveData;
            Reach.BipedObject  selectedBiped = ((ComboBoxItem)cBBipeds.SelectedItem).Tag as Reach.BipedObject;
            if (selectedBiped != null)
            {
                saveData.Player.ChangeBiped(selectedBiped, (bool)cBWeapTransfer.IsChecked);
            }

            Reach.BipedObject playerBiped = saveData.Player.Biped;
            playerBiped.MakeInvincible((bool)checkInvincible.IsChecked);
            playerBiped.NoFallDamage = (bool)checkNoFallDamage.IsChecked;
            if (playerBiped.Vehicle != null)
            {
                playerBiped.Vehicle.MakeInvincible((bool)checkInvincible.IsChecked);
                playerBiped.Vehicle.NoFallDamage = (bool)checkNoFallDamage.IsChecked;
            }
            playerBiped.PhysicsEnabled = !(bool)checkNoPhysics.IsChecked;

            playerBiped.X = Convert.ToSingle(txtPlayerXCord.Text);
            playerBiped.Y = Convert.ToSingle(txtPlayerYCord.Text);
            playerBiped.Z = Convert.ToSingle(txtPlayerZCord.Text);

            return(true);
        }
Example #2
0
        public static HashSet <Reach.BipedObject> FindSwappableBipeds(Reach.CampaignSave saveData)
        {
            Reach.BipedObject           currentBiped    = saveData.Player.Biped;
            HashSet <Reach.BipedObject> availableBipeds = new HashSet <Reach.BipedObject>();

            foreach (Reach.GameObject obj in saveData.Objects)
            {
                if (obj != null && !obj.Deleted && obj.TagGroup == Reach.TagGroup.Bipd && obj.Zone == currentBiped.Zone && obj.IsActive)
                {
                    availableBipeds.Add((Reach.BipedObject)obj);
                }
            }
            return(availableBipeds);
        }
Example #3
0
        public void Load()
        {
            _loading = true;
            BuildWeaponLists();

            for (int i = 1; i < _weaponBoxes.Length; i++)
            {
                EnableComboBox(i, false);
            }

            Reach.BipedObject playerBiped = _saveManager.SaveData.Player.Biped;
            LoadWeapon(cbPrimaryWeapon, playerBiped.PrimaryWeapon);
            LoadWeapon(cbSecondaryWeapon, playerBiped.SecondaryWeapon);
            LoadWeapon(cbTertiaryWeapon, playerBiped.TertiaryWeapon);
            LoadWeapon(cbQuaternaryWeapon, playerBiped.QuaternaryWeapon);
            _loading = false;
        }
Example #4
0
        public void Load()
        {
            loading = true;
            Reach.CampaignSave saveData    = _saveManager.SaveData;
            Reach.BipedObject  playerBiped = saveData.Player.Biped;
            checkInvincible.IsChecked   = playerBiped.Health.IsInfinite;
            checkNoPhysics.IsEnabled    = (playerBiped.Vehicle == null);
            checkNoPhysics.IsChecked    = !playerBiped.PhysicsEnabled;
            checkNoFallDamage.IsChecked = playerBiped.NoFallDamage;

            txtPlayerXCord.Text = playerBiped.X.ToString();
            txtPlayerYCord.Text = playerBiped.Y.ToString();
            txtPlayerZCord.Text = playerBiped.Z.ToString();

            originalBipdItem         = -1;
            cBWeapTransfer.IsEnabled = false;
            cBBipeds.Items.Clear();
            HashSet <Reach.BipedObject> availableBipeds = Util.EditorSupport.FindSwappableBipeds(saveData);

            availableBipeds.Add(playerBiped);
            SortedDictionary <string, Reach.BipedObject> sortedBipeds = new SortedDictionary <string, Reach.BipedObject>();

            foreach (Reach.BipedObject obj in availableBipeds)
            {
                sortedBipeds[_taglistManager.Identify(obj)] = obj;
            }

            foreach (KeyValuePair <string, Reach.BipedObject> obj in sortedBipeds)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = obj.Key;
                item.Tag     = obj.Value;
                cBBipeds.Items.Add(item);

                if (obj.Value == playerBiped)
                {
                    originalBipdItem       = cBBipeds.Items.Count - 1;
                    cBBipeds.SelectedIndex = originalBipdItem;
                }
            }
            cBBipeds.IsEnabled = true;

            loading = false;
        }
Example #5
0
        public bool Save()
        {
            Reach.BipedObject playerBiped = _saveManager.SaveData.Player.Biped;
            bool weaponChanged            = false;

            // We have to do the save in two passes:
            // 1. Replace weapons and edit ammo
            // 2. Drop weapons in reverse order
            for (int i = 0; i < _weaponBoxes.Length; i++)
            {
                ComboBox box  = _weaponBoxes[i];
                Grid     grid = (Grid)box.Tag;

                // Replace the weapon if it does not match
                ComboBoxItem item = (ComboBoxItem)box.SelectedItem;
                if (item.Tag != null)
                {
                    WeaponItem weapon = (WeaponItem)item.Tag;
                    if (weapon.Object != playerBiped.GetWeapon(i))
                    {
                        weaponChanged = true;
                        playerBiped.ChangeWeapon(i, weapon.Object);
                        if (_tagList.Identify(playerBiped) == "Noble 6")
                        {
                            if (i == 0)
                            {
                                weapon.Object.ParentNode = NobleSixPrimaryWeaponNode;
                            }
                            else
                            {
                                weapon.Object.ParentNode = NobleSixSecondaryWeaponNode;
                            }

                            weapon.Object.X = 0;
                            weapon.Object.Y = 0;
                            weapon.Object.Z = 0;
                        }
                    }
                }

                if (grid.Children.Count > 0)
                {
                    // Save its ammo info
                    Util.IAmmoDisplay display = (Util.IAmmoDisplay)grid.Children[0];
                    display.Save();
                }
            }

            for (int i = _weaponBoxes.Length - 1; i >= 0; i--)
            {
                if (_weaponBoxes[i].SelectedIndex == 0)
                {
                    // (nothing) item is selected
                    playerBiped.DropWeapon(i);
                }
            }

            if (weaponChanged && playerBiped.Weapons.Count > 1)
            {
                _mainWindow.showMessage("Once your save loads, cycle through all of your weapons at least once. This will fix the carry data for your new weapons and ensure that they work properly.", "WEAPON REPLACEMENT");
            }

            return(true);
        }
Example #6
0
        private void BuildWeaponLists()
        {
            _freeWeapons.Clear();
            _weaponIndices.Clear();

            foreach (ComboBox box in _weaponBoxes)
            {
                box.Items.Clear();

                ComboBoxItem emptyItem = new ComboBoxItem();
                emptyItem.Content = "(nothing)";
                box.Items.Add(emptyItem);
            }

            // Sort the weapons by name into a set
            Reach.CampaignSave     saveData    = _saveManager.SaveData;
            Reach.BipedObject      playerBiped = saveData.Player.Biped;
            SortedSet <WeaponItem> weapons     = new SortedSet <WeaponItem>();

            foreach (Reach.GameObject obj in saveData.Objects)
            {
                // Only process non-null weapons that aren't deleted, aren't carried by a vehicle, or that are carried by the player
                if (obj != null && obj.TagGroup == Reach.TagGroup.Weap && !obj.Deleted && (obj.Carrier == null || obj.Carrier.TagGroup != Reach.TagGroup.Vehi || obj.Carrier == playerBiped))
                {
                    string name = _tagList.Identify(obj);
                    if (name.StartsWith("Spartan") || name == "Knife" || name == "Knife Sheath")
                    {
                        continue;
                    }

                    weapons.Add(new WeaponItem()
                    {
                        Name = name, Object = (Reach.WeaponObject)obj
                    });
                }
            }

            // Now add them to the combo boxes
            foreach (WeaponItem weapon in weapons)
            {
                // Grab the free indices set for the combo box
                SortedSet <int> freeIndices;
                if (!_freeWeapons.TryGetValue(weapon.Object.MapID, out freeIndices))
                {
                    freeIndices = new SortedSet <int>();
                    _freeWeapons[weapon.Object.MapID] = freeIndices;
                }

                // Mark the weapon as unused
                int index = _weaponBoxes[0].Items.Count;
                freeIndices.Add(index);
                weapon.Index = index;
                _weaponIndices[weapon.Object] = index;

                // Add it to each combo box
                foreach (ComboBox box in _weaponBoxes)
                {
                    ComboBoxItem item = new ComboBoxItem();
                    item.Content = weapon.Name;
                    item.Tag     = weapon;
                    if (freeIndices.Count > 1)
                    {
                        item.Visibility = Visibility.Collapsed;
                    }
                    box.Items.Add(item);
                }
            }
        }