Esempio n. 1
0
    public GameObject SpawnBullet(BulletType bulletType, Bolt.NetworkId ownerId, Bolt.NetworkId targetId, bool isServer = false)
    {
        GameObject bullet = null;
        var        owner  = BoltNetwork.FindEntity(ownerId);
        var        target = BoltNetwork.FindEntity(targetId);

        if (owner != null && target != null)
        {
            bullet = Factory.Instance.CreateBullet(bulletType);
            bullet.GetComponent <BulletBehaviour>().Owner  = owner;
            bullet.GetComponent <BulletBehaviour>().Target = target;
            bullet.transform.position = owner.transform.position;

            if (isServer)
            {
                var evnt = FireEvent.Create();
                evnt.BulletId = (int)bulletType;
                evnt.OwnerId  = ownerId;
                evnt.TargetId = targetId;
                evnt.Send();
            }
            _bullets.Add(bullet);
        }

        return(bullet);
    }
Esempio n. 2
0
        public ClientEnemy(ulong id, float damage, float scale, Color color, List <EnemyProgression.Abilities> abilities)
        {
            this.damagemult = damage;
            this.abilities  = abilities;
            this.scale      = scale;
            if (!EnemyManager.clientEnemies.ContainsKey(id))
            {
                EnemyManager.clientEnemies.Add(id, this);
            }
            else
            {
                EnemyManager.clientEnemies.Remove(id);
                EnemyManager.clientEnemies.Add(id, this);
            }
            var entity = BoltNetwork.FindEntity(new Bolt.NetworkId(id));

            if (entity != null)
            {
                entity.transform.localScale = Vector3.one * scale;
                entity.GetComponentInChildren <MeshRenderer>().material.color = color;
                if (abilities.Contains(EnemyProgression.Abilities.Gargantuan))
                {
                    entity.BroadcastMessage("SetTriggerScale", 2.5f, SendMessageOptions.DontRequireReceiver);
                }
                else if (abilities.Contains(EnemyProgression.Abilities.Tiny))
                {
                    entity.BroadcastMessage("SetTriggerScale", 5f, SendMessageOptions.DontRequireReceiver);
                }
                else
                {
                    entity.BroadcastMessage("SetTriggerScale", 1.6f, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
Esempio n. 3
0
 protected override void OnReceived(UpdateCProgressionCommandParam param, BinaryReader r)
 {
     if (GameSetup.IsMpClient)
     {
         var entity = BoltNetwork.FindEntity(new Bolt.NetworkId(param.packed));
         if (EnemyManager.clinetProgressions.ContainsKey(entity))
         {
             ClientEnemyProgression cp = EnemyManager.clinetProgressions[entity];
             cp.UpdateDynamic(param.health, param.armor, param.armor_reduction, param.damage);
         }
     }
     else
     {
         if (EnemyManager.hostDictionary.TryGetValue(param.packed, out var enemy))
         {
             Send(NetworkManager.Target.Clients, new UpdateCProgressionCommandParam()
             {
                 health          = enemy.HP,
                 damage          = enemy.DamageTotal,
                 armor           = enemy.armor,
                 armor_reduction = enemy.armorReduction,
                 packed          = param.packed
             });
         }
     }
 }
Esempio n. 4
0
    public override void StreamDataReceived(BoltConnection connection, UdpStreamData data)
    {
        int        o          = 0;
        BoltEntity boltEntity = BoltNetwork.FindEntity(new NetworkId(Blit.ReadU64(data.Data, ref o)));

        if (boltEntity.IsAttached())
        {
            CoopVoice component = boltEntity.GetComponent <CoopVoice>();
            if (component)
            {
                component.ReceiveVoiceData(data.Data, o);
            }
        }
    }
    public override void Attached()
    {
        if (entity.IsOwner)
        {
            if (transform.rotation == Quaternion.identity)
            {
                _networkRigidbody.MoveVelocity = Random.onUnitSphere * 10f;
                transform.eulerAngles          = Random.insideUnitSphere * 360f;
            }
            else
            {
                _networkRigidbody.MoveVelocity = transform.forward * 10f;
            }
        }

        _dropToken = (WeaponDropToken)entity.AttachToken;
        _launcher  = BoltNetwork.FindEntity(_dropToken.networkId).GetComponent <PlayerMotor>();
        _inited    = true;
    }
 public static T Find <T>(NetworkId id)
 => BoltNetwork.FindEntity(id)
 .GetState <T>();
Esempio n. 7
0
        private object IOnPlayerChat(ChatEvent evt)
        {
            if (evt.Message.Trim().Length <= 1)
            {
                return(true);
            }

            BoltEntity entity = BoltNetwork.FindEntity(evt.Sender);

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

            IPlayer player = entity.IPlayer;

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

            // Set player name if available
            player.Name = entity.GetState <IPlayerState>().name?.Sanitize() ?? (!string.IsNullOrEmpty(player.Name) ? player.Name : "Unnamed"); // TODO: Localization

            // Is it a chat command?
            string str = evt.Message.Substring(0, 1);

            if (!str.Equals("/") && !str.Equals("!"))
            {
                // Call hooks for plugins
                object chatSpecific  = Interface.Call("OnPlayerChat", entity, evt.Message);
                object chatCovalence = Interface.Call("OnUserChat", player, evt.Message);
                object canChat       = chatSpecific is null ? chatCovalence : chatSpecific;
                if (canChat != null)
                {
                    return(true);
                }

                Interface.Oxide.LogInfo($"[Chat] {player.Name}: {evt.Message}");
                return(null);
            }

            // Replace ! with / for Covalence handling
            evt.Message = '/' + evt.Message.Substring(1);

            // Parse the command
            ParseCommand(evt.Message.Substring(1), out string cmd, out string[] args);
            if (cmd == null)
            {
                return(null);
            }

            // Call hooks for plugins
            object commandSpecific  = Interface.Call("OnPlayerCommand", entity, cmd, args);
            object commandCovalence = Interface.Call("OnUserCommand", player, cmd, args);
            object canBlock         = commandSpecific is null ? commandCovalence : commandSpecific;

            if (canBlock != null)
            {
                return(true);
            }

            // Is this a covalence command?
            if (Covalence.CommandSystem.HandleChatMessage(player, evt.Message))
            {
                return(true);
            }

            // TODO: Handle non-universal commands

            player.Reply(string.Format(lang.GetMessage("UnknownCommand", this, player.Id), cmd));
            return(true);
        }
Esempio n. 8
0
 private void OnSelectedGolfBallChanged()
 {
     selectedGolfBall     = BoltNetwork.FindEntity(state.SelectedGolfBall);
     lineRenderer.enabled = selectedGolfBall != null;
 }