Example #1
0
        private void OnConnectedDestroy(DestructionInfo info)
        {
            foreach (var generator in connectedGenerator.ToArray())
            {
                if (generator.Value.Item1 == info.Destroyed.gameObject)
                {
                    for (int i = 1; i <= detectionRange; i++)
                    {
                        var pos = registerTile.WorldPositionServer + GetCoordFromDirection(generator.Key) * i;

                        if (pos == info.Destroyed.gameObject.WorldPosServer())
                        {
                            break;
                        }

                        var matrix = MatrixManager.AtPoint(pos, true);

                        matrix.TileChangeManager.RemoveTile(MatrixManager.WorldToLocalInt(pos, matrix), LayerType.Windows);
                    }

                    connectedGenerator.Remove(generator.Key);
                    info.Destroyed.OnWillDestroyServer.RemoveListener(OnConnectedDestroy);
                    break;
                }
            }
        }
Example #2
0
        public void WhenDestroyed(DestructionInfo info)
        {
            //drop all our contents
            ItemStorage itemStorage = null;

            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            itemStorage = GetComponent <ItemStorage>();

            if (itemStorage != null)
            {
                itemStorage.ServerDropAll();
            }

            SpawnResult frameSpawn = Spawn.ServerPrefab(CommonPrefabs.Instance.MachineFrame, SpawnDestination.At(gameObject));

            if (!frameSpawn.Successful)
            {
                Logger.LogError($"Failed to spawn frame! Is {this} missing references in the inspector?", Category.Construction);
                return;
            }

            GameObject frame = frameSpawn.GameObject;

            frame.GetComponent <MachineFrame>().ServerInitFromComputer(this);

            Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
Example #3
0
    private void OnWillDestroyServer(DestructionInfo arg0)
    {
        Spawn.ServerPrefab("GlassShard", gameObject.TileWorldPosition().To3Int(), transform.parent, count: Random.Range(1, 4),
                           scatterRadius: Random.Range(0, 3), cancelIfImpassable: true);

        SoundManager.PlayNetworkedAtPos("GlassBreak0#", gameObject.TileWorldPosition().To3Int(), 1f, sourceObj: gameObject);
    }
Example #4
0
    private void CheckDestruction()
    {
        if (!destroyed && integrity <= 0)
        {
            var destructInfo = new DestructionInfo(lastDamageType);
            OnWillDestroyServer.Invoke(destructInfo);

            if (onFire)
            {
                //ensure we stop burning
                SyncOnFire(false);
            }

            if (destructInfo.DamageType == DamageType.Burn)
            {
                if (OnBurnUpServer != null)
                {
                    OnBurnUpServer(destructInfo);
                }
                else
                {
                    DefaultBurnUp(destructInfo);
                }
            }
            else
            {
                DefaultDestroy(destructInfo);
            }

            destroyed = true;
        }
    }
        ///<summary> Sets up Outputs, Info and variables for use. </summary>
        void Start()
        {
            output.RemoveAll(eOut => !eOut);

            appearance = (appearance) ? Instantiate(appearance) : ScriptableObject.CreateInstance(typeof(AppearanceInfo)) as AppearanceInfo;
            appearance.Setup(gameObject);
            appearance.SetupRenderer();

            if (destruction)
            {
                destruction = Instantiate(destruction);
                destruction.Setup(gameObject);
            }


            for (int i = 0; i < output.Count; i++)
            {
                output[i].firstSource = this;

                if (output[i].similarity == Similarity.UNIQUE)
                {
                    output[i] = Instantiate(output[i]);
                    output[i].SetID();
                }
            }

            SetHitpointsToMax(hitPoints == 0);      //Set hitpoints to hitpoint limit if they were not given a non-zero value
        }
Example #6
0
    private void OnWillDestroyServer(DestructionInfo arg0)
    {
        Spawn.ServerPrefab(matsOnDestroy, gameObject.TileWorldPosition().To3Int(), transform.parent, count: Random.Range(minCountOfMatsOnDestroy, maxCountOfMatsOnDestroy + 1),
                           scatterRadius: Random.Range(0, 3), cancelIfImpassable: true);

        SoundManager.PlayNetworkedAtPos(soundOnDestroy, gameObject.TileWorldPosition().To3Int(), 1f, sourceObj: gameObject);
    }
Example #7
0
        public void WhenDestroyed(DestructionInfo info)
        {
            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            Inventory.ServerSpawnPrefab(powerControlModule, powerControlSlot, ReplacementStrategy.Cancel);
            Inventory.ServerSpawnPrefab(powerCell, powerCellSlot, ReplacementStrategy.Cancel);

            SpawnResult frameSpawn = Spawn.ServerPrefab(APCFrameObj, SpawnDestination.At(gameObject));

            if (frameSpawn.Successful == false)
            {
                Logger.LogError($"Failed to spawn frame! Is {this} missing references in the inspector?", Category.Construction);
                return;
            }

            GameObject frame = frameSpawn.GameObject;

            frame.GetComponent <APCFrame>().ServerInitFromComputer(this);

            var Directional = frame.GetComponent <Directional>();

            if (Directional != null)
            {
                Directional.FaceDirection(gameObject.GetComponent <Directional>().CurrentDirection);
            }

            _ = Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
Example #8
0
    private void CheckDestruction()
    {
        if (!destroyed && integrity <= 0)
        {
            Profiler.BeginSample("IntegrityOnWillDestroy");
            var destructInfo = new DestructionInfo(lastDamageType, this);
            OnWillDestroyServer.Invoke(destructInfo);
            Profiler.EndSample();

            if (onFire)
            {
                //ensure we stop burning
                SyncOnFire(onFire, false);
            }

            if (destructInfo.DamageType == DamageType.Burn)
            {
                if (OnBurnUpServer != null)
                {
                    OnBurnUpServer(destructInfo);
                }
                else
                {
                    DefaultBurnUp(destructInfo);
                }
            }
            else
            {
                DefaultDestroy(destructInfo);
            }

            destroyed = true;
        }
    }
Example #9
0
        public void WhenDestroyed(DestructionInfo info)
        {
            //drop all our contents
            ItemStorage itemStorage = null;

            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            itemStorage = GetComponent <ItemStorage>();

            if (itemStorage != null)
            {
                itemStorage.ServerDropAll();
            }

            var frame = Spawn.ServerPrefab(framePrefab, SpawnDestination.At(gameObject)).GameObject;

            frame.GetComponent <MachineFrame>().ServerInitFromComputer(this);

            Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
Example #10
0
        public void WhenDestroyed(DestructionInfo info)
        {
            if (circuitBoardSlot.IsOccupied)
            {
                Inventory.ServerDrop(circuitBoardSlot);
            }

            if (CurrentState == glassAddedState)
            {
                //1-2
                Spawn.ServerPrefab(CommonPrefabs.Instance.GlassSheet, SpawnDestination.At(gameObject), UnityEngine.Random.Range(1, 3));
                //1-5
                Spawn.ServerPrefab(CommonPrefabs.Instance.SingleCableCoil, SpawnDestination.At(gameObject), UnityEngine.Random.Range(1, 6));
            }

            if (CurrentState == cablesAddedState)
            {
                //1-5
                Spawn.ServerPrefab(CommonPrefabs.Instance.SingleCableCoil, SpawnDestination.At(gameObject), UnityEngine.Random.Range(1, 6));
            }

            //1-5
            Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, SpawnDestination.At(gameObject), UnityEngine.Random.Range(1, 6));

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }
Example #11
0
 private void DefaultBurnUp(DestructionInfo info)
 {
     //just a guess - objects which can be picked up should have a smaller amount of ash
     EffectsFactory.Instance.Ash(registerTile.WorldPosition.To2Int(), isLarge);
     ChatRelay.Instance.AddToChatLogServer(ChatEvent.Local($"{name} burnt to ash.", gameObject.TileWorldPosition()));
     Logger.LogTraceFormat("{0} burning up, onfire is {1} (burningObject enabled {2})", Category.Health, name, this.onFire, burningObjectOverlayOverlay?.enabled);
     PoolManager.PoolNetworkDestroy(gameObject);
 }
Example #12
0
 public void WhenDestroyed(DestructionInfo info)
 {
     if (CurrentState == powerCellAddedState || CurrentState == powerControlAddedState)
     {
         RemoveCircuitAndParts();
     }
     integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
 }
Example #13
0
 private void DefaultBurnUp(DestructionInfo info)
 {
     //just a guess - objects which can be picked up should have a smaller amount of ash
     EffectsFactory.Ash(registerTile.WorldPosition.To2Int(), isLarge);
     Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " burnt to ash.", gameObject.TileWorldPosition());
     Logger.LogTraceFormat("{0} burning up, onfire is {1} (burningObject enabled {2})", Category.Health, name, this.onFire, burningObjectOverlay?.enabled);
     Despawn.ServerSingle(gameObject);
 }
Example #14
0
 private void OnBurnUpServer(DestructionInfo info)
 {
     //cook the meat by destroying this meat and spawning a meat steak
     PoolManager.PoolNetworkInstantiate(meatSteakPrefab, registerTile.WorldPosition, transform.parent);
     ChatRelay.Instance.AddToChatLogServer(ChatEvent.Local($"The {name} is cooked to perfection.",
                                                           gameObject.TileWorldPosition()));
     PoolManager.PoolNetworkDestroy(gameObject);
 }
Example #15
0
    private void OnWillDestroyServer(DestructionInfo arg0)
    {
        //force it open
        SetIsLocked(false);
        SetIsClosed(false);

        ItemFactory.SpawnMetal(2, gameObject.TileWorldPosition(), parent: transform.parent);
    }
Example #16
0
 private void OnWillDestroyServer(DestructionInfo arg0)
 {
     if (matsDroppedOnDestroy > 0)
     {
         Spawn.ServerPrefab(
             matsOnDestroy, registerObject.WorldPositionServer, transform.parent, count: matsDroppedOnDestroy,
             scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
     }
 }
Example #17
0
 private void DefaultBurnUp(DestructionInfo info)
 {
     Profiler.BeginSample("DefaultBurnUp");
     registerTile.TileChangeManager.MetaTileMap.AddOverlay(registerTile.LocalPosition, isLarge ? LARGE_ASH : SMALL_ASH);
     Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " burnt to ash.", gameObject);
     Logger.LogTraceFormat("{0} burning up, onfire is {1} (burningObject enabled {2})", Category.Health, name, this.onFire, burningObjectOverlay?.enabled);
     _ = Despawn.ServerSingle(gameObject);
     Profiler.EndSample();
 }
Example #18
0
        private void OnDestroySelf(DestructionInfo info)
        {
            if (CustomNetworkManager.IsServer == false)
            {
                return;
            }

            RemoveAllShields();
        }
Example #19
0
        private void WhenDestroyed(DestructionInfo info)
        {
            if (BlewUp)
            {
                return;
            }

            Explode(reagentContainerScript[fuel]);
        }
 private void OnWillDestroyServer(DestructionInfo info)
 {
     //release the player
     if (isOccupied)
     {
         var playerMoveAtPosition = MatrixManager.GetAt <PlayerMove>(transform.position.CutToInt(), true)
                                    ?.First(pm => pm.IsBuckled);
         playerMoveAtPosition.Unbuckle();
     }
 }
Example #21
0
 private void OnWillDestroyServer(DestructionInfo info)
 {
     //release the player
     if (occupant > 0)
     {
         //fixme: InvalidOperationException - Sequence contains no matching element
         var playerMoveAtPosition = MatrixManager.GetAt <PlayerMove>(transform.position.CutToInt(), true)
                                    ?.First(pm => pm.IsBuckled);
         playerMoveAtPosition.Unbuckle();
     }
 }
Example #22
0
    private void OnWillDestroyServer(DestructionInfo arg0)
    {
        //force it open
        SetIsLocked(false);
        SetIsClosed(false);

        if (metalDroppedOnDestroy > 0)
        {
            Spawn.ServerPrefab("Metal", gameObject.TileWorldPosition().To3Int(), transform.parent, count: metalDroppedOnDestroy,
                               scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
        }
    }
Example #23
0
    private void OnWillDestroyServer(DestructionInfo arg0)
    {
        //force it open so it drops its contents
        SyncLocked(isLocked, false);
        SyncStatus(statusSync, ClosetStatus.Open);

        if (metalDroppedOnDestroy > 0)
        {
            Spawn.ServerPrefab("Metal", gameObject.TileWorldPosition().To3Int(), transform.parent, count: metalDroppedOnDestroy,
                               scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
        }
    }
        private void OnWillDestroyServer(DestructionInfo arg0)
        {
            Spawn.ServerPrefab(shardsOnDestroy, gameObject.TileWorldPosition().To3Int(), transform.parent, count: Random.Range(minCountOfShardsOnDestroy, maxCountOfShardsOnDestroy + 1),
                               scatterRadius: Random.Range(0, 3), cancelIfImpassable: true);

            Spawn.ServerPrefab(rodsOnDestroy, gameObject.TileWorldPosition().To3Int(), transform.parent, count: Random.Range(minCountOfRodsOnDestroy, maxCountOfRodsOnDestroy + 1),
                               scatterRadius: Random.Range(0, 3), cancelIfImpassable: true);

            AudioSourceParameters audioSourceParameters = new AudioSourceParameters(pitch: 1f);

            SoundManager.PlayNetworkedAtPos(soundOnDestroy, gameObject.TileWorldPosition().To3Int(), audioSourceParameters, sourceObj: gameObject);
        }
Example #25
0
 private void DefaultDestroy(DestructionInfo info)
 {
     if (info.DamageType == DamageType.Brute)
     {
         Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " got smashed to pieces.", gameObject);
         _ = Despawn.ServerSingle(gameObject);
     }
     //TODO: Other damage types (acid)
     else
     {
         Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " got destroyed.", gameObject);
         _ = Despawn.ServerSingle(gameObject);
     }
 }
Example #26
0
 private void DefaultDestroy(DestructionInfo info)
 {
     if (info.DamageType == DamageType.Brute)
     {
         Chat.AddLocalMsgToChat($"{name} was smashed to pieces.", gameObject.TileWorldPosition());
         PoolManager.PoolNetworkDestroy(gameObject);
     }
     //TODO: Other damage types (acid)
     else
     {
         Chat.AddLocalMsgToChat($"{name} was destroyed.", gameObject.TileWorldPosition());
         PoolManager.PoolNetworkDestroy(gameObject);
     }
 }
Example #27
0
 private void DefaultDestroy(DestructionInfo info)
 {
     if (info.DamageType == DamageType.Brute)
     {
         ChatRelay.Instance.AddToChatLogServer(ChatEvent.Local($"{name} was smashed to pieces.", gameObject.TileWorldPosition()));
         PoolManager.PoolNetworkDestroy(gameObject);
     }
     //TODO: Other damage types (acid)
     else
     {
         ChatRelay.Instance.AddToChatLogServer(ChatEvent.Local($"{name} was destroyed.", gameObject.TileWorldPosition()));
         PoolManager.PoolNetworkDestroy(gameObject);
     }
 }
Example #28
0
        private void OnWillDestroyServer(DestructionInfo arg0)
        {
            // failsafe: drop all contents immediately
            ServerHandleContentsOnStatusChange(false);

            //force it open so it drops its contents
            SyncLocked(isLocked, false);
            SyncStatus(statusSync, ClosetStatus.Open);

            if (matsDroppedOnDestroy > 0)
            {
                Spawn.ServerPrefab(matsOnDestroy, gameObject.TileWorldPosition().To3Int(), transform.parent, count: matsDroppedOnDestroy,
                                   scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);
            }
        }
        private void OnWillDestroyServer(DestructionInfo info)
        {
            //release the player
            if (HasOccupant)
            {
                var playerMoveAtPosition =
                    MatrixManager.GetAt <PlayerMove>(transform.position.CutToInt(), true)
                    .FirstOrDefault(pm => pm.IsBuckled);

                if (playerMoveAtPosition != null)
                {
                    playerMoveAtPosition.Unbuckle();
                }
            }
        }
Example #30
0
        public void WhenDestroyed(DestructionInfo info)
        {
            // rare cases were gameObject is destroyed for some reason and then the method is called
            if (gameObject == null)
            {
                return;
            }

            AccessRestrictions airlockAccess = GetComponentInChildren <AccessRestrictions>();

            var doorAssembly = Spawn.ServerPrefab(airlockAssemblyPrefab, SpawnDestination.At(gameObject)).GameObject;

            doorAssembly.GetComponent <AirlockAssembly>().ServerInitFromComputer(AirlockElectronicsPrefab, airlockAccess.restriction, doorMasterController.isWindowedDoor);
            _ = Despawn.ServerSingle(gameObject);

            integrity.OnWillDestroyServer.RemoveListener(WhenDestroyed);
        }