private void OnDamageBarricadeRequested(CSteamID instigatorSteamID, Transform barricadeTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin) { if (BarricadeManager.tryGetInfo(barricadeTransform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region, out BarricadeDrop drop)) { BarricadeData data = region.barricades[index]; UnturnedBarricadeBuildable buildable = new UnturnedBarricadeBuildable(data, drop); Player nativePlayer = Provider.clients.FirstOrDefault(x => x?.playerID.steamID == instigatorSteamID)?.player; UnturnedPlayer player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer); UnturnedBuildableDamagingEvent @event; if (pendingTotalDamage >= buildable.State.Health) { @event = new UnturnedBarricadeDestroyingEvent(buildable, pendingTotalDamage, damageOrigin, player, instigatorSteamID); } else { @event = new UnturnedBarricadeDamagingEvent(buildable, pendingTotalDamage, damageOrigin, player, instigatorSteamID); } Emit(@event); pendingTotalDamage = @event.DamageAmount; shouldAllow = [email protected]; } }
public UnturnedBarricadeBuildable(BarricadeData data, BarricadeDrop drop) : this(drop) { if (drop.GetServersideData() != data) { throw new Exception($"{nameof(data)} is incorrect barricade data for {nameof(drop)}"); } }
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); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length > 1) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter")); throw new WrongUsageOfCommandException(caller, this); } UnturnedPlayer player = (UnturnedPlayer)caller; if (Physics.Raycast(player.Player.look.aim.position, player.Player.look.aim.forward, out RaycastHit hit, 4, RayMasks.BARRICADE_INTERACT)) { if (BarricadeManager.tryGetInfo(hit.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion r)) { BarricadeData bdata = r.barricades[index]; if (bdata.barricade.id != 3280 || bdata.owner != player.CSteamID.m_SteamID) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"Error occured: this barricade is not a virtual inventory box or box is not yours.", Color.red); Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"Owner steamID: {bdata.owner}\r\nYour steamID: {player.CSteamID.ToString()}"); return; } StateToBlock(bdata, player.CSteamID.ToString(), (command.Length == 0) ? SetBoxName(Plugin.Instance.pathTemp + $@"\{player.CSteamID}") : command[0].Trim()); //BarricadeManager.dropBarricade(bdata.barricade, hit.transform, player.Position, bdata.angle_x, bdata.angle_y, bdata.angle_z, bdata.owner, bdata.group); BarricadeManager.damage(hit.transform, ushort.MaxValue, 1, false); //BarricadeManager.dropBarricade(bdata.barricade, hit.transform, player.Position, bdata.angle_x, bdata.angle_y, bdata.angle_z, bdata.owner, bdata.group); List <ItemData> itemsData = new List <ItemData>(); GetItemsInRadius(bdata.point, 2, new RegionCoordinate(x, y), itemsData); foreach (var item in itemsData) { ItemManager.instance.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, (object)x, (object)y, (object)item.instanceID); } } } }
private void Events_OnBarricadeDestroyed(BarricadeData data, BarricadeDrop drop) { UnturnedBarricadeDestroyedEvent @event = new UnturnedBarricadeDestroyedEvent(new UnturnedBarricadeBuildable(data, drop)); Emit(@event); }
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 Events_OnBarricadeTransformed(BarricadeData data, BarricadeDrop drop) { var @event = new UnturnedBarricadeTransformedEvent(new UnturnedBarricadeBuildable(data, drop)); Emit(@event); }
private static void DestroyBarricade(BarricadeRegion region, ushort index) { ThreadUtil.assertIsGameThread(); BarricadeData data = region.barricades[index]; BarricadeDrop drop = region.drops[index]; OnBarricadeDestroyed?.Invoke(data, drop); }
public void Execute(IRocketPlayer caller, string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; DirectoryInfo directory = new DirectoryInfo(Plugin.Instance.pathTemp + "\\" + ((UnturnedPlayer)caller).CSteamID.ToString()); if (!directory.Exists || directory.GetFiles().Length == 0) { directory.Create(); } if (!GetAllowed(player.CSteamID.ToString(), out ushort allowedTotal, out string groupName)) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, "You groupID was not found to find your find limits"); return; } ushort boxNow = (ushort)new DirectoryInfo(Plugin.Instance.pathTemp + $@"\{player.CSteamID}").GetFiles().Length; if (allowedTotal - boxNow == 0) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"You have reached your limit of boxes in cloud. \r\nLimit: {allowedTotal}\r\nYour groupID: {groupName}"); return; } else if (allowedTotal - boxNow < 0) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"You have {boxNow - allowedTotal} extra boxes in cloud box intentory, drop {boxNow - allowedTotal + 1} boxes to send new box"); return; } if (command.Length > 1) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, U.Translate("command_generic_invalid_parameter")); throw new WrongUsageOfCommandException(caller, this); } if (Physics.Raycast(player.Player.look.aim.position, player.Player.look.aim.forward, out RaycastHit hit, 4, RayMasks.BARRICADE_INTERACT)) { if (BarricadeManager.tryGetInfo(hit.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion r)) { BarricadeData bdata = r.barricades[index]; if (bdata.barricade.id != 3280 || bdata.owner != player.CSteamID.m_SteamID) { Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"Error occured: this barricade is not a virtual inventory box or box is not yours.", Color.red); Rocket.Unturned.Chat.UnturnedChat.Say(caller, $"Owner steamID: {bdata.owner}\r\nYour steamID: {player.CSteamID.ToString()}"); return; } StateToBlock(bdata, player.CSteamID.ToString(), (command.Length == 0) ? SetBoxName(Plugin.Instance.pathTemp + $@"\{player.CSteamID}") : command[0].Trim()); //BarricadeManager.dropBarricade(bdata.barricade, hit.transform, player.Position, bdata.angle_x, bdata.angle_y, bdata.angle_z, bdata.owner, bdata.group); BarricadeManager.damage(hit.transform, ushort.MaxValue, 1, false); //BarricadeManager.dropBarricade(bdata.barricade, hit.transform, player.Position, bdata.angle_x, bdata.angle_y, bdata.angle_z, bdata.owner, bdata.group); List <ItemData> itemsData = new List <ItemData>(); GetItemsInRadius(bdata.point, 2, new RegionCoordinate(x, y), itemsData); foreach (var item in itemsData) { ItemManager.instance.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, (object)x, (object)y, (object)item.instanceID); } } } }
private void Events_OnBarricadeTransformed(BarricadeData data, BarricadeDrop drop, CSteamID instigatorSteamId) { var nativePlayer = PlayerTool.getPlayer(instigatorSteamId); var player = GetUnturnedPlayer(nativePlayer); var @event = new UnturnedBarricadeTransformedEvent(new UnturnedBarricadeBuildable(data, drop), instigatorSteamId, player !); Emit(@event); }
public UnturnedBarricadeBuildable(BarricadeData data, BarricadeDrop drop) : base( new UnturnedBuildableAsset(drop.asset), new UnityTransform(drop.model), new UnturnedBuildableState(data.barricade), new UnturnedBuildableOwnership(data), drop.instanceID.ToString()) { BarricadeData = data; BarricadeDrop = drop; Interactable = drop.interactable; }
public UnturnedBarricadeBuildable(BarricadeData data, BarricadeDrop drop) { BarricadeData = data; BarricadeDrop = drop; Asset = new UnturnedBuildableAsset(drop.asset); Transform = new UnityTransform(drop.model); State = new UnturnedBuildableState(data.barricade); Ownership = new UnturnedBuildableOwnership(data); BuildableInstanceId = drop.instanceID.ToString(); Interactable = drop.interactable; }
private void OnSalvageBarricadeRequested(CSteamID steamID, byte x, byte y, ushort plant, ushort index, ref bool shouldAllow) { BarricadeData data = BarricadeManager.regions[x, y].barricades[index]; BarricadeDrop drop = BarricadeManager.regions[x, y].drops[index]; UnturnedBarricadeSalvagingEvent @event = new UnturnedBarricadeSalvagingEvent(new UnturnedBarricadeBuildable(data, drop)); Emit(@event); shouldAllow = [email protected]; }
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); } }
public static SerializableBarricade Create(BarricadeDrop drop, BarricadeData data) { var barricade = new SerializableBarricade { Position = new SerializableVector3(data.point), Rotation = new SerializableVector3(drop.model.transform.localEulerAngles), Owner = data.owner, Group = data.@group, State = data.barricade.state, Health = data.barricade.health, ID = data.barricade.id }; return(barricade); }
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; } } } } } }
public static SerializableBarricade Create(BarricadeDrop drop, BarricadeData data) { SerializableBarricade result = new SerializableBarricade(); result.Position = new Vector3Wrapper(data.point); result.Rotation = new Vector3Wrapper(drop.model.transform.localEulerAngles); result.Owner = data.owner; result.Group = data.group; result.State = data.barricade.state; result.ActiveDate = data.objActiveDate; result.Health = data.barricade.health; result.Id = data.barricade.id; return(result); }
public static void AskTransformBarricade(byte x, byte y, ushort plant, uint instanceID) { ThreadUtil.assertIsGameThread(); if (!BarricadeManager.tryGetRegion(x, y, plant, out BarricadeRegion region)) { return; } int index = region.barricades.FindIndex(k => k.instanceID == instanceID); BarricadeData data = region.barricades[index]; BarricadeDrop drop = region.drops[index]; OnBarricadeTransformed?.Invoke(data, drop); }
private static void StateToBlock(BarricadeData bdata, string steamID, string boxName) { Block block = new Block(); block.writeUInt16(bdata.barricade.id); block.writeUInt16(bdata.barricade.health); block.writeSingleVector3(bdata.point); block.writeByte(bdata.angle_x); block.writeByte(bdata.angle_y); block.writeByte(bdata.angle_z); block.writeUInt64(bdata.owner); block.writeUInt64(bdata.group); block.writeByteArray(bdata.barricade.state); Functions.WriteBlock(Plugin.Instance.pathTemp + $@"\{steamID}\{boxName}.dat", block, false); }
private void OnHarvested(CSteamID steamID, byte x, byte y, ushort plant, ushort index, ref bool shouldAllow) { if (BarricadeManager.tryGetRegion(x, y, plant, out BarricadeRegion region) && steamID != (CSteamID)0) { BarricadeData data = region.barricades[index]; UnturnedPlayer instigator = UnturnedPlayer.FromCSteamID(steamID); if ((CSteamID)data.owner != instigator.CSteamID && ((CSteamID)data.group != instigator.Player.quests.groupID || data.group == 0) && !R.Permissions.HasPermission(new RocketPlayer(steamID.ToString()), "antigrief.bypass")) { if (Instance.Configuration.Instance.ShowHarvestBlockMessage) { UnturnedChat.Say(steamID, Instance.Translate("antigrief_harvest_blocked"), Color.red); } shouldAllow = false; } } }
public void askSalvageBarricade(CSteamID steamID, byte x, byte y, ushort plant, ushort index) { BarricadeRegion barricadeRegion; bool cancel = false; if (BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion)) { BarricadeData data = barricadeRegion.barricades[(int)index]; BarricadeEvents.RunBarricadeSalvage(UnturnedBarricade.Create(data), ref cancel); } if (!cancel) { DetourManager.CallOriginal(typeof(BarricadeManager).GetMethod("askSalvageBarricade", BindingFlags.Public | BindingFlags.Instance), BarricadeManager.instance, steamID, x, y, plant, index); } }
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.models[i]; InternalData = region.barricades[i]; return; } } } } }
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 void OnBarricadeDamaged(CSteamID instigatorSteamID, Transform barricadeTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin) { SteamPlayer steamPlayer; if (!Configuration.Instance.AllowRaid && (steamPlayer = PlayerTool.getSteamPlayer(instigatorSteamID)) != null) { BarricadeDrop drop = BarricadeManager.FindBarricadeByRootTransform(barricadeTransform); BarricadeData data = drop.GetServersideData(); // return if barricade owner is instigator if (data.owner == instigatorSteamID.m_SteamID || data.group == steamPlayer.player.quests.groupID.m_SteamID) { return; } // return if barricade owner is offline if (!Provider.clients.Exists(x => x.playerID.steamID.m_SteamID == data.owner || x.player.quests.groupID.m_SteamID == data.group)) { return; } this.StartPlayerRaid(instigatorSteamID); } }
public static Transform GetBarricadeTransform(Player player, out BarricadeData barricadeData, out BarricadeDrop drop) { barricadeData = null; drop = null; RaycastHit hit; if (PhysicsUtility.raycast(new Ray(player.look.aim.position, player.look.aim.forward), out hit, 3, RayMasks.BARRICADE_INTERACT)) { Transform transform = hit.transform; InteractableDoorHinge doorHinge = hit.transform.GetComponent <InteractableDoorHinge>(); if (doorHinge != null) { transform = doorHinge.door.transform; } if (BarricadeManager.tryGetInfo(transform, out _, out _, out _, out ushort index, out BarricadeRegion region, out drop)) { barricadeData = region.barricades[index]; return(region.drops[index].model); } } return(null); }
public static Transform dropBarricade(Barricade barricade, Transform hit, Vector3 point, float angle_x, float angle_y, float angle_z, ulong owner, ulong group) { // #Nelson doesn't know how to optimize!!! ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, barricade.id); Transform result = null; if (itemBarricadeAsset == null) { return(result); } Vector3 eulerAngles = BarricadeManager.getRotation(itemBarricadeAsset, angle_x, angle_y, angle_z).eulerAngles; angle_x = (float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2); angle_y = (float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2); angle_z = (float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2); byte b3; byte b4; BarricadeRegion barricadeRegion2; bool cancel = false; if (hit != null && hit.transform.CompareTag("Vehicle")) // Placed on vehicle??? { byte b; byte b2; ushort num; BarricadeRegion barricadeRegion; if (!BarricadeManager.tryGetPlant(hit, out b, out b2, out num, out barricadeRegion)) { return(result); } BarricadeData barricadeData = new BarricadeData(barricade, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, @group, Provider.time); ServerEvents.RunBarricadeCreated(barricadeData, ref cancel); if (cancel) { return(null); } barricadeRegion.barricades.Add(barricadeData); uint num2 = (uint)typeof(BarricadeManager).GetField("", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 1u; result = (Transform)typeof(BarricadeManager).GetMethod("spawnBarricade", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(BarricadeManager.instance, new object[] { barricadeRegion, barricade.id, barricade.state, barricadeData.point, barricadeData.angle_x, barricadeData.angle_y, barricadeData.angle_z, 100, barricadeData.owner, barricadeData.@group, num2 }); BarricadeManager.instance.channel.send("tellBarricade", ESteamCall.OTHERS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { b, b2, num, barricade.id, barricade.state, barricadeData.point, barricadeData.angle_x, barricadeData.angle_y, barricadeData.angle_z, barricadeData.owner, barricadeData.@group, num2 }); } else if (Regions.tryGetCoordinate(point, out b3, out b4) && BarricadeManager.tryGetRegion(b3, b4, 65535, out barricadeRegion2)) { BarricadeData barricadeData2 = new BarricadeData(barricade, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, @group, Provider.time); ServerEvents.RunBarricadeCreated(barricadeData2, ref cancel); if (cancel) { return(null); } barricadeRegion2.barricades.Add(barricadeData2); uint num3 = (uint)typeof(BarricadeManager).GetField("", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 1u; result = (Transform)typeof(BarricadeManager).GetMethod("spawnBarricade", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(BarricadeManager.instance, new object[] { barricadeRegion2, barricade.id, barricade.state, barricadeData2.point, barricadeData2.angle_x, barricadeData2.angle_y, barricadeData2.angle_z, 100, barricadeData2.owner, barricadeData2.@group, num3 }); BarricadeManager.instance.channel.send("tellBarricade", ESteamCall.OTHERS, b3, b4, BarricadeManager.BARRICADE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { b3, b4, 65535, barricade.id, barricade.state, barricadeData2.point, barricadeData2.angle_x, barricadeData2.angle_y, barricadeData2.angle_z, barricadeData2.owner, barricadeData2.@group, num3 }); } return(result); }
public BarricadeTag(Transform transform, BarricadeData data) { Internal = transform; InternalData = data; }
internal static void RunBarricadeCreated(BarricadeData barricade, ref bool cancel) => OnBarricadeCreated?.Invoke(UnturnedBarricade.Create(barricade), ref cancel);
internal void Report(IRocketPlayer caller, ushort itemId, float range, bool printConsole, bool getPinfo, object data, BuildableType type = BuildableType.Element, int count = 0, ulong lockedOwner = 0, int vindex = 0) { Category cat; if (!elements.ContainsKey(itemId)) { if (type == BuildableType.VehicleElement) { if (reportLists[BuildableType.VehicleElement].ContainsKey('!')) { reportLists[BuildableType.VehicleElement]['!'] += 1; } else { reportLists[BuildableType.VehicleElement].Add('!', 1); } cat = categorys['!']; } else { if (reportLists[BuildableType.Element].ContainsKey('!')) { reportLists[BuildableType.Element]['!'] += 1; } else { reportLists[BuildableType.Element].Add('!', 1); } cat = categorys['!']; } } else { if (type == BuildableType.VehicleElement) { if (reportLists[BuildableType.VehicleElement].ContainsKey(elements[itemId].CategoryId)) { reportLists[BuildableType.VehicleElement][elements[itemId].CategoryId] += 1; } else { reportLists[BuildableType.VehicleElement].Add(elements[itemId].CategoryId, 1); } cat = categorys[elements[itemId].CategoryId]; } else { if (reportLists[BuildableType.Element].ContainsKey(elements[itemId].CategoryId)) { reportLists[BuildableType.Element][elements[itemId].CategoryId] += 1; } else { reportLists[BuildableType.Element].Add(elements[itemId].CategoryId, 1); } cat = categorys[elements[itemId].CategoryId]; } } if (printConsole || !elements.ContainsKey(itemId)) { string stype = type == BuildableType.VehicleElement ? "Vehicle Element: " : "Element: "; string msg = string.Empty; ulong owner = 0; InteractableVehicle vehicle = null; StructureData sData = null; BarricadeData bData = null; string eName = string.Empty; if (data is BarricadeData) { bData = data as BarricadeData; owner = bData.owner; eName = bData.barricade.asset.itemName; } else if (data is StructureData) { sData = data as StructureData; owner = sData.owner; eName = sData.structure.asset.itemName; } else if (data is InteractableVehicle) { vehicle = data as InteractableVehicle; itemId = vehicle.id; eName = vehicle.asset.vehicleName; } if (type == BuildableType.Vehicle) { DestructionProcessing.HasFlaggedElement(vindex > 0 ? vehicle.trainCars[vindex].root : vehicle.transform, out ulong signOwner); msg = string.Format("{0}{1} (Id: {6}:{2}, Instance ID: {8}) @ {3}m, Barricade Count: {4}, Sign by: {7}, Locked By: {5}", stype, cat.Name, itemId, Math.Round(range, 2), count, lockedOwner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(lockedOwner) : lockedOwner.ToString() : "N/A", vindex > 0 ? "Train car#" + vindex : eName, signOwner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(signOwner) : signOwner.ToString() : "N/A", vehicle.instanceID.ToString()); } else { // Generate the message in another method, as the Player info one requires special data types that have to be loaded before executing a method. msg = string.Format("{0}{1} (Id: {5}:{2}) @ {3}m, Owner: {4}", stype, cat.Name, itemId, Math.Round(range, 2), owner > 0 ? getPinfo ? WreckingBall.Instance.PInfoGenerateMessage(owner) : owner.ToString() : "N/A", eName); } if (WreckingBall.Instance.Configuration.Instance.LogScans) { Logger.Log(msg, cat.Color); } else { Console.ForegroundColor = cat.Color; Console.WriteLine(msg); Console.ResetColor(); if (R.Settings.Instance.RCON.Enabled) { RCONServer.Broadcast(msg); } } if (WreckingBall.Instance.Configuration.Instance.PrintToChat && !(caller is ConsolePlayer)) { UnturnedChat.Say(caller, msg, Color.yellow); } } }
public BarricadeDataInternal(BarricadeData structureData, bool Plant, Transform transform) { bdata = structureData; plant = Plant; this.transform = transform; }
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); } } } }