コード例 #1
0
        public override void Load()
        {
            IsInitializing = true;
            base.Load();

            m_suppressWritingSelectedWeapon = true;
            Weapon = (Weapon?)TheEditor.GetGlobal(GlobalVariable.PlayerWeapon);
            m_suppressWritingSelectedWeapon = false;

            Scripts.GlobalVariables.CollectionChanged += GlobalVariables_CollectionChanged;

            ReadSlot(0);
            ReadSlot(1);
            ReadSlot(2);
            ReadSlot(3);
            ReadSlot(4);
            ReadSlot(5);
            ReadSlot(6);
            ReadSlot(7);
            ReadSlot(8);
            ReadSlot(9);
            UpdateInventory();
            UpdateOutfit();
            UpdateSpawnPointMarker();
            UpdateSpawnPointInterior();

            OnPropertyChanged(nameof(Armor));
            OnPropertyChanged(nameof(Money));
            OnPropertyChanged(nameof(Weapon));
            OnPropertyChanged(nameof(SpawnPoint));
            OnPropertyChanged(nameof(SpawnHeading));
        }
コード例 #2
0
        public void UpdateSpawnPointInterior()
        {
            m_isUpdatingSpawnInterior = true;

            SafeHouse sf          = (SafeHouse)TheEditor.GetGlobal(GlobalVariable.CurrentInterior);
            float     indDistance = Vector3D.Distance(SpawnPoint, PortlandSpawnPoint);
            float     comDistance = Vector3D.Distance(SpawnPoint, StauntonSpawnPoint);
            float     subDistance = Vector3D.Distance(SpawnPoint, ShoresideSpawnPoint);

            if (sf == SafeHouse.Portland && indDistance < SpawnPointTolerance)
            {
                SpawnInterior = SafeHouse.Portland;
            }
            else if (sf == SafeHouse.Staunton && comDistance < SpawnPointTolerance)
            {
                SpawnInterior = SafeHouse.Staunton;
            }
            else if (sf == SafeHouse.Shoreside && subDistance < SpawnPointTolerance)
            {
                SpawnInterior = SafeHouse.Shoreside;
            }
            else
            {
                SpawnInterior = null;
            }

            m_isUpdatingSpawnInterior = false;
        }
コード例 #3
0
        private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            GlobalVariableInfo item = (ShowSavedOnly)
                        ? Globals.Where(x => x.Index == e.NewStartingIndex).FirstOrDefault()
                        : Globals[e.NewStartingIndex];

            item.IntValue   = TheEditor.GetGlobal(item.Index);
            item.FloatValue = TheEditor.GetGlobalAsFloat(item.Index);
        }
コード例 #4
0
 public void UpdateIntValue()
 {
     if (SelectedItem != null)
     {
         int oldVal = TheEditor.GetGlobal(SelectedItem.Index);
         int newVal = SelectedItem.IntValue;
         if (oldVal != newVal)
         {
             TheEditor.SetGlobal(SelectedItem.Index, newVal);
         }
     }
 }
コード例 #5
0
        public int GetNumStuntJumpsFound()
        {
            int stuntJumpsFound = 0;

            for (int i = 0; i < Collectibles.NumStuntJumps; i++)
            {
                if (TheEditor.GetGlobal(GlobalVariable.Package1Collected + i) != 0)
                {
                    stuntJumpsFound++;
                }
            }

            return(stuntJumpsFound);
        }
コード例 #6
0
        public int GetNumPackagesFound()
        {
            int packagesFound = 0;

            for (int i = 0; i < Collectibles.NumPackages; i++)
            {
                if (TheEditor.GetGlobal(GlobalVariable.Package1Collected + i) != 0)
                {
                    packagesFound++;
                }
            }

            return(packagesFound);
        }
