Ejemplo n.º 1
0
 public void PlayNote(float scale)
 {
     effectP.worldPos = transform.position;
     effectP.origin   = transform.position;
     effectP.scale    = scale;
     EffectNetwork.Send(effectP);
 }
Ejemplo n.º 2
0
            public void FireProjectile(BasePlayer player, Vector3 position, Vector3 velocity)
            {
                //var item = ItemManager.CreateByName("ammo.rifle.incendiary");
                var itemModProjectile = item.info.GetComponent <ItemModProjectile>();
                var projectile        = itemModProjectile.projectileObject.Get().GetComponent <Projectile>();

                //Puts($"itemModProjectile.projectileVelocity: {itemModProjectile.projectileVelocity}");

                FiredProjectile firedProjectile = new FiredProjectile
                {
                    itemDef          = item.info,
                    itemMod          = itemModProjectile,
                    projectilePrefab = projectile,
                    firedTime        = UnityEngine.Time.realtimeSinceStartup,
                    travelTime       = 0f,
                    position         = position,
                    velocity         = velocity,
                    initialPosition  = position,
                    initialVelocity  = velocity
                };

                Add(firedProjectile);

                Effect effect = new Effect();

                effect.Clear();
                effect.Init(global::Effect.Type.Projectile, position, velocity, null);
                effect.scale        = 2;
                effect.pooledString = itemModProjectile.projectileObject.resourcePath;
                effect.number       = 1;
                EffectNetwork.Send(effect);
            }
Ejemplo n.º 3
0
 private void PlayTuneStack()
 {
     if (!playingTune)
     {
         playingTune = true;
     }
     if (nextNote.Pluck)
     {
         effectP.worldPos = transform.position;
         effectP.origin   = transform.position;
         effectP.scale    = nextNote.NoteScale;
         EffectNetwork.Send(effectP);
     }
     else
     {
         effectS.worldPos = transform.position;
         effectS.origin   = transform.position;
         effectS.scale    = nextNote.NoteScale;
         EffectNetwork.Send(effectS);
     }
     if (tuneToPlay.Count > 0 && enabled)
     {
         Invoke("PlayTuneStack", nextNote.Delay);
         nextNote = tuneToPlay.Pop();
     }
     else
     {
         if (!enabled)
         {
             tuneToPlay = new Stack <TuneNote>();
         }
         playingTune = false;
     }
 }
Ejemplo n.º 4
0
        private object CanLock(BasePlayer player, BaseLock @lock)
        {
            if (player == null || @lock == null)
            {
                return(null);
            }
            if (@lock.IsLocked())
            {
                return(false);
            }
            if (playerPrefs.ContainsKey(player.UserIDString) && !playerPrefs[player.UserIDString])
            {
                return(null);
            }

            var prefab = @lock.parentEntity.Get(true).ShortPrefabName;

            if (prefab == null)
            {
                return(null);
            }

            var codeLock = @lock as CodeLock;

            foreach (var type in lockableTypes)
            {
                if (!prefab.Contains(type))
                {
                    continue;
                }
                if (!permission.UserHasPermission(player.UserIDString, $"masterkey.{type}"))
                {
                    return(null);
                }

                if (showMessages)
                {
                    player.ChatMessage(Lang("UnlockedWith", player.UserIDString, type));
                }
                if (logUsage)
                {
                    Log(Lang("LogLock", null, PlayerName(player), type, player.transform.position));
                }

                if (@lock != null)
                {
                    @lock.SetFlag(BaseEntity.Flags.Locked, true);
                }
                if (player != null && codeLock != null)
                {
                    EffectNetwork.Send(new Effect(codeLock.effectLocked.resourcePath, player.transform.position, Vector3.zero));
                }

                return(false);
            }

            return(null);
        }
Ejemplo n.º 5
0
    private void SVPlayNote(BaseEntity.RPCMessage msg)
    {
        byte   num1   = msg.read.UInt8();
        float  num2   = msg.read.Float();
        Effect effect = new Effect(this.soundEffect[(int)num1].resourcePath, (BaseEntity)this, 0U, Vector3.get_zero(), Vector3.get_forward(), msg.connection);

        effect.scale = (__Null)(double)num2;
        EffectNetwork.Send(effect);
    }
