Exemplo n.º 1
0
        public static String Name(FlagType flag)
        {
            switch (flag)
            {
            case FlagType._readonly:
                return("readonly");

            default:
                return(flag.ToString());
            }
        }
Exemplo n.º 2
0
        internal static void Wreck(IRocketPlayer caller, string filter, float radius, Vector3 position, WreckType type, FlagType flagtype, ulong steamID, ushort itemID)
        {
            bool pInfoLibLoaded = false;

            syncError = false;
            if (type == WreckType.Wreck)
            {
                if (DestructionProcessing.processing)
                {
                    UnturnedChat.Say(caller, WreckingBall.Instance.Translate("wreckingball_processing", originalCaller != null ? originalCaller.CharacterName : "???", (dIdxCount - dIdx), CalcProcessTime()));
                    return;
                }
                Abort(WreckType.Wreck);
            }
            else if (type == WreckType.Scan)
            {
                WreckingBall.ElementData.reportLists[BuildableType.Element].Clear();
                WreckingBall.ElementData.reportLists[BuildableType.VehicleElement].Clear();
                if (WreckingBall.Instance.Configuration.Instance.EnablePlayerInfo && WreckingBall.isPlayerInfoLibPresent && WreckingBall.isPlayerInfoLibLoaded)
                {
                    pInfoLibLoaded = true;
                }
            }
            UnturnedPlayer Player = null;

            if (!(caller is ConsolePlayer) && type != WreckType.Cleanup)
            {
                Player = (UnturnedPlayer)caller;
                if (Player.IsInVehicle)
                {
                    position = Player.CurrentVehicle.transform.position;
                }
                else
                {
                    position = Player.Position;
                }
            }

            List <char> Filter = new List <char>();

            Filter.AddRange(filter.ToCharArray());

            float           distance  = 0;
            float           vdistance = 0;
            StructureRegion structureRegion;
            BarricadeRegion barricadeRegion;

            for (int k = 0; k < StructureManager.regions.GetLength(0); k++)
            {
                for (int l = 0; l < StructureManager.regions.GetLength(1); l++)
                {
                    // check to see if the region is out of range, skip if it is.
                    if (!radius.IsNaN() && position.RegionOutOfRange(k, l, radius) && type != WreckType.Cleanup && type != WreckType.Counts)
                    {
                        continue;
                    }

                    structureRegion = StructureManager.regions[k, l];
                    ProcessElements(caller, itemID, radius, type, flagtype, Filter, pInfoLibLoaded, structureRegion, position, steamID, BuildableType.Element);
                }
            }

            for (int k = 0; k < BarricadeManager.BarricadeRegions.GetLength(0); k++)
            {
                for (int l = 0; l < BarricadeManager.BarricadeRegions.GetLength(1); l++)
                {
                    // check to see if the region is out of range, skip if it is.
                    if (!radius.IsNaN() && position.RegionOutOfRange(k, l, radius) && type != WreckType.Cleanup && type != WreckType.Counts)
                    {
                        continue;
                    }

                    barricadeRegion = BarricadeManager.BarricadeRegions[k, l];
                    ProcessElements(caller, itemID, radius, type, flagtype, Filter, pInfoLibLoaded, barricadeRegion, position, steamID, BuildableType.Element);
                }
            }


            foreach (InteractableVehicle vehicle in VehicleManager.vehicles)
            {
                bool validVehicleElements = BarricadeManager.tryGetPlant(vehicle.transform, out byte x, out byte y, out ushort plant, out barricadeRegion);
                // Process Vehicles.
                if ((Filter.Contains('V') || Filter.Contains('*')) && type != WreckType.Cleanup && type != WreckType.Counts && (flagtype == FlagType.Normal || (flagtype == FlagType.SteamID && vehicle.isLocked && vehicle.lockedOwner == (CSteamID)steamID)))
                {
                    vdistance = Vector3.Distance(vehicle.transform.position, position);
                    if ((!radius.IsNaN() && vdistance <= radius) || (radius.IsNaN() && (vehicle.transform.position.x.IsNaN() || vehicle.transform.position.y.IsNaN() || vehicle.transform.position.z.IsNaN())))
                    {
                        WreckProcess(caller, 999, vdistance, pInfoLibLoaded, BuildableType.Vehicle, type, vehicle, vehicle.transform, !validVehicleElements ? 0 : barricadeRegion.drops.Count, vehicle.isLocked ? (ulong)vehicle.lockedOwner : 0);
                    }
                    if (vehicle.asset.engine == EEngine.TRAIN && vehicle.trainCars != null && vehicle.trainCars.Length > 1)
                    {
                        for (int i = 1; i < vehicle.trainCars.Length; i++)
                        {
                            if (BarricadeManager.tryGetPlant(vehicle.trainCars[i].root, out x, out y, out plant, out BarricadeRegion barricadeRegion2))
                            {
                                float tcdistance = Vector3.Distance(vehicle.trainCars[i].root.position, position);
                                if (tcdistance <= radius)
                                {
                                    WreckProcess(caller, 999, tcdistance, pInfoLibLoaded, BuildableType.Vehicle, type, vehicle, vehicle.transform, barricadeRegion2 == null ? 0 : barricadeRegion2.drops.Count, 0, i);
                                }
                            }
                        }
                    }
                }

                if (type == WreckType.Cleanup && vehicle.asset.engine != EEngine.TRAIN && WreckingBall.Instance.Configuration.Instance.CleanupLockedCars && vehicle.isLocked && vehicle.lockedOwner == (CSteamID)steamID)
                {
                    cleanupList.Add(new Destructible(vehicle.transform, ElementType.Vehicle, vehicle.asset.id, vehicle));
                }
                // Add Locked vehicles to the top players count, if the cleanup locked vehicles feature is active.
                if (type == WreckType.Counts && vehicle.asset.engine != EEngine.TRAIN && WreckingBall.Instance.Configuration.Instance.CleanupLockedCars && vehicle.isLocked)
                {
                    ulong vOwner = (ulong)vehicle.lockedOwner;
                    if (pElementCounts.ContainsKey(vOwner))
                    {
                        pElementCounts[vOwner]++;
                    }
                    else
                    {
                        pElementCounts.Add(vOwner, 1);
                    }
                }
                // Process vehicles elements, remove distance limiting on vehicle placement for element scanning, to handle massively misplaced elements on vehicles.
                if (validVehicleElements)
                {
                    ProcessElements(caller, itemID, radius, type, flagtype, Filter, pInfoLibLoaded, barricadeRegion, position, steamID, BuildableType.VehicleElement);
                }

                if (vehicle.asset.engine == EEngine.TRAIN && vehicle.trainCars != null && vehicle.trainCars.Length > 1)
                {
                    for (int i = 1; i < vehicle.trainCars.Length; i++)
                    {
                        if (BarricadeManager.tryGetPlant(vehicle.trainCars[i].root, out x, out y, out plant, out BarricadeRegion barricadeRegion2))
                        {
                            ProcessElements(caller, itemID, radius, type, flagtype, Filter, pInfoLibLoaded, barricadeRegion2, position, steamID, BuildableType.VehicleElement);
                        }
                    }
                }
            }

            if (Filter.Contains('Z'))
            {
                for (int z = 0; z < ZombieManager.regions.Length; z++)
                {
                    foreach (Zombie zombie in ZombieManager.regions[z].zombies)
                    {
                        distance = Vector3.Distance(zombie.transform.position, position);
                        if (distance < radius)
                        {
                            WreckProcess(caller, 998, distance, pInfoLibLoaded, BuildableType.Element, type, zombie, zombie.transform);
                        }
                    }
                }
            }

            if (Filter.Contains('A'))
            {
                foreach (Animal animal in AnimalManager.animals)
                {
                    distance = Vector3.Distance(animal.transform.position, position);
                    if (distance <= radius)
                    {
                        WreckProcess(caller, 997, distance, pInfoLibLoaded, BuildableType.Element, type, animal, animal.transform);
                    }
                }
            }


            if (type == WreckType.Scan)
            {
                uint totalCount = 0;
                if (WreckingBall.ElementData.reportLists[BuildableType.Element].Count > 0 || WreckingBall.ElementData.reportLists[BuildableType.VehicleElement].Count > 0)
                {
                    foreach (KeyValuePair <BuildableType, Dictionary <char, uint> > reportDictionary in WreckingBall.ElementData.reportLists)
                    {
                        if (reportDictionary.Value.Count == 0)
                        {
                            continue;
                        }
                        foreach (KeyValuePair <char, uint> reportFilter in reportDictionary.Value)
                        {
                            totalCount += reportFilter.Value;
                        }
                    }
                }
                Logger.Log(string.Format("Player: {0}, ran scan at: {1}, with Radius: {7}, with Flag type: {2}, with Flags: {3}, with ItemID: {4}, with SteamID: {5}, number of elements scanned: {6}", caller is ConsolePlayer ? "Console" : Player.CharacterName + " [" + Player.SteamName + "] (" + Player.CSteamID.ToString() + ")", caller is ConsolePlayer ? "N/A" : Player.Position.ToString(), flagtype.ToString(), Filter.Count > 0 ? string.Join("", Filter.Select(i => i.ToString()).ToArray()) : "N/A", itemID, steamID, totalCount, radius.IsNaN() ? "NaN(NaN Check)" : radius.ToString()));
                return;
            }
            if (destroyList.Count >= 1 && type == WreckType.Wreck)
            {
                Logger.Log(string.Format("Player {0}, queued wreck at: {1}, with Radius: {7}, with Flag type: {2}, with Flags: {3}, with itemID: {4}, with StermID: {5}, number of elements queued: {6}", caller is ConsolePlayer ? "Console" : Player.CharacterName + " [" + Player.SteamName + "] (" + Player.CSteamID.ToString() + ")", caller is ConsolePlayer ? "N/A" : Player.Position.ToString(), flagtype.ToString(), Filter.Count > 0 ? string.Join("", Filter.Select(i => i.ToString()).ToArray()) : "N/A", itemID, steamID, destroyList.Count, radius.IsNaN() ? "NaN(NaN Check)" : radius.ToString()));
                dIdxCount = destroyList.Count;
                WreckingBall.Instance.Instruct(caller);
            }
            else if (type == WreckType.Cleanup)
            {
                cdIdxCount = cleanupList.Count;
            }
            else if (type != WreckType.Counts)
            {
                UnturnedChat.Say(caller, WreckingBall.Instance.Translate("wreckingball_not_found", radius));
            }
        }
Exemplo n.º 3
0
 public AncientFlag(FlagType flagType, Vector2 tile) : base(1900, tile)
 {
     flagTexture = ModResources.ancientFlagsTexture;
     base.defaultSourceRect.Value = new Rectangle(32 * (int)flagType % flagTexture.Width, 32 * (int)flagType / flagTexture.Width * 32, 32, 32);
     base.modData.Add(ModEntry.ANCIENT_FLAG_KEY, flagType.ToString());
 }
Exemplo n.º 4
0
 internal static void SetHoistedFlag(FlagType flagType)
 {
     Game1.player.modData[HOISTED_FLAG_KEY] = flagType.ToString();
 }