コード例 #7
0
        private void PopulateAllVariables()
        {
            for (int i = 0, enumIndex = 0; i < TheEditor.GetNumGlobals(); i++, enumIndex++)
            {
                while (TheEditor.GetIndexOfGlobal((GlobalVariable)enumIndex) < i)
                {
                    enumIndex++;
                }

                string name = Enum.GetName(typeof(GlobalVariable), enumIndex);
                Globals.Add(new GlobalVariableInfo()
                {
                    Index      = i,
                    IntValue   = TheEditor.GetGlobal(i),
                    FloatValue = TheEditor.GetGlobalAsFloat(i),
                    Name       = name
                });
            }
        }
コード例 #8
0
        private void PopulateSavedVariables()
        {
            foreach (GlobalVariable var in Enum.GetValues(typeof(GlobalVariable)))
            {
                int index = TheEditor.GetIndexOfGlobal(var);
                if (index == -1)
                {
                    continue;
                }

                Globals.Add(new GlobalVariableInfo()
                {
                    Index      = index,
                    IntValue   = TheEditor.GetGlobal(var),
                    FloatValue = TheEditor.GetGlobalAsFloat(var),
                    Name       = var.ToString()
                });
            }
        }
コード例 #9
0
        public void PlotAll(BlipType type)
        {
            int stateArrayBase = -1;

            switch (type)
            {
            case BlipType.Package: stateArrayBase = (int)GlobalVariable.Package1Collected; break;

            case BlipType.Rampage: stateArrayBase = (int)GlobalVariable.Rampage1Passed; break;

            case BlipType.StuntJump: stateArrayBase = (int)GlobalVariable.StuntJump1Completed; break;
            }

            var b = Blips.Where(x => x.Type == type).ToArray();

            for (int i = 0; i < b.Length; i++)
            {
                int state = TheEditor.GetGlobal(stateArrayBase + i);
                b[i].IsCollected = (state != 0);
                b[i].IsEnabled   = true;
            }
        }
コード例 #10
0
        public void ReadSlot(int index)
        {
            m_isReadingWeaponSlot = true;

            if (index == 0)
            {
                bool hasBrassKnuckles = TheEditor.GetGlobal(WeaponVars[Types.Weapon.BrassKnuckles]) != 0;
                Slot0Weapon = (hasBrassKnuckles) ? Types.Weapon.BrassKnuckles : Types.Weapon.Fists;
                goto Cleanup;
            }

            IReadOnlyList <Weapon> slotWeapons = index switch
            {
                1 => Slot1Weapons,
                2 => Slot2Weapons,
                3 => Slot3Weapons,
                4 => Slot4Weapons,
                5 => Slot5Weapons,
                6 => Slot6Weapons,
                7 => Slot7Weapons,
                8 => Slot8Weapons,
                9 => Slot9Weapons,
                _ => throw new InvalidOperationException($"Bad weapon slot number: {index}"),
            };

            Weapon?weapon = null;
            int    ammo   = 0;

            foreach (Weapon w in slotWeapons)
            {
                int a = TheEditor.GetGlobal(WeaponVars[w]);
                if (a != 0)
                {
                    ammo   = a;
                    weapon = w;
                    break;
                }
            }

            switch (index)
            {
            case 1: Slot1Weapon = weapon; Slot1Ammo = ammo; break;

            case 2: Slot2Weapon = weapon; Slot2Ammo = ammo; break;

            case 3: Slot3Weapon = weapon; Slot3Ammo = ammo; break;

            case 4: Slot4Weapon = weapon; Slot4Ammo = ammo; break;

            case 5: Slot5Weapon = weapon; Slot5Ammo = ammo; break;

            case 6: Slot6Weapon = weapon; Slot6Ammo = ammo; break;

            case 7: Slot7Weapon = weapon; Slot7Ammo = ammo; break;

            case 8: Slot8Weapon = weapon; Slot8Ammo = ammo; break;

            case 9: Slot9Weapon = weapon; Slot9Ammo = ammo; break;
            }

Cleanup:
            m_isReadingWeaponSlot = false;
        }