public void PowerSamsiteOn(SamSite sam) { sam.UpdateHasPower(25, 0); sam.SetFlag(BaseEntity.Flags.Reserved8, true); if (!onlineSams.Contains(sam)) { onlineSams.Add(sam); } }
private void PowerSamsiteOff(SamSite sam) { sam.UpdateHasPower(0, 0); sam.SetFlag(BaseEntity.Flags.Reserved8, false); if (onlineSams.Contains(sam)) { onlineSams.Remove(sam); } }
public void TurretInput(InputState input, BasePlayer player) { if (input == null || player == null) { return; } BUTTON.TryParse(Button, out PowerButton); if (input.WasJustPressed(PowerButton)) { bool hasPermission = permission.UserHasPermission(player.UserIDString, perms); if (!hasPermission) { player.ChatMessage(msg("NoPermissions", player.UserIDString)); return; } RaycastHit hit; if (Physics.SphereCast(player.eyes.position, 0.5f, Quaternion.Euler(player.serverInput.current.aimAngles) * Vector3.forward, out hit)) { AutoTurret autoturret = hit.GetEntity()?.GetComponent <AutoTurret>(); SamSite samsite = hit.GetEntity()?.GetComponent <SamSite>(); if (autoturret != null) { if (hit.distance >= 1.5) { return; } if (!autoturret.IsAuthed(player)) { player.ChatMessage(msg("NotAuthed", player.UserIDString)); return; } if (!IsAuthed(player, autoturret)) { player.ChatMessage(msg("NoBuildPrivilege", player.UserIDString)); return; } if (autoturret.IsOnline()) { autoturret.SetIsOnline(false); PoweredTurrets.Remove(autoturret.net.ID); } else { autoturret.SetIsOnline(true); PoweredTurrets.Add(autoturret.net.ID); } autoturret.SendNetworkUpdateImmediate(); } if (samsite != null) { if (hit.distance >= 1.5) { return; } if (!IsAuthed(player, samsite)) { player.ChatMessage(msg("NoBuildPrivilege", player.UserIDString)); return; } if (samsite.IsPowered()) { samsite.UpdateHasPower(0, 1); PoweredSams.Remove(samsite.net.ID); } else { samsite.UpdateHasPower(25, 1); PoweredSams.Add(samsite.net.ID); } samsite.SendNetworkUpdateImmediate(); } } } }