Пример #1
0
        private void OnTransformBarricadeRequested(CSteamID instigator, byte x, byte y, ushort plant, uint instanceID,
                                                   ref Vector3 point, ref byte angle_x, ref byte angle_y, ref byte angle_z, ref bool shouldAllow)
        {
            BarricadeRegion region = BarricadeManager.regions[x, y];
            int             index  = region.barricades.FindIndex(k => k.instanceID == instanceID);

            BarricadeData data = region.barricades[index];
            BarricadeDrop drop = region.drops[index];

            Player nativePlayer = Provider.clients.FirstOrDefault(x => x?.playerID.steamID == instigator)?.player;

            UnturnedPlayer player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer);

            UnturnedBarricadeTransformingEvent @event = new UnturnedBarricadeTransformingEvent(
                new UnturnedBarricadeBuildable(data, drop), player, instigator, point,
                Quaternion.Euler(angle_x * 2, angle_y * 2, angle_z * 2));

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            Vector3 eulerAngles = @event.Rotation.eulerAngles;

            angle_x = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angle_y = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angle_z = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
        }
Пример #2
0
        public void Execute(ICommandContext context)
        {
            UnturnedPlayer player = ((UnturnedUser)context.User).Player;

            Random random = new Random(DateTime.Now.Millisecond);

            switch (context.Parameters.Get <string> (0).ToLower())
            {
            case "b":
            case "barricade":
                BarricadeRegion randomBRegion = BarricadeManager.regions [random.Next(0, BarricadeManager.BARRICADE_REGIONS), random.Next(0, BarricadeManager.BARRICADE_REGIONS)];
                Vector3         randomPoint   = randomBRegion.barricades [random.Next(0, randomBRegion.barricades.Count)].point.ToSystemVector();
                randomPoint.Y += 10;
                player.Entity.Teleport(randomPoint);
                break;

            case "s":
            case "structure":
                StructureRegion randomSRegion = StructureManager.regions [random.Next(0, StructureManager.STRUCTURE_REGIONS), random.Next(0, StructureManager.STRUCTURE_REGIONS)];
                randomPoint    = randomSRegion.structures [random.Next(0, randomSRegion.structures.Count)].point.ToSystemVector();
                randomPoint.Y += 10;
                player.Entity.Teleport(randomPoint);
                break;

            case "v":
            case "vehicle":
                randomPoint    = VehicleManager.vehicles [random.Next(0, VehicleManager.vehicles.Count)].transform.position.ToSystemVector();
                randomPoint.Y += 10;
                player.Entity.Teleport(randomPoint);
                break;
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            for (byte i = 0; i < Regions.WORLD_SIZE; i += 1)
            {
                for (byte j = 0; j < Regions.WORLD_SIZE; j += 1)
                {
                    BarricadeRegion br = BarricadeManager.regions[i, j];
                    for (int index = 0; index < br.barricades.Count; index++)
                    {
                        BarricadeData b = br.barricades[index];
                        if (Assets.find(EAssetType.ITEM, b.barricade.id) is ItemBarricadeAsset asset && asset.build != EBuild.FARM)
                        {
                            b.barricade.health = asset.health;
                            //BarricadeManager.instance.channel.send("tellBarricadeHealth", ESteamCall.ALL,
                            //    ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { i, j, ushort.MaxValue, index, b.asset.quality });
                        }
                    }

                    StructureRegion sr = StructureManager.regions[i, j];
                    for (int index = 0; index < sr.structures.Count; index++)
                    {
                        StructureData s = sr.structures[index];
                        if (Assets.find(EAssetType.ITEM, s.structure.id) is ItemStructureAsset asset)
                        {
                            s.structure.health = asset.health;
                            //BarricadeManager.instance.channel.send("tellStructureHealth", ESteamCall.ALL,
                            //    ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { i, j, ushort.MaxValue, index, s.asset.quality });
                        }
                    }
                }
            }
            UnturnedChat.Say(caller, "repaired all buildings");
        }
        private void BarricadeSpawned(BarricadeRegion region, BarricadeDrop drop)
        {
            var data  = region.barricades.Find(k => k.instanceID == drop.instanceID);
            var build = new BarricadeBuildable(data, drop);

            m_BarricadeBuildables.Add(build.InstanceId, build);
            m_DeferredAdd.Enqueue(build);
        }
Пример #5
0
        public void OnBarricadeSpawned(BarricadeRegion region, BarricadeDrop drop)
        {
            if (drop.asset.id != 1050)
            {
                return;
            }

            ActiveHealthStations.Add(SpawnHealthStationBarricade(region, drop, 20000));
        }
Пример #6
0
        public void OnBarricadeSpawned(BarricadeRegion region, BarricadeDrop drop)
        {
            if (drop.asset.id != 1241)
            {
                return;
            }

            ActiveC4.Add(SpawnC4Barricade(region, drop, 30000));
        }
Пример #7
0
            private static void DestroyBarricade(BarricadeRegion region, ushort index)
            {
                ThreadUtil.assertIsGameThread();

                var data = region.barricades[index];
                var drop = region.drops[index];

                OnBarricadeDestroyed?.Invoke(data, drop);
            }
Пример #8
0
        internal bool Sell(decimal curBallance, UnturnedPlayer player, RaycastInfo raycastInfo, out decimal totalCost, out short actualCount)
        {
            bool sufficientAmount = false;

            totalCost   = 0;
            actualCount = 0;
            InteractableVehicle vehicle = null;

            if (RestrictBuySell == RestrictBuySell.BuyOnly)
            {
                actualCount = -1;
                return(false);
            }
            VehicleInfo vInfo = DShop.Instance.Database.GetVehicleInfo((ulong)player.CSteamID, ItemID);

            if (vInfo == null)
            {
                // The car the player's looking at hasn't been bought before from them, from the shop.
                actualCount = -2;
                return(false);
            }
            else
            {
                vehicle          = raycastInfo.vehicle;
                sufficientAmount = true;
                actualCount      = 1;
                if (DShop.Instance.Configuration.Instance.VehicleSellDropElements)
                {
                    BarricadeRegion vregion = null;
                    byte            x;
                    byte            y;
                    ushort          plant;
                    if (BarricadeManager.tryGetPlant(vehicle.transform, out x, out y, out plant, out vregion))
                    {
                        for (int j = 0; j < vregion.drops.Count; j++)
                        {
                            if (j < vregion.drops.Count && vregion.barricades[j].barricade.id > 0)
                            {
                                Item item = new Item(vregion.barricades[j].barricade.id, true);
                                ItemManager.dropItem(item, vregion.drops[j].model.position, false, true, true);
                            }
                        }
                    }
                }
                DShop.Instance.Database.DeleteVehicleInfo(vInfo);
                vehicle.askDamage(ushort.MaxValue, false);
                totalCost = decimal.Multiply(BuyCost, SellMultiplier);
                DShop.Instance._OnShopSell(decimal.Add(curBallance, totalCost), player, 1, this, ItemType.Vehicle, BuyCost, totalCost, actualCount, 0);
            }
            return(sufficientAmount);
        }
Пример #9
0
            private static void DropBarricade(BarricadeRegion region, Barricade barricade, Vector3 point,
                                              Quaternion rotation, ulong owner, ulong group, BarricadeData data, ref Transform result,
                                              ref uint instanceID)
            {
                if (result != null)
                {
                    BarricadeDrop drop = region.drops.LastOrDefault();

                    if (drop?.instanceID == instanceID)
                    {
                        OnBarricadeDeployed?.Invoke(data, drop);
                    }
                }
            }
Пример #10
0
            private static void DropBarricade(BarricadeRegion region, BarricadeData data, ref Transform result, ref uint instanceID)
            {
                if (result == null)
                {
                    return;
                }

                var drop = region.drops.LastOrDefault();

                if (drop?.instanceID == instanceID)
                {
                    OnBarricadeDeployed?.Invoke(data, drop);
                }
            }
Пример #11
0
 public C4(BarricadeRegion region, BarricadeDrop drop, int time)
 {
     Id           = 1;
     Name         = "item_barricade_c4";
     DisplayName  = "C4";
     ItemType     = ItemType.BARRICADE;
     UnturnedItem = new SDG.Unturned.Item(1241, true);
     Asset        = (ItemAsset)Assets.find(EAssetType.ITEM, 1241);
     Region       = region;
     Drop         = drop;
     Defused      = false;
     Length       = time;
     TimeLeft     = time;
     AsyncHelper.Schedule("C4Tick", C4Tick, 500);
 }
Пример #12
0
 public HealthStation(BarricadeRegion region, BarricadeDrop drop, int time)
 {
     Id           = 2;
     Name         = "item_barricade_healthstation";
     DisplayName  = "HealthStation";
     ItemType     = ItemType.BARRICADE;
     UnturnedItem = new SDG.Unturned.Item(1050, true);
     Asset        = (ItemAsset)Assets.find(EAssetType.ITEM, 1050);
     Region       = region;
     Drop         = drop;
     Expired      = false;
     TimeLeft     = time;
     AsyncHelper.Schedule("HealthStationTick", HealthStationTick, 500);
     InterfaceManager.SendEffectLocationUnsafe(2000, drop.model.position);
 }
 public RaycastResult(RaycastHit Info, bool hit)
 {
     RaycastHit = hit;
     if (hit)
     {
         Raycast = Info;
         Vehicle = TryGetEntity <InteractableVehicle>();
         Transform target = Raycast.collider?.transform;
         if (target != null)
         {
             if (target.CompareTag("Barricade"))
             {
                 target = DamageTool.getBarricadeRootTransform(target);
                 BarricadeRootTransform = target;
                 if (BarricadeManager.tryGetInfo(target, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion Region, out BarricadeDrop Drop))
                 {
                     BarricadeRegion = Region;
                     BarricadeX      = x;
                     BarricadeY      = y;
                     BarricadePlant  = plant;
                     BarricadeIndex  = index;
                     BarricadeData B = Region.barricades.FirstOrDefault(D => D.instanceID == Drop.instanceID);
                     if (B != null)
                     {
                         Barricade = B;
                     }
                 }
             }
             else if (target.CompareTag("Structure"))
             {
                 target = DamageTool.getStructureRootTransform(target);
                 StructureRootTransform = target;
                 if (StructureManager.tryGetInfo(target, out byte x, out byte y, out ushort index, out StructureRegion Region))
                 {
                     StructureX      = x;
                     StructureY      = y;
                     StructureIndex  = index;
                     StructureRegion = Region;
                     StructureData B = Region.structures[index];
                     if (B != null)
                     {
                         Structure = B;
                     }
                 }
             }
         }
     }
 }
Пример #14
0
 public static BarricadeTag For(int instanceID)
 {
     for (byte x = 0; x < Regions.WORLD_SIZE; x++)
     {
         for (byte y = 0; y < Regions.WORLD_SIZE; y++)
         {
             BarricadeRegion region = BarricadeManager.regions[x, y];
             for (int i = 0; i < region.barricades.Count; i++)
             {
                 if (instanceID == region.drops[i].model.gameObject.GetInstanceID())
                 {
                     return(new BarricadeTag(region.drops[i].model, region.barricades[i]));
                 }
             }
         }
     }
     return(null);
 }
Пример #15
0
 public BarricadeTag(Barricade barricade)
 {
     for (byte x = 0; x < Regions.WORLD_SIZE; x++)
     {
         for (byte y = 0; y < Regions.WORLD_SIZE; y++)
         {
             BarricadeRegion region = BarricadeManager.regions[x, y];
             for (int i = 0; i < region.barricades.Count; i++)
             {
                 if (barricade == region.barricades[i].barricade)
                 {
                     Internal     = region.drops[i].model;
                     InternalData = region.barricades[i];
                     return;
                 }
             }
         }
     }
 }
        private static bool CheckResponse(UnturnedPlayer player, string[] commands, out InteractableVehicle vehicle, out BarricadeRegion vehicleRegion)
        {
            GarageUtil.SuperGarageAddChecks(player, commands, out vehicle, out vehicleRegion, out var responseType);
            switch (responseType)
            {
            case EResponseType.GARAGE_NOT_FOUND:
                UnturnedChat.Say(player, Plugin.Inst.Translate("rfgarage_command_garage_not_found"), Plugin.MsgColor);
                return(false);

            case EResponseType.INVALID_STEAM_ID:
                UnturnedChat.Say(player, Plugin.Inst.Translate("rfgarage_command_invalid_id"), Plugin.MsgColor);
                return(false);

            case EResponseType.SAME_NAME_AS_GARAGE:
                UnturnedChat.Say(player, Plugin.Inst.Translate("rfgarage_command_vehicle_name_same_as_garage"), Plugin.MsgColor);
                return(false);

            case EResponseType.SUCCESS:
                return(true);

            case EResponseType.VEHICLE_NOT_FOUND:
                UnturnedChat.Say(player, Plugin.Inst.Translate("rfgarage_command_vehicle_not_found"), Plugin.MsgColor);
                return(false);

            default:
                UnturnedChat.Say(player, responseType.ToString(), Plugin.MsgColor);
                return(false);
            }
        }
Пример #17
0
 static public C4 SpawnC4Barricade(BarricadeRegion region, BarricadeDrop drop, int time) => new C4(region, drop, time);
Пример #18
0
 public static void SuperGarageAddChecks(UnturnedPlayer player, string[] commands, out InteractableVehicle vehicle, out BarricadeRegion vehicleRegion, out EResponseType responseType)
 {
     responseType  = EResponseType.SUCCESS;
     vehicle       = null;
     vehicleRegion = null;
     if (!ulong.TryParse(commands[0], out var steamID))
     {
         responseType = EResponseType.INVALID_STEAM_ID;
         return;
     }
     if (Plugin.Conf.VirtualGarages.Any(g =>
                                        string.Equals(g.Name, commands[2], StringComparison.CurrentCultureIgnoreCase)))
     {
         responseType = EResponseType.SAME_NAME_AS_GARAGE;
         return;
     }
     if (!VehicleCheck(player, out vehicle, out vehicleRegion))
     {
         responseType = EResponseType.VEHICLE_NOT_FOUND;
         return;
     }
     if (!GarageCheck(player, GarageModel.Parse(commands[1]), out responseType, isSuper: true))
     {
     }
 }
Пример #19
0
        private static void ProcessElements(IRocketPlayer caller, ushort itemID, float radius, WreckType type, FlagType flagtype, List <char> Filter, bool pInfoLibLoaded, object region, Vector3 position, ulong steamID, BuildableType buildType)
        {
            StructureRegion sRegion   = null;
            BarricadeRegion bRegion   = null;
            BarricadeData   bData     = null;
            StructureData   sData     = null;
            bool            isSRegion = region is StructureRegion;
            int             DataCount;
            int             transformCount;

            if (isSRegion)
            {
                sRegion        = region as StructureRegion;
                transformCount = sRegion.drops.Count;
                DataCount      = sRegion.structures.Count;
            }
            else
            {
                bRegion        = region as BarricadeRegion;
                transformCount = bRegion.drops.Count;
                DataCount      = bRegion.barricades.Count;
            }

            for (int i = 0; i < transformCount; i++)
            {
                Transform transform = isSRegion ? sRegion.drops[i].model : bRegion.drops[i].model;
                ulong     owner;
                if (i < DataCount)
                {
                    if (isSRegion)
                    {
                        sData = sRegion.structures[i];
                        owner = sData.owner;
                    }
                    else
                    {
                        bData = bRegion.barricades[i];
                        owner = bData.owner;
                    }
                }
                else
                {
                    Logger.LogWarning(WreckingBall.Instance.Translate(isSRegion ? "wreckingball_structure_array_sync_error" : "wreckingball_barricade_array_sync_error"));
                    syncError = true;
                    break;
                }
                float distance = Vector3.Distance(transform.position, position);
                if (((!radius.IsNaN() && distance <= radius) || (radius.IsNaN() && (transform.position.x.IsNaN() || transform.position.y.IsNaN() || transform.position.z.IsNaN()))) && type != WreckType.Cleanup && type != WreckType.Counts)
                {
                    ushort item = isSRegion ? sData.structure.id : bData.barricade.id;
                    if (WreckingBall.ElementData.FilterItem(item, Filter) || Filter.Contains('*') || flagtype == FlagType.ItemID)
                    {
                        if (flagtype == FlagType.Normal)
                        {
                            WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform);
                        }
                        else if (flagtype == FlagType.SteamID && owner == steamID)
                        {
                            WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform);
                        }
                        else if (flagtype == FlagType.ItemID && itemID == item)
                        {
                            WreckProcess(caller, item, distance, pInfoLibLoaded, buildType, type, isSRegion ? (object)sData : bData, transform);
                        }
                    }
                }
                else if (type == WreckType.Cleanup && owner == steamID)
                {
                    cleanupList.Add(new Destructible(transform, isSRegion ? ElementType.Structure : ElementType.Barricade, isSRegion ? sData.structure.id : bData.barricade.id));
                }
                else if (type == WreckType.Counts)
                {
                    if (pElementCounts.ContainsKey(owner))
                    {
                        pElementCounts[owner]++;
                    }
                    else
                    {
                        pElementCounts.Add(owner, 1);
                    }
                }
            }
        }
