Exemplo n.º 1
0
    public override void OnEvent(DeclineBlockFreeze evnt)
    {
        if (entity.IsOwner)
        {
            if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Shoot)
            {
                BoltNetwork.Destroy(gameObject);
                return;
            }

            gameObject.transform.position = evnt.OldBlockPosition;
            gameObject.transform.rotation = evnt.OldBlockRotation;

            GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;

            if (gameObject.GetComponent <ConstantForce>() == null)
            {
                gameObject.AddComponent <ConstantForce>();
            }

            gameObject.layer = 8;

            if (gameObject.GetComponent <ConnectionScanning>() == null)
            {
                var scan = gameObject.AddComponent <ConnectionScanning>();
                scan.WaitSeconds = 1;
            }

            if (gameObject.GetComponent <PartBehaviour>() == null)
            {
                gameObject.AddComponent <PartBehaviour>();
            }
        }
    }
Exemplo n.º 2
0
    public override void OnEvent(BlockDestroy evnt)
    {
        if (entity.IsOwner)
        {
            GlobalReferences.AffectedParts.Remove(gameObject);
            GlobalReferences.FreeParts.Remove(gameObject);

            Part p = GetComponent <Part>();
            if (PlacementReferences.InfiniteParts && p.Respawn)
            {
                GameObject go = GlobalReferences.PartSpawner.SpawnPart(p.TemplateID);
                go.GetComponent <Part>().Respawn = true;

                if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
                {
                    GlobalReferences.AffectPart(go);
                    GlobalReferences.FreeParts.Remove(go);
                }
            }
            if (PlacementReferences.PlacementType == PlacementReferences.PlaceChoreo.Choreo)
            {
                GlobalReferences.ChangeAffectedNumber(PlacementReferences.AffectedParts);
            }

            BoltNetwork.Destroy(gameObject);
        }
    }
Exemplo n.º 3
0
 public void DestroyPlayer()
 {
     if (character)
     {
         BoltNetwork.Destroy(character);
     }
 }
 private void EndGuardLifetime()
 {
     if (entity.IsOwner)
     {
         BoltNetwork.Destroy(entity);
     }
 }
Exemplo n.º 5
0
 public override void OnEvent(RequestDestroy evnt)
 {
     if (!this.ValidateSender(evnt, SenderTypes.Any))
     {
         return;
     }
     if (evnt.Entity && evnt.Entity.isAttached && evnt.Entity.isOwner && (evnt.Entity.StateIs <ICookingState>() || evnt.Entity.GetComponentInChildren <ShelterTrigger>()))
     {
         for (int i = 0; i < TheForest.Utils.Scene.SceneTracker.allPlayerEntities.Count; i++)
         {
             if (TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].source == evnt.RaisedBy)
             {
                 if (Vector3.Distance(TheForest.Utils.Scene.SceneTracker.allPlayerEntities[i].transform.position, evnt.Entity.transform.position) < 20f)
                 {
                     evnt.Entity.transform.parent = null;
                     BoltNetwork.Destroy(evnt.Entity);
                 }
                 break;
             }
         }
         if (BoltNetwork.isServer && evnt.RaisedBy == null && Vector3.Distance(LocalPlayer.Transform.position, evnt.Entity.transform.position) < 9f)
         {
             evnt.Entity.transform.parent = null;
             BoltNetwork.Destroy(evnt.Entity);
         }
     }
 }
Exemplo n.º 6
0
        // PUBLIC

        public void DestroyEntity()
        {
            if (entity.isOwner)
            {
                BoltNetwork.Destroy(_targetEntity);
            }
        }
Exemplo n.º 7
0
    void Die()
    {
        BoltNetwork.Destroy(gameObject);

        var spawnPosition = new Vector3(Random.Range(-5f, 5f), Random.Range(15f, 30f), 0f);
        var player        = BoltNetwork.Instantiate(BoltPrefabs.Vampire, spawnPosition, Quaternion.identity);
    }
