private void ApplyComponents() { if (Configuration.Instance.allSentriesInfinite) { return; } foreach (BarricadeRegion r in BarricadeManager.regions) { for (int i = r.drops.Count - 1; i >= 0; i--) { BarricadeDrop drop = r.drops[i]; InteractableSentry s = drop.interactable as InteractableSentry; if (s == null) { continue; } // Consider using reverse for loop here. SentryTrackerComponent can modify collection // Using foreach will cause an exception to be thrown if/when this happens foreach (SentryPosition pos in Configuration.Instance.sentries) { if (pos.CompareVector3(s.transform.position)) { s.gameObject.AddComponent <SentryTrackerComponent>(); } } } } }
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 Events_OnBarricadeTransformed(BarricadeData data, BarricadeDrop drop) { var @event = new UnturnedBarricadeTransformedEvent(new UnturnedBarricadeBuildable(data, drop)); Emit(@event); }
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); }
private void Events_OnBarricadeDestroyed(BarricadeData data, BarricadeDrop drop) { UnturnedBarricadeDestroyedEvent @event = new UnturnedBarricadeDestroyedEvent(new UnturnedBarricadeBuildable(data, drop)); Emit(@event); }
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); }
private void Events_OnBarricadeTransformed(BarricadeDrop drop) { var player = GetUnturnedPlayer(s_CurrentTransformingPlayer); var @event = new UnturnedBarricadeTransformedEvent(new UnturnedBarricadeBuildable(drop), player); 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 OnBarricadeSpawned(BarricadeRegion region, BarricadeDrop drop) { if (drop.asset.id != 1241) { return; } ActiveC4.Add(SpawnC4Barricade(region, drop, 30000)); }
public void OnBarricadeSpawned(BarricadeRegion region, BarricadeDrop drop) { if (drop.asset.id != 1050) { return; } ActiveHealthStations.Add(SpawnHealthStationBarricade(region, drop, 20000)); }
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(BarricadeDrop drop) : base( new UnturnedBuildableAsset(drop.asset), new UnityTransform(drop.model), new UnturnedBuildableState(drop.GetServersideData().barricade), new UnturnedBuildableOwnership(drop.GetServersideData()), drop.instanceID.ToString()) { 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; }
public void Execute(IRocketPlayer caller, string[] args) { var PlayerCaller = (UnturnedPlayer)caller; InteractableDoorHinge component = raycastdoor.Getdoor(PlayerCaller); if (component != null) { bool isregistered = false; InteractableDoor door = component.door; bool flag = !door.isOpen; byte x; byte y; ushort plant; ushort index; BarricadeRegion barricadeRegion; BarricadeManager.tryGetInfo(door.transform, out x, out y, out plant, out index, out barricadeRegion); BarricadeDrop barricadedrop = barricadeRegion.drops[index]; var ID = barricadedrop.instanceID; foreach (Registereddoortype doorinfo in miscstuff.Instance.Configuration.Instance.listofregistereddoors) { if (doorinfo.ID == ID) { isregistered = true; if (caller.HasPermission(doorinfo.permission)) { //OPEN THE DOOOOOOOR Rocket.Core.Logging.Logger.Log("Player has perm: " + doorinfo.permission); SteamCaller steamCaller = (BarricadeManager)typeof(BarricadeManager).GetField("manager", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); door.updateToggle(flag); steamCaller.channel.send("tellToggleDoor", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] { x, y, plant, index, flag }); Rocket.Core.Logging.Logger.Log("Player toggled door " + doorinfo.ID); UnturnedChat.Say(caller, doorinfo.name + " door toggled", Color.yellow); } else { UnturnedChat.Say(caller, "You do not have the right permissions to open this door", Color.red); } } } if (isregistered == false) { UnturnedChat.Say(caller, "Door is not registered!", Color.red); } } }
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 void OnSalvageBarricadeRequested(BarricadeDrop drop, SteamPlayer instigator, ref bool shouldAllow) { var player = GetUnturnedPlayer(instigator); var @event = new UnturnedBarricadeSalvagingEvent(new UnturnedBarricadeBuildable(drop), player !) { IsCancelled = !shouldAllow }; Emit(@event); shouldAllow = [email protected]; }
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); } } }
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); }
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 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 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); }
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 override Task DestroyAsync() { async UniTask DestroyTask() { await UniTask.SwitchToMainThread(); if (BarricadeDrop.GetNetId().IsNull()) { return; } if (BarricadeManager.tryGetRegion(BarricadeDrop.model, out var x, out var y, out var plant, out _)) { BarricadeManager.destroyBarricade(BarricadeDrop, x, y, plant); } } return(DestroyTask().AsTask()); }
public void Execute(IRocketPlayer caller, string[] args) { var PlayerCaller = (UnturnedPlayer)caller; InteractableDoorHinge component = raycastdoor.Getdoor(PlayerCaller); if (component != null) { InteractableDoor door = component.door; bool flag = !door.isOpen; byte x; byte y; ushort plant; ushort index; BarricadeRegion barricadeRegion; BarricadeManager.tryGetInfo(door.transform, out x, out y, out plant, out index, out barricadeRegion); BarricadeDrop barricadedrop = barricadeRegion.drops[index]; var ID = barricadedrop.instanceID; UnturnedChat.Say(caller, "Index of this door is: " + index); UnturnedChat.Say(caller, "Instance ID of this door is:" + ID); 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 void Execute(IRocketPlayer caller, string[] args) { var PlayerCaller = (UnturnedPlayer)caller; // actually get the door you are looking at if (args.Length != 2) { UnturnedChat.Say(caller, "Invalid arguments", Color.red); return; } InteractableDoorHinge component = raycastdoor.Getdoor(PlayerCaller); if (component != null) { var name = args[0]; var permissionname = args[1]; InteractableDoor door = component.door; byte x; byte y; ushort plant; ushort index; BarricadeRegion barricadeRegion; BarricadeManager.tryGetInfo(door.transform, out x, out y, out plant, out index, out barricadeRegion); var permission = "Registereddoor." + permissionname; Registereddoortype tempvar = new Registereddoortype(); tempvar.name = name; tempvar.permission = permission; tempvar.steamid = PlayerCaller.CSteamID.ToString(); tempvar.doorposition = door.transform.position; BarricadeDrop barricadedrop = barricadeRegion.drops[index]; var ID = barricadedrop.instanceID; tempvar.ID = ID; if (miscstuff.Instance.Configuration.Instance.listofregistereddoors.Count > 0) { foreach (Registereddoortype doorinfo in miscstuff.Instance.Configuration.Instance.listofregistereddoors) { if (doorinfo.name == tempvar.name) { UnturnedChat.Say(caller, "A door already exists with that name!", Color.red); return; } else if (doorinfo.ID == ID) { UnturnedChat.Say(caller, "This door " + doorinfo.name + " is already registered!", Color.red); return; } } } miscstuff.Instance.Configuration.Instance.listofregistereddoors.Add(tempvar); UnturnedChat.Say(caller, "Door Registered!", Color.blue); miscstuff.Instance.Configuration.Save(); } else { UnturnedChat.Say(caller, "Not looking at a door!"); return; } }
static public C4 SpawnC4Barricade(BarricadeRegion region, BarricadeDrop drop, int time) => new C4(region, drop, time);
public void Execute(IRocketPlayer caller, string[] args) { if (args.Length > 1) { UnturnedChat.Say(caller, "invalid arguments", Color.red); return; } else if (args.Length == 1) { bool isregistered = false; foreach (Registereddoortype doorinfo in miscstuff.Instance.Configuration.Instance.listofregistereddoors) { if (doorinfo.name == args[0]) { isregistered = true; miscstuff.Instance.Configuration.Instance.listofregistereddoors.Remove(doorinfo); UnturnedChat.Say(caller, "Door" + doorinfo.name + " Unregistered!"); miscstuff.Instance.Configuration.Save(); } } if (isregistered == false) { UnturnedChat.Say(caller, "Registered Door does not exist with that name", Color.red); } } else if (args.Length == 0) { var PlayerCaller = (UnturnedPlayer)caller; InteractableDoorHinge component = raycastdoor.Getdoor(PlayerCaller); if (component != null) { InteractableDoor door = component.door; bool flag = !door.isOpen; byte x; byte y; ushort plant; ushort index; BarricadeRegion barricadeRegion; BarricadeManager.tryGetInfo(door.transform, out x, out y, out plant, out index, out barricadeRegion); BarricadeDrop barricadedrop = barricadeRegion.drops[index]; var ID = barricadedrop.instanceID; bool isregistered = false; foreach (Registereddoortype doorinfo in miscstuff.Instance.Configuration.Instance.listofregistereddoors) { if (doorinfo.ID == ID) { isregistered = true; miscstuff.Instance.Configuration.Instance.listofregistereddoors.Remove(doorinfo); UnturnedChat.Say(caller, "Door" + doorinfo.name + " Unregistered!"); miscstuff.Instance.Configuration.Save(); } } if (isregistered == false) { UnturnedChat.Say(caller, "That door is not registered!", Color.red); } } else { UnturnedChat.Say(caller, "You are not looking at a valid object", Color.red); } } }
static public HealthStation SpawnHealthStationBarricade(BarricadeRegion region, BarricadeDrop drop, int time) => new HealthStation(region, drop, time);
private void Events_OnBarricadeDeployed(BarricadeRegion region, BarricadeDrop drop) { var @event = new UnturnedBarricadeDeployedEvent(new UnturnedBarricadeBuildable(drop)); Emit(@event); }