Ejemplo n.º 6
0
 public static void Run(string strName, Vector3 posWorld = default(Vector3), Vector3 normWorld = default(Vector3), Connection sourceConnection = null, bool broadcast = false)
 {
     if (!string.IsNullOrEmpty(strName))
     {
         reusableInstace.Init(Type.Generic, posWorld, normWorld, sourceConnection);
         reusableInstace.pooledString = strName;
         reusableInstace.broadcast    = broadcast;
         EffectNetwork.Send(reusableInstace);
     }
 }
Ejemplo n.º 7
0
 public static void Run(string strName, BaseEntity ent, uint boneID, Vector3 posLocal, Vector3 normLocal, Connection sourceConnection = null, bool broadcast = false)
 {
     if (!string.IsNullOrEmpty(strName))
     {
         reusableInstace.Init(Type.Generic, ent, boneID, posLocal, normLocal, sourceConnection);
         reusableInstace.pooledString = strName;
         reusableInstace.broadcast    = broadcast;
         EffectNetwork.Send(reusableInstace);
     }
 }
    private void SVPlayNote(BaseEntity.RPCMessage msg)
    {
        byte  num    = msg.read.UInt8();
        float single = msg.read.Float();

        EffectNetwork.Send(new Effect(this.soundEffect[num].resourcePath, this, 0, Vector3.zero, Vector3.forward, msg.connection)
        {
            scale = single
        });
    }
Ejemplo n.º 9
0
 public static void Run(
     Effect.Type fxtype,
     Vector3 posWorld,
     Vector3 normWorld,
     Connection sourceConnection = null,
     bool broadcast = false)
 {
     Effect.reusableInstace.Init(fxtype, posWorld, normWorld, sourceConnection);
     Effect.reusableInstace.broadcast = broadcast;
     EffectNetwork.Send(Effect.reusableInstace);
 }
Ejemplo n.º 10
0
        private void SendHit(BasePlayer attacker, HitInfo info)
        {
            if (info == null || attacker == null || !attacker.IsConnected)
            {
                return;
            }
            if (_storedData.DisabledUsers.Contains(attacker.userID))
            {
                return;
            }
            if (info.HitEntity is BaseNpc && _showNpc)
            {
                GuiDisplay(attacker, _colorNpc, info);
                return;
            }
            var victim = info.HitEntity as BasePlayer;

            if (victim == null)
            {
                return;
            }
            if (victim == attacker)
            {
                return;
            }
            if (_useClans && _clansAPI)
            {
                if (AreClanMates(attacker.userID, victim.userID))
                {
                    GuiDisplay(attacker, _colorClan, info, false, "clans");
                    if (_useSound)
                    {
                        EffectNetwork.Send(new Effect(_mateSound, attacker.transform.position, Vector3.zero), attacker.net.connection);
                    }
                    return;
                }
            }
            if (_friendAPI && _useFriends && AreFriends(victim.userID.ToString(), attacker.userID.ToString()))
            {
                GuiDisplay(attacker, _colorFriend, info, false, "friends");
                if (_useSound)
                {
                    EffectNetwork.Send(new Effect(_mateSound, attacker.transform.position, Vector3.zero), attacker.net.connection);
                }
                return;
            }
            if (info.isHeadshot)
            {
                GuiDisplay(attacker, _colorHead, info, false, "", true);
                return;
            }
            GuiDisplay(attacker, _colorBody, info);
        }
Ejemplo n.º 11
0
 public static void Run(
     Effect.Type fxtype,
     BaseEntity ent,
     uint boneID,
     Vector3 posLocal,
     Vector3 normLocal,
     Connection sourceConnection = null,
     bool broadcast = false)
 {
     Effect.reusableInstace.Init(fxtype, ent, boneID, posLocal, normLocal, sourceConnection);
     Effect.reusableInstace.broadcast = broadcast;
     EffectNetwork.Send(Effect.reusableInstace);
 }
