private object OnSamSiteTarget(SamSite samSite, BaseCombatEntity target)
        {
            if (SamSite.alltarget)
            {
                if (samSite.OwnerID == 0) // stop monument samsites from shooting attack heli or ch47
                {
                    if (target.prefabID == 1514383717 || target.prefabID == 3029415845)
                    {
                        return(false);
                    }
                }
                if (target.prefabID == 209286362) // stop hackable crate being shot
                {
                    return(false);
                }
            }
            int kind;

            if (!vehicles.TryGetValue(target.prefabID, out kind))
            {
                return(null);
            }
            if (!IsAuthed(samSite, target, kind))
            {
                return(null);
            }
            return(false);
        }
 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);
     }
 }
        private static bool IsAuthed(SamSite samSite, BaseCombatEntity target, int kind)
        {
            switch (kind)
            {
            case 0: return(true);

            case 1: return(IsPilot(samSite, target));

            case 2: return(IsVicinity(samSite, target));

            default: return(false);
            }
        }
示例#5
0
        object OnSamSiteTarget(SamSite samsite, MiniCopter target)
        {
            BasePlayer player = target.GetDriver();

            BuildingPrivlidge priviledge = samsite.GetBuildingPrivilege();

            if (player != null && permission.UserHasPermission(player.UserIDString, turretsIgnore) || (samsite.ShortPrefabName == "sam_site_turret_deployed" && _config.samSitesAffected || samsite.ShortPrefabName == "sam_static" && _config.staticSamSitesAffected) && (priviledge == null || priviledge != null && ((priviledge.IsAuthed(player) || (!priviledge.IsAuthed(player.userID) && !player.IsBuildingBlocked())))))
            {
                return(false);
            }

            return(null);
        }
 public void ToggleSamsite(SamSite sam, BasePlayer player = null)
 {
     if (player != null)
     {
         if (sam.GetBuildingPrivilege() != player.GetBuildingPrivilege())
         {
             player.ChatMessage(Instance.Lang("NoPermThisTurret", player.UserIDString));
             return;
         }
     }
     if (sam.IsPowered() || onlineSams.Contains(sam))
     {
         PowerSamsiteOff(sam);
     }
     else
     {
         PowerSamsiteOn(sam);
     }
     sam.SendNetworkUpdate();
 }
 private void OnServerInitialized()
 {
     foreach (var ent in BaseEntity.serverEntities)
     {
         if (ent is AutoTurret)
         {
             AutoTurret turret = ent as AutoTurret;
             if (data.AutoTurrets.Contains(turret.net.ID))
             {
                 turretManager.PowerTurretOn(turret);
             }
         }
         else if (ent is SamSite)
         {
             SamSite sam = ent as SamSite;
             if (data.SamSites.Contains(sam.net.ID))
             {
                 turretManager.PowerSamsiteOn(sam);
             }
         }
     }
 }
示例#8
0
            public void ToggleSamsite(SamSite samSite, BasePlayer player = null)
            {
                if (samSite == null)
                {
                    return;
                }

                if (player != null && samSite.GetBuildingPrivilege()?.IsAuthed(player) == false)
                {
                    player.ChatMessage(_instance.Lang("NoPermThisTurret", player.UserIDString));
                    return;
                }

                if (samSite.IsPowered())
                {
                    PowerSamsiteOff(samSite);
                }
                else
                {
                    PowerSamsiteOn(samSite);
                }

                samSite.SendNetworkUpdate();
            }
 private static bool IsPilot(SamSite entity, BaseCombatEntity target)
 {
     driver = (target as BaseVehicle).GetDriver();
     return(driver == null || IsAuthed(driver, entity));
 }
 private static bool IsVicinity(SamSite entity, BaseCombatEntity target)
 {
     players.Clear();
     Vis.Entities(target.transform.position, 2, players, Rust.Layers.Mask.Player_Server);
     return(players.Count == 0 || players.Any(player => IsAuthed(player, entity)));
 }
示例#11
0
        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();
                    }
                }
            }
        }
示例#12
0
        private object CanSamSiteShoot(SamSite samSite)
        {
            if (samSite == null)
            {
                return(false);
            }

            List <BasePlayer> targetPlayers = new List <BasePlayer>();

            switch (samSite.currentTarget.prefabID)
            {
            case 2278499844:     //minicopter
                MiniCopter      targetCopter = samSite.currentTarget as MiniCopter;
                BaseVehicleSeat driverSeat   = null;
                //if (targetCopter == null) PrintToChat("copter not found");
                if (targetCopter != null)
                {
                    driverSeat = targetCopter.GetComponentsInChildren <BaseVehicleSeat>()[0];
                }
                //if (driverSeat == null) PrintToChat("seat not found");
                if (driverSeat != null)
                {
                    targetPlayers.Add(driverSeat._mounted);
                }
                break;

            case 3111236903:     //hotairballoon
                HotAirBalloon targetBalloon = samSite.currentTarget as HotAirBalloon;
                Vis.Entities(targetBalloon.transform.position, 2, targetPlayers);
                break;

            default:
                return(false);
            }

            if (targetPlayers.Count == 0)
            {
                return(null);
            }

            //calculate distance
            float distance = Vector3.Distance(samSite.transform.position, samSite.currentTarget.transform.position);

            //warning
            if (distance > firingRange)
            {
                foreach (var player in targetPlayers)
                {
                    //player.ChatMessage(warningMsg);
                    GUIAnnouncements?.Call("CreateAnnouncement", getCustomMsg(false, samSite.GetInstanceID()), "grey", "white", player);
                    return(false);
                }
            }

            //firing
            else
            {
                foreach (var player in targetPlayers)
                {
                    //player.ChatMessage(firingMsg);
                    GUIAnnouncements?.Call("CreateAnnouncement", getCustomMsg(true, samSite.GetInstanceID()), "red", "white", player);
                    return(null);
                }
            }
            return(false);
        }