Example #1
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 #2
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 #3
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 #4
0
        private void ExplodeContainer()
        {
            var shakeIntensity = (byte)Mathf.Lerp(
                byte.MinValue, byte.MaxValue / 2, GasMix.Pressure / MAX_EXPLOSION_EFFECT_PRESSURE);
            var shakeDistance = Mathf.Lerp(1, 64, GasMix.Pressure / MAX_EXPLOSION_EFFECT_PRESSURE);

            //release all of our gases at once when destroyed
            ReleaseContentsInstantly();

            ExplosionUtils.PlaySoundAndShake(WorldPosition, shakeIntensity, (int)shakeDistance);
            Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " exploded!", gameObject);

            ServerContainerExplode?.Invoke();
            // Disable this script, gameObject has no valid container now.
            enabled = false;
        }
        private void OnWillDestroyServer(DestructionInfo info)
        {
            var tileWorldPosition = gameObject.TileWorldPosition().To3Int();
            //release all of our gases at once when destroyed
            MetaDataLayer metaDataLayer  = MatrixManager.AtPoint(tileWorldPosition, true).MetaDataLayer;
            Vector3Int    position       = transform.localPosition.RoundToInt();
            MetaDataNode  node           = metaDataLayer.Get(position, false);
            var           shakeIntensity = (byte)Mathf.Lerp(byte.MinValue, byte.MaxValue / 2, GasMix.Pressure / MAX_EXPLOSION_EFFECT_PRESSURE);
            var           shakeDistance  = Mathf.Lerp(1, 64, GasMix.Pressure / MAX_EXPLOSION_EFFECT_PRESSURE);

            node.GasMix += GasMix;
            metaDataLayer.UpdateSystemsAt(position);
            Chat.AddLocalDestroyMsgToChat(gameObject.ExpensiveName(), " exploded!", gameObject.TileWorldPosition());

            Spawn.ServerPrefab("Metal", gameObject.TileWorldPosition().To3Int(), transform.parent, count: 2,
                               scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true);

            ExplosionUtils.PlaySoundAndShake(tileWorldPosition, shakeIntensity, (int)shakeDistance);
        }