Ejemplo n.º 12
0
        void DisplayBannerToAll(string reason)
        {
            foreach (var player in BasePlayer.activePlayerList)
            {
                if (bannerdisplay == true)
                {
                    string message = string.Empty;
                    if (reason == "spawn")
                    {
                        message = $"{lang.GetMessage("SpawnMsg", this, player.UserIDString)}";
                    }
                    if (reason == "killed")
                    {
                        message = $"{lang.GetMessage("KilledMsg", this, player.UserIDString)}";
                    }
                    var CuiElement   = new CuiElementContainer();
                    var PatrolBanner = CuiElement.Add(new CuiPanel {
                        Image = { Color = bannercolor }, RectTransform = { AnchorMin = "0.20 0.85", AnchorMax = "0.80 0.90" }, CursorEnabled = false
                    });
                    var closeButton = new CuiButton {
                        Button = { Close = PatrolBanner, Color = "0.0 0.0 0.0 0.6" }, RectTransform = { AnchorMin = "0.90 0.01", AnchorMax = "0.99 0.99" }, Text = { Text = "X", FontSize = 20, Align = TextAnchor.MiddleCenter }
                    };
                    CuiElement.Add(closeButton, PatrolBanner);
                    CuiElement.Add(new CuiLabel {
                        Text = { Text = $"{message}", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1.0 1.0 1.0 1" }, RectTransform = { AnchorMin = "0.10 0.10", AnchorMax = "0.90 0.90" }
                    }, PatrolBanner);

                    CuiHelper.AddUi(player, CuiElement);

                    timer.Once(12, () =>
                    {
                        CuiHelper.DestroyUi(player, PatrolBanner);
                    });
                    if (debug == true)
                    {
                        Puts($"BANNER DISPLAYING FOR PLAYER {player.displayName}");
                    }
                }

                if (sound == true)
                {
                    var sound = new Effect("assets/bundled/prefabs/fx/player/howl.prefab", player, 0, Vector3.zero, Vector3.forward);
                    EffectNetwork.Send(sound, player.net.connection);
                    if (debug == true)
                    {
                        Puts($"PLAYING SOUND FOR PLAYER {player.displayName}");
                    }
                }
            }
        }
Ejemplo n.º 13
0
    private void CreateProjectileEffectClientside(string prefabName, UnityEngine.Vector3 pos, UnityEngine.Vector3 velocity, int seed, Connection sourceConnection, bool silenced = false, bool forceClientsideEffects = false)
    {
        Effect effect = BaseProjectile.reusableInstance;

        effect.Clear();
        effect.Init(Effect.Type.Projectile, pos, velocity, sourceConnection);
        effect.scale = (silenced ? 0f : 1f);
        if (forceClientsideEffects)
        {
            effect.scale = 2f;
        }
        effect.pooledString = prefabName;
        effect.number       = seed;
        EffectNetwork.Send(effect);
    }
Ejemplo n.º 14
0
        private void InitializeTimer()
        {
            if (AFKTimer != null && !AFKTimer.Destroyed)
            {
                AFKTimer.Destroy();
            }
            AFKTimer = timer.Every(Settings.GeneralSettings.StatusRefreshInterval, () =>
            {
                foreach (var trackedPlayer in TrackedPlayers.Values)
                {
                    trackedPlayer.CheckPosition(Settings.CompareSettings.CompareRotation);
                    if (trackedPlayer.TimeAFK >= Settings.GeneralSettings.SecondsToAFKStatus && !AFKPlayers.Contains(trackedPlayer.Player))
                    {
                        AFKPlayers.Add(trackedPlayer.Player);
                    }
                    else if (trackedPlayer.TimeAFK < Settings.GeneralSettings.SecondsToAFKStatus && AFKPlayers.Contains(trackedPlayer.Player))
                    {
                        AFKPlayers.Remove(trackedPlayer.Player);
                    }
                    if (Settings.NotificationSettings.NotifyPlayer && Settings.GeneralSettings.SecondsToAFKStatus - trackedPlayer.TimeAFK < Settings.NotificationSettings.NotifyPlayerTime)
                    {
                        Messenger(trackedPlayer.Player, true, mnotify);
                        if (Settings.NotificationSettings.NotifyPlayerSound)
                        {
                            var beep = new Effect();
                            beep.Init(Effect.Type.Generic, trackedPlayer.Player.transform.position, trackedPlayer.Player.transform.forward);
                            beep.pooledString = "assets/prefabs/tools/pager/effects/beep.prefab";
                            EffectNetwork.Send(beep, trackedPlayer.Player.Connection);
                        }
                    }
                }
            });
#if (DEBUG)
            Puts($"New timer initialized with {Settings.GeneralSettings.StatusRefreshInterval.ToString()} interval. " +
                 $"Notifications are {(Settings.NotificationSettings.NotifyPlayer ? "ON" : "OFF")}. " +
                 $"Sounds are {(Settings.NotificationSettings.NotifyPlayerSound ? "ON" : "OFF")}...");
#endif
        }
Ejemplo n.º 15
0
        private void OnPlayerInput(BasePlayer player, InputState input)
        {
            if (player == null || input == null)
            {
                return;
            }

            if (input.IsDown(BUTTON.FORWARD) || input.IsDown(BUTTON.BACKWARD) || input.IsDown(BUTTON.LEFT) || input.IsDown(BUTTON.RIGHT))
            {
                try
                {
                    var activeCamera = player.GetMounted().GetComponentInParent <ComputerStation>() ?? null;
                    if (activeCamera != null)
                    {
                        var cctv = activeCamera.currentlyControllingEnt.Get(true).GetComponent <CCTV_RC>();
                        if (cctv == null)
                        {
                            return;
                        }
                        if (cctv.IsStatic() && !player.IPlayer.HasPermission(permCCTVAdmin))
                        {
                            return;
                        }
                        cctv.hasPTZ = true;

                        float x = input.IsDown(BUTTON.RIGHT) ? 1f : (input.IsDown(BUTTON.LEFT) ? -1f : 0f);
                        float y = input.IsDown(BUTTON.FORWARD) ? 1f : (input.IsDown(BUTTON.BACKWARD) ? -1f : 0f);
#if DEBUG
                        string lr   = input.IsDown(BUTTON.RIGHT) ? "right" : (input.IsDown(BUTTON.LEFT) ? "left" : "");
                        string ud   = input.IsDown(BUTTON.FORWARD) ? "up" : (input.IsDown(BUTTON.BACKWARD) ? "down" : "");
                        string udlr = ud + lr;
                        Puts($"Trying to move camera {udlr}.");
#endif
                        float speed = 0.1f;
                        if (input.IsDown(BUTTON.SPRINT))
                        {
                            speed *= 3;
                        }

                        InputState inputState = new InputState();
                        inputState.current.mouseDelta.y = y * speed;
                        inputState.current.mouseDelta.x = x * speed;

                        cctv.UserInput(inputState, player);

                        if (configData.playSound)
                        {
                            Effect effect = new Effect(moveSound, new Vector3(0, 0, 0), Vector3.forward);
                            if (configData.playAtCamera)
                            {
                                effect.worldPos = cctv.transform.position;
                                effect.origin   = cctv.transform.position;
                            }
                            else
                            {
                                effect.worldPos = player.transform.position;
                                effect.origin   = player.transform.position;
                            }
                            EffectNetwork.Send(effect);
                        }
                    }
                }
                catch {}
            }
        }
Ejemplo n.º 16
0
 private void playeffect(BasePlayer player, string[] args)
 {
     if (player == null)
     {
         if (args.Length != 2)
         {
             Puts(GetLang("usageExample", null));
             return;
         }
         string argTarget = args[0];
         string effect    = args[1];
         if (converttoulong(argTarget))
         {
             ulong      effectTarget = Convert.ToUInt64(argTarget);
             BasePlayer finaltarget  = BasePlayer.FindByID(effectTarget);
             if (finaltarget == null)
             {
                 Puts(GetLang("noPlayerFound", null));
                 return;
             }
             var finaleffect = new Effect(effect, finaltarget, 0, Vector3.zero, Vector3.forward);
             if (localEffect)
             {
                 EffectNetwork.Send(finaleffect, finaltarget.net.connection);
             }
             else
             {
                 EffectNetwork.Send(finaleffect);
             }
             Puts("Effect ran on " + finaltarget.displayName);
             return;
         }
     }
     else
     {
         if (args.Length != 2)
         {
             Player.Reply(player, GetLang("usageExample", player.UserIDString));
             return;
         }
         string argTarget = args[0];
         string effect    = args[1];
         if (converttoulong(argTarget))
         {
             ulong      effectTarget = Convert.ToUInt64(argTarget);
             BasePlayer finaltarget  = BasePlayer.FindByID(effectTarget);
             if (finaltarget == null)
             {
                 Player.Reply(player, GetLang("noPlayerFound", player.UserIDString));
                 return;
             }
             var finaleffect = new Effect(effect, finaltarget, 0, Vector3.zero, Vector3.forward);
             if (localEffect)
             {
                 EffectNetwork.Send(finaleffect, finaltarget.net.connection);
             }
             else
             {
                 EffectNetwork.Send(finaleffect);
             }
             Player.Reply(player, "Effect ran on " + finaltarget.displayName);
             return;
         }
     }
 }
Ejemplo n.º 17
0
    private void TakePhoto(RPCMessage msg)
    {
        BasePlayer player = msg.player;
        Item       item   = GetItem();

        if (player == null || item == null || item.condition <= 0f)
        {
            return;
        }
        byte[] array = msg.read.BytesWithSize();
        if (array.Length > 102400 || !ImageProcessing.IsValidJPG(array, resolutionX, resolutionY))
        {
            return;
        }
        Item item2 = ItemManager.Create(photoItem, 1, 0uL);

        if (item2 == null)
        {
            Debug.LogError("Failed to create photo item");
            return;
        }
        if (item2.instanceData.subEntity == 0)
        {
            item2.Remove();
            Debug.LogError("Photo has no sub-entity");
            return;
        }
        BaseNetworkable baseNetworkable = BaseNetworkable.serverEntities.Find(item2.instanceData.subEntity);

        if (baseNetworkable == null)
        {
            item2.Remove();
            Debug.LogError("Sub-entity was not found");
            return;
        }
        PhotoEntity photoEntity;

        if ((object)(photoEntity = baseNetworkable as PhotoEntity) == null)
        {
            item2.Remove();
            Debug.LogError("Sub-entity is not a photo");
            return;
        }
        photoEntity.SetImageData(player.userID, array);
        if (!player.inventory.GiveItem(item2))
        {
            item2.Drop(player.GetDropPosition(), player.GetDropVelocity());
        }
        EffectNetwork.Send(new Effect(screenshotEffect.resourcePath, base.transform.position, base.transform.forward, msg.connection));
        if (!hasSentAchievement && !string.IsNullOrEmpty("SUMMER_PAPARAZZI"))
        {
            Vector3           position = GetOwnerPlayer().eyes.position;
            Vector3           vector   = GetOwnerPlayer().eyes.HeadForward();
            List <BasePlayer> obj      = Facepunch.Pool.GetList <BasePlayer>();
            Vis.Entities(position + vector * 5f, 5f, obj, 131072);
            foreach (BasePlayer item3 in obj)
            {
                if (item3.isServer && item3 != GetOwnerPlayer() && item3.IsVisible(GetOwnerPlayer().eyes.position))
                {
                    hasSentAchievement = true;
                    GetOwnerPlayer().GiveAchievement("SUMMER_PAPARAZZI");
                    break;
                }
            }
            Facepunch.Pool.FreeList(ref obj);
        }
        item.LoseCondition(1f);
    }
Ejemplo n.º 18
0
            void FixedUpdate()
            {
                float time = Time.realtimeSinceStartup;

                if (input.current.buttons != input.previous.buttons && input.current.buttons != 0 && NextTimeToPress < time)
                {
                    float num_shift = input.WasDown(BUTTON.SPRINT) ? 0.2f : 0;
                    bool  Strum     = input.WasDown(BUTTON.DUCK);
                    //fx/gestures/guitarstrum
                    NextTimeToPress = time + noteTime;
                    float num = (float)Math.Log((input.current.buttons / 262144), 2) / adjust + num_shift + start;
                    //owner.ChatMessage(num.ToString("N2"));
                    if (float.IsInfinity(num))
                    {
                        return;
                    }
                    if (num > 7)
                    {
                        num = 7;
                    }
                    else if (num < -2)
                    {
                        num = -2;
                    }
                    if (!Strum)
                    {
                        effectP.worldPos = transform.position;
                        effectP.origin   = transform.position;
                        effectP.scale    = num;
                        EffectNetwork.Send(effectP);
                    }
                    else
                    {
                        effectS.worldPos = transform.position;
                        effectS.origin   = transform.position;
                        effectS.scale    = num;
                        EffectNetwork.Send(effectS);
                    }
                    if (Recording)
                    {
                        if (recTune == null)
                        {
                            recTune = new List <TuneNote>();
                        }
                        if (recTune.Count == 0)
                        {
                            recTune = new List <TuneNote>();
                            TuneNote curNote = new TuneNote(num, 0f, !Strum);
                            recTune.Add(curNote);
                            nextNoteTime = time;
                        }
                        else
                        {
                            recTune[recTune.Count - 1].Delay = time - nextNoteTime;
                            TuneNote curNote = new TuneNote(num, 0f, !Strum);
                            recTune.Add(curNote);
                            nextNoteTime = time;
                        }
                    }
                }
            }
Ejemplo n.º 19
0
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (!this.VerifyClientAttack(basePlayer))
        {
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            return;
        }
        if (basePlayer == null)
        {
            return;
        }
        if (basePlayer.IsHeadUnderwater())
        {
            return;
        }
        if (!this.canThrowAsProjectile)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Not throwable (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "not_throwable");
            return;
        }
        Item item = this.GetItem();

        if (item == null)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item not found (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "item_missing");
            return;
        }
        ItemModProjectile component = item.info.GetComponent <ItemModProjectile>();

        if (component == null)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Item mod not found (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "mod_missing");
            return;
        }
        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read);

        if (projectileShoot.projectiles.Count != 1)
        {
            AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Projectile count mismatch (", base.ShortPrefabName, ")"));
            basePlayer.stats.combat.Log(this, "count_mismatch");
            return;
        }
        basePlayer.CleanupExpiredProjectiles();
        foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
        {
            if (!basePlayer.HasFiredProjectile(projectile.projectileID))
            {
                if (!base.ValidateEyePos(basePlayer, projectile.startPos))
                {
                    continue;
                }
                basePlayer.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, item.info, item);
                Effect effect = new Effect();
                effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection);
                effect.scale        = 1f;
                effect.pooledString = component.projectileObject.resourcePath;
                effect.number       = projectile.seed;
                EffectNetwork.Send(effect);
            }
            else
            {
                AntiHack.Log(basePlayer, AntiHackType.ProjectileHack, string.Concat("Duplicate ID (", projectile.projectileID, ")"));
                basePlayer.stats.combat.Log(this, "duplicate_id");
            }
        }
        item.SetParent(null);
        Interface.CallHook("OnMeleeThrown", basePlayer, item);
        if (this.canAiHearIt)
        {
            float single = 0f;
            if (component.projectileObject != null)
            {
                GameObject gameObject = component.projectileObject.Get();
                if (gameObject != null)
                {
                    Projectile component1 = gameObject.GetComponent <Projectile>();
                    if (component1 != null)
                    {
                        foreach (DamageTypeEntry damageType in component1.damageTypes)
                        {
                            single += damageType.amount;
                        }
                    }
                }
            }
            if (basePlayer != null)
            {
                Sensation sensation = new Sensation()
                {
                    Type            = SensationType.ThrownWeapon,
                    Position        = basePlayer.transform.position,
                    Radius          = 50f,
                    DamagePotential = single,
                    InitiatorPlayer = basePlayer,
                    Initiator       = basePlayer
                };
                Sense.Stimulate(sensation);
            }
        }
    }
        private void UnlockBlueprint(BasePlayer player, string itemShortName)
        {
            if (player == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(itemShortName))
            {
                return;
            }

            var playerUID = player.userID;

            var playersToShareWith = new List <BasePlayer>();

            if (clansEnabled && (Clans != null || ClansReborn != null) && InClan(playerUID))
            {
                playersToShareWith.AddRange(GetClanMembers(playerUID));
            }

            if (friendsEnabled && Friends != null && HasFriends(playerUID))
            {
                playersToShareWith.AddRange(GetFriends(playerUID));
            }

            if (teamsEnabled && InTeam(playerUID))
            {
                playersToShareWith.AddRange(GetTeamMembers(playerUID));
            }

            foreach (BasePlayer sharePlayer in playersToShareWith)
            {
                if (sharePlayer != null)
                {
                    var blueprintComponent = sharePlayer.blueprints;

                    if (blueprintComponent == null)
                    {
                        return;
                    }

                    var itemDefinition = GetItemDefinition(itemShortName);

                    if (itemDefinition == null)
                    {
                        return;
                    }

                    blueprintComponent.Unlock(itemDefinition);

                    var soundEffect = new Effect("assets/prefabs/deployable/research table/effects/research-success.prefab", sharePlayer.transform.position, Vector3.zero);

                    if (soundEffect == null)
                    {
                        return;
                    }

                    EffectNetwork.Send(soundEffect, sharePlayer.net.connection);
                }
            }
        }