Exemplo n.º 8
0
    private void Explode()
    {
        Collider[] hits = Physics.OverlapSphere(transform.position, Range);


        foreach (Collider hit in hits)
        {
            if (hit.GetComponent <Rigidbody>() != null)
            {
                hit.GetComponent <Rigidbody>().AddExplosionForce(ExplosionForce, transform.position, Range, 0f);
            }
            if (hit.transform.tag == "Player")
            {
                RaycastHit Hit;
                Physics.Linecast(transform.position, hit.transform.position, out Hit, Mask);
                Debug.Log(Hit.transform.tag);
                if (Hit.transform.tag == "Player")
                {
                    Debug.Log(Vector3.Distance(transform.position, hit.transform.position));
                    float Distance = Vector3.Distance(transform.position, hit.transform.position);


                    var Event = DamageEvent.Create(hit.GetComponent <BoltEntity>());
                    Event.Damage = BaseDamage / Mathf.RoundToInt(Distance);
                    Event.Player = Throwed;
                    Event.Send();
                    break;
                }
            }
        }

        BoltNetwork.Destroy(gameObject);
    }
Exemplo n.º 9
0
 private void DisolveBurnt()
 {
     if (!BoltNetwork.isRunning || (base.entity.isAttached && base.entity.isOwner))
     {
         if (this.DissolvedPrefab)
         {
             GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.DissolvedPrefab, base.transform.position, base.transform.rotation);
             if (this._scaleDisolve)
             {
                 gameObject.transform.localScale.Scale(this._targetRenderer.transform.localScale);
             }
             if (BoltNetwork.isRunning && gameObject.GetComponent <BoltEntity>())
             {
                 BoltNetwork.Attach(gameObject);
             }
         }
         if (BoltNetwork.isRunning)
         {
             BoltNetwork.Destroy(base.gameObject);
         }
         else
         {
             UnityEngine.Object.Destroy(base.gameObject);
         }
     }
 }
Exemplo n.º 10
0
    public GameObject SpawnTower(TowerType towerType, PlayerObject player, Vector3 position)
    {
        TowerData data = DataManager.Instance.GetTowerData(towerType);

        Vector2Int coord = GridManager.Instance.GetCoordFromPosition(position);

        if (GridManager.Instance.IsEmpty(coord.x, coord.y) && player.behavior.state.Gold >= data.cost)
        {
            var tower = BoltNetwork.Instantiate(BoltPrefabs.BaseTower);
            tower.transform.position = position;

            if (GridManager.Instance.CanPlaceObject(tower))
            {
                GridManager.Instance.SetEmpty(coord.x, coord.y, false);
                player.behavior.state.Gold -= data.cost;
                SetControl(player, tower);
                _towers.Add(tower);
                tower.GetComponent <TowerBehaviour>().Init_Server(data);
                return(tower);
            }
            else
            {
                BoltNetwork.Destroy(tower);
            }
        }
        return(null);
    }
Exemplo n.º 11
0
 public override void OnEvent(DestroyBuilding evnt)
 {
     if (evnt.BuildingEntity)
     {
         BoltNetwork.Destroy(evnt.BuildingEntity);
     }
 }
Exemplo n.º 12
0
 public override void OnEvent(DestroyWithTag evnt)
 {
     if (evnt.Entity)
     {
         DestroyOnContactWithTag componentInChildren = evnt.Entity.GetComponentInChildren <DestroyOnContactWithTag>();
         if (componentInChildren)
         {
             if (componentInChildren._destroyTarget)
             {
                 foreach (Transform transform in componentInChildren._destroyTarget.transform)
                 {
                     if (transform.GetComponent <BoltEntity>())
                     {
                         transform.parent = null;
                         BoltNetwork.Destroy(transform.gameObject);
                     }
                 }
             }
             componentInChildren.Perform(true);
             BoltNetwork.Destroy(evnt.Entity, new CoopDestroyTagToken());
         }
         else
         {
             BoltNetwork.Destroy(evnt.Entity);
         }
     }
 }
Exemplo n.º 13
0
 public override void OnEvent(DestroyPickupEvent evnt)
 {
     if (BoltNetwork.IsServer)
     {
         BoltNetwork.Destroy(evnt.Entity.gameObject);
     }
 }
Exemplo n.º 14
0
    public void Kill()
    {
        if (BoltNetwork.IsRunning)
        {
            BoltEntity entity = GetComponent <NetworkBlockBehaviour>().entity;

            if (entity != null && entity.IsOwner)
            {
                BoltNetwork.Destroy(entity);
            }

            return;
        }
        else
        {
            try
            {
                GlobalReferences.Parts.Remove(gameObject);
                GlobalReferences.FreeParts.Remove(gameObject);
            }
            catch
            {
                throw new System.Exception("Part not Containes in global Collections");
            }

            Destroy(gameObject);
        }
    }
