void AddSwitch(AutoTurret aturret) { ElectricBattery bat = null; if (IsBatEnabled()) { bat = AddBattery(aturret.GetParentEntity() as MiniCopter); } ElectricSwitch aSwitch = aturret.GetComponentInChildren <ElectricSwitch>(); aSwitch = GameManager.server.CreateEntity(switchPrefab, aturret.transform.position)?.GetComponent <ElectricSwitch>(); if (aSwitch == null) { return; } aSwitch.pickup.enabled = false; aSwitch.SetParent(aturret); aSwitch.transform.localPosition = new Vector3(0f, -0.65f, 0.325f); aSwitch.transform.localRotation = Quaternion.Euler(0, 0, 0); DestroyMeshCollider(aSwitch); DestroyGroundComp(aSwitch); aSwitch.Spawn(); aSwitch._limitedNetworking = false; if (!IsBatEnabled()) { RunWire(aSwitch, 0, aturret, 0, 12); } else if (bat != null) { RunWire(bat, 0, aSwitch, 0); RunWire(aSwitch, 0, aturret, 0); } }
private object OnSwitchToggle(ElectricSwitch eswitch, BasePlayer player) { if (IsBatEnabled()) { return(null); } BaseEntity parent = eswitch.GetParentEntity(); if (parent != null && parent.PrefabName.Equals(autoturretPrefab)) { AutoTurret turret = parent as AutoTurret; if (turret == null) { return(null); } if (!eswitch.IsOn()) { PowerTurretOn(turret); } else { PowerTurretOff(turret); } } return(null); }
private object OnSwitchToggle(ElectricSwitch eswitch, BasePlayer player) { if (eswitch == null) { return(null); } if (player == null) { return(null); } if (switches.Contains(eswitch.net.ID)) { #if DEBUG Puts("OnSwitchToggle called for one of our switches!"); #endif if (IsLocked(eswitch.net.ID)) { if (eswitch.OwnerID == player.userID && ownerBypass) { #if DEBUG Puts("OnSwitchToggle: Per config, owner can bypass"); #endif return(null); } Message(player.IPlayer, "locked"); return(true); } } return(null); }
private void OnSwitchToggled(ElectricSwitch electricSwitch) { var autoTurret = GetParentTurret(electricSwitch); if (autoTurret == null) { return; } var drone = GetParentDrone(autoTurret); if (drone == null) { return; } if (electricSwitch.IsOn()) { autoTurret.InitiateStartup(); } else { autoTurret.InitiateShutdown(); } return; }
private void OnEntitySpawned(ElectricSwitch eswitch) { if (eswitch != null) { if (eswitch.name.Contains("fluid")) { return; } BasePlayer player = FindOwner(eswitch.OwnerID); if (player == null) { #if DEBUG Puts($"Could not find owner of this switch."); #endif return; } if (!player.IPlayer.HasPermission(permElectrolockUse)) { #if DEBUG Puts($"Player {player.displayName} denied permission."); #endif return; } if (!userenabled.ContainsKey(player.userID)) { #if DEBUG Puts($"Player {player.displayName} has never enabled ElectroLock."); #endif Message(player.IPlayer, "disabled"); return; } if (userenabled[player.userID] == false || userenabled[player.userID] == null) { #if DEBUG Puts($"Player {player.displayName} has ElectroLock disabled."); #endif Message(player.IPlayer, "disabled"); return; } if (eswitch) { if (AddLock(eswitch)) { switches.Add(eswitch.net.ID); Message(player.IPlayer, "spawned"); SaveData(); } else { Message(player.IPlayer, "failed"); } } player = null; } }
private static void SetupTurretSwitch(ElectricSwitch electricSwitch) { // Damage will be processed by the drone. electricSwitch.baseProtection = null; electricSwitch.pickup.enabled = false; electricSwitch.SetFlag(IOEntity.Flag_HasPower, true); RemoveProblemComponents(electricSwitch); HideInputsAndOutputs(electricSwitch); }
// Redirect damage from the turret switch to the drone. private bool?OnEntityTakeDamage(ElectricSwitch electricSwitch, HitInfo info) { var autoTurret = GetParentTurret(electricSwitch); if (autoTurret == null) { return(null); } var drone = GetParentDrone(autoTurret); if (drone == null) { return(null); } drone.Hurt(info); HitNotify(drone, info); return(true); }