Ejemplo n.º 21
0
    private void CLProject(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!VerifyClientAttack(player))
        {
            SendNetworkUpdate();
        }
        else
        {
            if (player == null || player.IsHeadUnderwater())
            {
                return;
            }
            if (!canThrowAsProjectile)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "not_throwable");
                return;
            }
            Item item = GetItem();
            if (item == null)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "item_missing");
                return;
            }
            ItemModProjectile component = item.info.GetComponent <ItemModProjectile>();
            if (component == null)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "mod_missing");
                return;
            }
            ProjectileShoot projectileShoot = ProjectileShoot.Deserialize(msg.read);
            if (projectileShoot.projectiles.Count != 1)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + base.ShortPrefabName + ")");
                player.stats.combat.Log(this, "count_mismatch");
                return;
            }
            player.CleanupExpiredProjectiles();
            foreach (ProjectileShoot.Projectile projectile in projectileShoot.projectiles)
            {
                if (player.HasFiredProjectile(projectile.projectileID))
                {
                    AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + projectile.projectileID + ")");
                    player.stats.combat.Log(this, "duplicate_id");
                }
                else if (ValidateEyePos(player, projectile.startPos))
                {
                    player.NoteFiredProjectile(projectile.projectileID, projectile.startPos, projectile.startVel, this, item.info, item);
                    Effect effect = new Effect();
                    effect.Init(Effect.Type.Projectile, projectile.startPos, projectile.startVel, msg.connection);
                    effect.scale        = 1f;
                    effect.pooledString = component.projectileObject.resourcePath;
                    effect.number       = projectile.seed;
                    EffectNetwork.Send(effect);
                }
            }
            projectileShoot?.Dispose();
            item.SetParent(null);
            Interface.CallHook("OnMeleeThrown", player, item);
            if (!canAiHearIt)
            {
                return;
            }
            float num = 0f;
            if (component.projectileObject != null)
            {
                GameObject gameObject = component.projectileObject.Get();
                if (gameObject != null)
                {
                    Projectile component2 = gameObject.GetComponent <Projectile>();
                    if (component2 != null)
                    {
                        foreach (DamageTypeEntry damageType in component2.damageTypes)
                        {
                            num += damageType.amount;
                        }
                    }
                }
            }
            if (player != null)
            {
                Sensation sensation = default(Sensation);
                sensation.Type            = SensationType.ThrownWeapon;
                sensation.Position        = player.transform.position;
                sensation.Radius          = 50f;
                sensation.DamagePotential = num;
                sensation.InitiatorPlayer = player;
                sensation.Initiator       = player;
                Sense.Stimulate(sensation);
            }
        }
    }