Exemplo n.º 15
0
        public void DetachMoveState(bool destroyObject)
        {
            if (clientMoveEntity == null)
            {
                return;
            }

            if (Unit.IsOwner)
            {
                clientMoveState.RemoveCallback(nameof(IUnitState.MovementFlags), OnLocalMoveStateFlagsChanged);
            }

            if (destroyObject)
            {
                if (!clientMoveEntity.IsOwner || !clientMoveEntity.IsAttached)
                {
                    Object.Destroy(clientMoveEntity.gameObject);
                }
                else
                {
                    BoltNetwork.Destroy(clientMoveEntity.gameObject);
                }
            }

            clientMoveEntity = null;
            clientMoveState  = null;
        }
Exemplo n.º 16
0
 private void OnTriggerEnter(Collider other)
 {
     if (_inited && entity.IsAttached && entity.IsOwner)
     {
         if (other.GetComponent <PlayerMotor>())
         {
             if (other.GetComponent <PlayerWeapons>().CanAddWeapon(_dropToken.ID))
             {
                 if (other.GetComponent <PlayerMotor>() == _launcher && _time < Time.time)
                 {
                     other.GetComponent <PlayerWeapons>().AddWeaponEvent((int)_dropToken.ID, _dropToken.currentAmmo, _dropToken.totalAmmo);
                     BoltNetwork.Destroy(entity);
                     _networkRigidbody.enabled = false;
                     _boxCollider.enabled      = false;
                     _render.SetActive(false);
                     _sphereCollider.enabled = false;
                 }
                 else if (other.GetComponent <PlayerMotor>() != _launcher)
                 {
                     other.GetComponent <PlayerWeapons>().AddWeaponEvent((int)_dropToken.ID, _dropToken.currentAmmo, _dropToken.totalAmmo);
                     BoltNetwork.Destroy(entity);
                     _networkRigidbody.enabled = false;
                     _boxCollider.enabled      = false;
                     _render.SetActive(false);
                     _sphereCollider.enabled = false;
                 }
             }
         }
     }
 }
Exemplo n.º 17
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            IDestroyable target;

            switch (other.tag)
            {
            case "Player":
                var player = other.gameObject.GetComponent <Player>();
                if (player == null || player.playerId == shooter)
                {
                    return;
                }
                target = player;
                break;

            case "Terrain":
                target = other.gameObject.GetComponent <IDestroyable>();
                break;

            default:
                return;
            }

            if (target == null)
            {
                BoltLog.Warn("return with hitting an null object");
                return;
            }
            target.OnHurt(dmg);
            BoltNetwork.Destroy(gameObject);
        }
Exemplo n.º 18
0
        public void Dispose()
        {
            players.Remove(this);

            // destroy
            if (entity)
            {
                BoltNetwork.Destroy(entity.gameObject);
            }

            // while we have a team difference of more then 1 player
            while (Mathf.Abs(redPlayers.Count() - bluePlayers.Count()) > 1)
            {
                if (redPlayers.Count() < bluePlayers.Count())
                {
                    var player = bluePlayers.First();
                    player.Kill();
                    player.state.team = TEAM_RED;
                }
                else
                {
                    var player = redPlayers.First();
                    player.Kill();
                    player.state.team = TEAM_BLUE;
                }
            }
        }
Exemplo n.º 19
0
    public void Detonate()
    {
        Collider[] targets = Physics.OverlapSphere(this.transform.position, explosionRadius);
        int        i       = 0;

        while (i < targets.Length)
        {
            //If something in the radius is a player, deal damage to them.
            GameObject target    = targets[i].gameObject;
            IPlayer    hitplayer = target.GetComponent <AbstractPlayer>();
            if (hitplayer != null)
            {
                hitplayer.TakeDamage(damage, Thrower, (target.transform.position - this.transform.position), 0);
            }
            i++;
        }
        //--------Put in something here to create an explosion particle effect------------
        //OK, I will, here goes:
        ExplosionEvent evnt = ExplosionEvent.Create(Bolt.GlobalTargets.Everyone, Bolt.ReliabilityModes.Unreliable);

        evnt.Position = transform.position;
        evnt.Send();
        //done

        //Once the whole array has been checked through, delete the grenade.
        BoltNetwork.Destroy(this.gameObject);
    }