Пример #20
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;
            byte            x;
            byte            y;
            ushort          plant;
            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 x, out y, out 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++)
                        {
                            BarricadeRegion barricadeRegion2 = null;
                            if (BarricadeManager.tryGetPlant(vehicle.trainCars[i].root, out x, out y, out plant, out 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++)
                    {
                        BarricadeRegion barricadeRegion2 = null;
                        if (BarricadeManager.tryGetPlant(vehicle.trainCars[i].root, out x, out y, out plant, out 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));
            }
        }
Пример #21
0
 internal static void DestroyBarricade(BarricadeRegion region, ushort index)
 {
     ThreadUtil.assertIsGameThread();
     OnBuildableDestroyed?.Invoke(region.drops[index].instanceID, false);
 }
        public List <BarricadeDataInternal> GetBarricadeTransforms(UnturnedPlayer player, int radius, ulong SpecificSteamid64, bool GroupOnly, bool Rectangle)
        {
            var             position     = player.Position;
            var             error        = 0;
            var             Barricades   = new List <BarricadeDataInternal>();
            var             transforms   = 0;
            var             regionsfound = 0;
            var             regionsused  = 0;
            bool            Plant;
            Vector3         pointVector3;
            BarricadeData   barricade;
            BarricadeRegion barricadeRegion = null;
            Transform       transform       = null;

            for (var x = 0; x < BarricadeManager.regions.GetLength(0); x++)
            {
                for (var y = 0; y < BarricadeManager.regions.GetLength(1); y++)
                {
                    regionsfound++;
                    Regions.tryGetPoint((byte)x, (byte)y, out pointVector3);

                    if (Vector3.Distance(pointVector3 += new Vector3(64, 0, 64), new Vector3(position.x, 0f, position.z)) > radius)
                    {
                        continue;
                    }
                    regionsused++;
                    barricadeRegion = BarricadeManager.regions[x, y];
                    transforms      = barricadeRegion.drops.Count;
                    for (var i = 0; i < transforms; i++)
                    {
                        transform = barricadeRegion.drops[i].model;
                        Plant     = transform.parent != null && transform.parent.CompareTag("Vehicle");
                        if (barricadeRegion.barricades[i] == null)
                        {
                            error++;
                            continue;
                        }

                        barricade = barricadeRegion.barricades[i];
                        if (GroupOnly)
                        {
                            if (barricade.group != player.SteamGroupID.m_SteamID)
                            {
                                continue;
                            }
                        }
                        if (SpecificSteamid64 != 0)
                        {
                            if (barricade.owner != SpecificSteamid64)
                            {
                                continue;
                            }
                        }

                        if (Vector3.Distance(position, transform.position) < radius - 92 && !Plant)
                        {
                            Barricades.Add(new BarricadeDataInternal(barricadeRegion.barricades[i], transform.parent != null && transform.parent.CompareTag("Vehicle") ? true : false, transform != null ? transform : null));
                        }
                    }
                }
            }

            //Logger.Log($"We have found {regionsfound} regions and used {regionsused} of them.");
            if (error != 0)
            {
                SendMessageAndLog(player, "It seems your barricade regions are a bit of sync, if you have issues, gotta restart server. This issue may be caused by one of your plugins.", $"Error on executing SaveSchematic command for {player.CharacterName},it seems barricade regions are out of sync, gotta restart if this causes issues. Sorry! This could be caused by a server plugin, or just getting unlucky.");
            }
            return(Barricades);
        }
Пример #23
0
 private static bool VehicleCheck(UnturnedPlayer player, out InteractableVehicle vehicle, out BarricadeRegion vehicleRegion)
 {
     vehicle       = null;
     vehicleRegion = null;
     if (!VehicleUtil.GetVehicleByLook(player, 2048f, out vehicle, out vehicleRegion))
     {
         VehicleUtil.GetVehicleBySeat(player, out vehicle, out vehicleRegion);
     }
     return(vehicle != null);
 }
Пример #24
0
 public static void SaveVgVehicleToSql(ulong steamID, string garageName, string vehicleName, InteractableVehicle vehicle, BarricadeRegion vehicleRegion)
 {
     try
     {
         var info = SerializableVehicle.Create(vehicle).ToInfo();
         VehicleUtil.ForceExitPassenger(vehicle);
         VehicleUtil.ClearItems(vehicle);
         Plugin.DbManager.InsertVgVehicle(steamID.ToString(), garageName, vehicleName, info);
         VehicleManager.askVehicleDestroy(vehicle);
     }
     catch (Exception e)
     {
         Logger.LogError("[RFGarage] SaveError: " + e);
     }
 }
Пример #25
0
 public static void ServerSetBedOwnerInternal(InteractableBed bed, byte x, byte y, ushort plant, ushort index, BarricadeRegion region, CSteamID steamID)
 {
     m_Method.Invoke(null, new object[] { bed, x, y, plant, index, region, steamID });
 }
Пример #26
0
        public static void GarageAddChecks(UnturnedPlayer player, string[] commands, out InteractableVehicle vehicle, out BarricadeRegion vehicleRegion, out EResponseType responseType, out ushort blacklistedID)
        {
            responseType  = EResponseType.SUCCESS;
            blacklistedID = 0;
            vehicle       = null;
            vehicleRegion = null;
            var oneArg = commands.Length == 1;

            switch (oneArg)
            {
            case true:
                if (!SelectedGarageCheck(player))
                {
                    responseType = EResponseType.GARAGE_NOT_SELECTED;
                    return;
                }
                if (Plugin.Conf.VirtualGarages.Any(g =>
                                                   string.Equals(g.Name, commands[0], StringComparison.CurrentCultureIgnoreCase)))
                {
                    responseType = EResponseType.SAME_NAME_AS_GARAGE;
                    return;
                }
                if (!VehicleCheck(player, out vehicle, out vehicleRegion))
                {
                    responseType = EResponseType.VEHICLE_NOT_FOUND;
                    return;
                }
                if (!OwnerCheck(player, vehicle))
                {
                    responseType = EResponseType.VEHICLE_NOT_OWNER;
                    return;
                }
                if (!GarageCheck(player, Plugin.SelectedGarageDict[player.CSteamID], out responseType))
                {
                    return;
                }
                BlacklistCheck(player, vehicle, out responseType, out blacklistedID);
                break;

            case false:
                if (Plugin.Conf.VirtualGarages.Any(g =>
                                                   string.Equals(g.Name, commands[1], StringComparison.CurrentCultureIgnoreCase)))
                {
                    responseType = EResponseType.SAME_NAME_AS_GARAGE;
                    return;
                }
                if (!VehicleCheck(player, out vehicle, out vehicleRegion))
                {
                    responseType = EResponseType.VEHICLE_NOT_FOUND;
                    return;
                }
                if (!OwnerCheck(player, vehicle))
                {
                    responseType = EResponseType.VEHICLE_NOT_OWNER;
                    return;
                }
                if (!GarageCheck(player, GarageModel.Parse(commands[0]), out responseType))
                {
                    return;
                }
                BlacklistCheck(player, vehicle, out responseType, out blacklistedID);
                break;
            }
        }
Пример #27
0
 static public HealthStation SpawnHealthStationBarricade(BarricadeRegion region, BarricadeDrop drop, int time) => new HealthStation(region, drop, time);
 public static void SendOpenDoor(ushort plant, byte x, byte y, ushort index, InteractableDoor interactableDoor, BarricadeRegion barricadeRegion)
 {
     BarricadeManager.ServerSetDoorOpen(interactableDoor, !interactableDoor.isOpen);
 }
Пример #29
0
        private void Events_OnBarricadeDeployed(BarricadeRegion region, BarricadeDrop drop)
        {
            var @event = new UnturnedBarricadeDeployedEvent(new UnturnedBarricadeBuildable(drop));

            Emit(@event);
        }
Пример #30
0
        public static bool GetVehicleBySeat(UnturnedPlayer player, out InteractableVehicle currentVehicle, out BarricadeRegion vehicleBarricadeRegion)
        {
            currentVehicle         = player.CurrentVehicle;
            vehicleBarricadeRegion = null;
            if (currentVehicle == null)
            {
                return(false);
            }

            vehicleBarricadeRegion = BarricadeManager.getRegionFromVehicle(currentVehicle);
            return(true);
        }