Ejemplo n.º 22
0
        private void SendEffect(BasePlayer player, string sound)
        {
            var effect = new Effect(sound, player, 0, Vector3.zero, Vector3.forward);

            EffectNetwork.Send(effect, player.net.connection);
        }
Ejemplo n.º 23
0
    private void CLProject(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!this.VerifyClientAttack(player))
        {
            this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        }
        else
        {
            if (Object.op_Equality((Object)player, (Object)null) || player.IsHeadUnderwater())
            {
                return;
            }
            if (!this.canThrowAsProjectile)
            {
                AntiHack.Log(player, AntiHackType.ProjectileHack, "Not throwable (" + this.ShortPrefabName + ")");
                player.stats.combat.Log((AttackEntity)this, "not_throwable");
            }
            else
            {
                Item pickupItem = this.GetItem();
                if (pickupItem == null)
                {
                    AntiHack.Log(player, AntiHackType.ProjectileHack, "Item not found (" + this.ShortPrefabName + ")");
                    player.stats.combat.Log((AttackEntity)this, "item_missing");
                }
                else
                {
                    ItemModProjectile component1 = (ItemModProjectile)((Component)pickupItem.info).GetComponent <ItemModProjectile>();
                    if (Object.op_Equality((Object)component1, (Object)null))
                    {
                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Item mod not found (" + this.ShortPrefabName + ")");
                        player.stats.combat.Log((AttackEntity)this, "mod_missing");
                    }
                    else
                    {
                        ProjectileShoot projectileShoot = ProjectileShoot.Deserialize((Stream)msg.read);
                        if (((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).Count != 1)
                        {
                            AntiHack.Log(player, AntiHackType.ProjectileHack, "Projectile count mismatch (" + this.ShortPrefabName + ")");
                            player.stats.combat.Log((AttackEntity)this, "count_mismatch");
                        }
                        else
                        {
                            player.CleanupExpiredProjectiles();
                            using (List <ProjectileShoot.Projectile> .Enumerator enumerator = ((List <ProjectileShoot.Projectile>)projectileShoot.projectiles).GetEnumerator())
                            {
                                while (enumerator.MoveNext())
                                {
                                    ProjectileShoot.Projectile current = enumerator.Current;
                                    if (player.HasFiredProjectile((int)current.projectileID))
                                    {
                                        AntiHack.Log(player, AntiHackType.ProjectileHack, "Duplicate ID (" + (object)(int)current.projectileID + ")");
                                        player.stats.combat.Log((AttackEntity)this, "duplicate_id");
                                    }
                                    else if (this.ValidateEyePos(player, (Vector3)current.startPos))
                                    {
                                        player.NoteFiredProjectile((int)current.projectileID, (Vector3)current.startPos, (Vector3)current.startVel, (AttackEntity)this, pickupItem.info, pickupItem);
                                        Effect effect = new Effect();
                                        effect.Init(Effect.Type.Projectile, (Vector3)current.startPos, (Vector3)current.startVel, msg.connection);
                                        effect.scale        = (__Null)1.0;
                                        effect.pooledString = component1.projectileObject.resourcePath;
                                        effect.number       = current.seed;
                                        EffectNetwork.Send(effect);
                                    }
                                }
                            }
                            pickupItem.SetParent((ItemContainer)null);
                            Interface.CallHook("OnMeleeThrown", (object)player, (object)pickupItem);
                            if (!this.canAiHearIt)
                            {
                                return;
                            }
                            float num = 0.0f;
                            if (component1.projectileObject != null)
                            {
                                GameObject gameObject = component1.projectileObject.Get();
                                if (Object.op_Inequality((Object)gameObject, (Object)null))
                                {
                                    Projectile component2 = (Projectile)gameObject.GetComponent <Projectile>();
                                    if (Object.op_Inequality((Object)component2, (Object)null))
                                    {
                                        foreach (DamageTypeEntry damageType in component2.damageTypes)
                                        {
                                            num += damageType.amount;
                                        }
                                    }
                                }
                            }
                            if (!Object.op_Inequality((Object)player, (Object)null))
                            {
                                return;
                            }
                            Sense.Stimulate(new Sensation()
                            {
                                Type            = SensationType.ThrownWeapon,
                                Position        = ((Component)player).get_transform().get_position(),
                                Radius          = 50f,
                                DamagePotential = num,
                                InitiatorPlayer = player,
                                Initiator       = (BaseEntity)player
                            });
                        }
                    }
                }
            }
        }
    }