Exemplo n.º 20
0
    private void destroyMe()
    {
        bool       flag      = false;
        BoltEntity component = this.parent.GetComponent <BoltEntity>();

        if (component)
        {
            if (!component.isAttached)
            {
                flag = true;
            }
            else if (component.isOwner)
            {
                flag = true;
            }
        }
        if (!BoltNetwork.isRunning || flag)
        {
            if (this.parent)
            {
                UnityEngine.Object.Destroy(this.parent);
            }
        }
        else if (BoltNetwork.isServer)
        {
            BoltNetwork.Destroy(this.parent.gameObject);
        }
    }
Exemplo n.º 21
0
    public override void OnEvent(NewGameEvent evnt)
    {
        List <GameObject> tempGos = new List <GameObject>();

        tempGos.AddRange(GlobalReferences.FreeParts);
        tempGos.AddRange(GlobalReferences.AffectedParts);

        for (int i = tempGos.Count - 1; i >= 0; --i)
        {
            var entity = tempGos[i].GetComponent <NetworkBlockBehaviour>().entity;

            if (entity.IsAttached && entity.IsOwner)
            {
                BoltNetwork.Destroy(tempGos[i]);
            }
        }

        foreach (GameObject go in GlobalReferences.FrozenParts.Values)
        {
            Destroy(go);
        }



        GlobalReferences.FreeParts.Clear();
        GlobalReferences.FrozenParts.Clear();
        GlobalReferences.AffectedParts.Clear();
        GlobalReferences.NumOfParts = 0;
        GlobalReferences.Parts.Clear();
        GlobalReferences.PartIDLedger.Clear();

        GlobalReferences.PartSpawner.SpawnMultiple(PartsHolder.NumParts);
    }
            internal void DetachMoveState(bool destroyEntity)
            {
                if (moveEntity == null)
                {
                    return;
                }

                if (unit.IsOwner)
                {
                    moveState.RemoveCallback(nameof(IUnitState.MovementFlags), OnMoveStateFlagsChanged);
                }

                if (destroyEntity)
                {
                    if (!moveEntity.IsOwner || !moveEntity.IsAttached)
                    {
                        Destroy(moveEntity.gameObject);
                    }
                    else
                    {
                        BoltNetwork.Destroy(moveEntity.gameObject);
                    }
                }

                moveEntity = null;
                moveState  = null;
            }
Exemplo n.º 23
0
 public void RemovePlayer()
 {
     if (entity && entity.IsAttached)
     {
         BoltNetwork.Destroy(gameObject);
     }
 }
Exemplo n.º 24
0
 public override void OnEvent(SetCorpsePosition evnt)
 {
     if (!this.ValidateSender(evnt, SenderTypes.Any))
     {
         return;
     }
     if (evnt.Corpse)
     {
         if (evnt.Corpse.transform.parent != null)
         {
             evnt.Corpse.gameObject.SendMessageUpwards("releaseNooseTrapMP", SendMessageOptions.DontRequireReceiver);
         }
         evnt.Corpse.transform.parent = null;
         evnt.Corpse.Freeze(false);
         if (evnt.Pickup)
         {
             evnt.Corpse.SendMessage("sendResetRagDoll", SendMessageOptions.DontRequireReceiver);
             evnt.Corpse.transform.position = new Vector3(4096f, 4096f, 4096f);
         }
         else if (evnt.Destroy)
         {
             BoltNetwork.Destroy(evnt.Corpse);
         }
         else
         {
             evnt.Corpse.SendMessage("dropFromCarry", false, SendMessageOptions.DontRequireReceiver);
             evnt.Corpse.SendMessage("setRagDollDrop", SendMessageOptions.DontRequireReceiver);
             evnt.Corpse.transform.position = evnt.Position;
             evnt.Corpse.transform.rotation = ((!(evnt.Rotation == default(Quaternion))) ? evnt.Rotation : Quaternion.identity);
             MultiHolder.GetTriggerChild(evnt.Corpse.transform).gameObject.SetActive(true);
         }
     }
 }
Exemplo n.º 25
0
 public IEnumerator disableSled(bool checkCoolDown = false)
 {
     if (checkCoolDown)
     {
         while (this.coolDown)
         {
             yield return(null);
         }
     }
     if (BoltNetwork.isRunning)
     {
         BoltEntity componentInParent = base.GetComponentInParent <BoltEntity>();
         if (componentInParent)
         {
             BoltNetwork.Destroy(componentInParent);
         }
     }
     Grabber.SetFilter(null);
     LocalPlayer.SpecialActions.SendMessage("exitPushSled");
     this.logTrigger.SetActive(true);
     if (!this.flagTrigger.activeSelf)
     {
         this.flagTrigger.SetActive(true);
     }
     if (this.hideScript.enabled)
     {
         this.hideScript.enabled = false;
     }
     this.Sheen.SetActive(false);
     this.MyPickUp.SetActive(false);
     this.onSled   = false;
     this.coolDown = true;
     base.Invoke("resetCoolDown", 1.2f);
     yield break;
 }
Exemplo n.º 26
0
    public static void DestroyClientPlayer(BoltConnection connection)
    {
        PlayerObject player = (PlayerObject)connection.UserData;

        players.Remove(player);
        BoltNetwork.Destroy(player.character.gameObject);
    }
Exemplo n.º 27
0
 private void OnTriggerEnter(Collider other)
 {
     if (BoltNetwork.isRunning && base.entity && (!base.entity.isAttached || !base.entity.isOwner))
     {
         return;
     }
     if (other.CompareTag("Water"))
     {
         this.Wet = true;
     }
     else if (other.CompareTag("enemyCollide"))
     {
         this.doBreak(true);
         if (this.canDouse && !this.alreadyDoused)
         {
             other.gameObject.SendMessageUpwards("douseEnemy", SendMessageOptions.DontRequireReceiver);
             other.transform.SendMessageUpwards("getAttackDirection", 3, SendMessageOptions.DontRequireReceiver);
             other.gameObject.SendMessage("getAttackerType", 4, SendMessageOptions.DontRequireReceiver);
             other.transform.SendMessageUpwards("Hit", 1, SendMessageOptions.DontRequireReceiver);
             this.alreadyDoused = true;
         }
         base.Invoke("CleanUp", 5f);
     }
     else if (other.CompareTag("FireTrigger"))
     {
         this.Wet = true;
         this.doBreak(false);
         if (BoltNetwork.isRunning)
         {
             FireAddFuelEvent fireAddFuelEvent = FireAddFuelEvent.Raise(GlobalTargets.OnlyServer);
             fireAddFuelEvent.Target       = other.GetComponentInParent <BoltEntity>();
             fireAddFuelEvent.CanSetAlight = this.isLit;
             fireAddFuelEvent.Send();
         }
         else
         {
             if (this.isLit)
             {
                 other.SendMessage("Burn");
             }
             other.SendMessage("Action_AddFuel");
         }
     }
     else if (this.DousedMolotovPrefab && other.CompareTag("BrokenMolotovUnlit"))
     {
         this.doBreak(false);
         if (!BoltNetwork.isRunning)
         {
             UnityEngine.Object.Instantiate <GameObject>(this.DousedMolotovPrefab, other.transform.position, other.transform.rotation);
             UnityEngine.Object.Destroy(other.gameObject);
         }
         else
         {
             BoltNetwork.Instantiate(this.DousedMolotovPrefab, other.transform.position, other.transform.rotation);
             BoltNetwork.Destroy(other.gameObject);
         }
         this.DousedMolotovPrefab = null;
     }
 }
Exemplo n.º 28
0
 private void health_callback()
 {
     local_health = state.health;
     if (state.health <= 0)
     {
         BoltNetwork.Destroy(gameObject);
     }
 }
Exemplo n.º 29
0
 public override void OnEvent(DestroyEntity evnt)
 {
     if (evnt.Entity != null &&
         evnt.Entity.IsOwner)
     {
         BoltNetwork.Destroy(evnt.Entity);
     }
 }
Exemplo n.º 30
0
 private void healthCallback()
 {
     localHealth = state.health;
     if (localHealth <= 0)
     {
         BoltNetwork.Destroy(this.gameObject);
     }
 }