示例#1
0
 private void Disassemble()
 {
     Spawn.ServerPrefab(transformToPrefab, registerObject.WorldPositionServer, count: spawnAmount);
     ToolUtils.ServerPlayToolSound(interaction);
     Despawn.ServerSingle(gameObject);
 }
示例#2
0
        private void AddOverlay(PositionalHandApply interaction, Vector3Int cellPos, bool isWall = false)
        {
            //Work out colour
            var chosenColour    = GetColour();
            var chosenDirection = GetDirection();

            var tileToUse = GetTileFromIndex(isWall);

            if (tileToUse == null)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer,
                                             $"You need to chose a type of graffiti to {(isCan ? "spray" : "draw")} first");
                return;
            }

            var graffitiAlreadyOnTile = registerItem.TileChangeManager.MetaTileMap.GetOverlayTilesByType(cellPos,
                                                                                                         isWall ? LayerType.Walls : LayerType.Floors, OverlayType.Cleanable)
                                        .Where(t => t.IsGraffiti).ToList();

            foreach (var graffiti in graffitiAlreadyOnTile)
            {
                //replace if type already on tile
                if (graffiti == tileToUse)
                {
                    //Add change overlay
                    ToolUtils.ServerUseToolWithActionMessages(interaction, timeToDraw,
                                                              $"You begin to {(isCan ? "spray" : "draw")} graffiti on to the {(isWall ? "wall" : "floor")}...",
                                                              $"{interaction.Performer.ExpensiveName()} starts to {(isCan ? "spray" : "draw")} graffiti on the {(isWall ? "wall" : "floor")}...",
                                                              $"You {(isCan ? "spray" : "draw")} graffiti on to the {(isWall ? "wall" : "floor")}",
                                                              $"{interaction.Performer.ExpensiveName()} {(isCan ? "sprays" : "draws")} graffiti on to the {(isWall ? "wall" : "floor")}",
                                                              () =>
                    {
                        if (charges > 0 || charges == -1)
                        {
                            registerItem.TileChangeManager.MetaTileMap.RemoveOverlaysOfType(cellPos,
                                                                                            isWall ? LayerType.Walls : LayerType.Floors, OverlayType.Cleanable);
                            registerItem.TileChangeManager.MetaTileMap.AddOverlay(cellPos, tileToUse, chosenDirection,
                                                                                  chosenColour);
                        }

                        UseAndCheckCharges(interaction);
                    }
                                                              );

                    UseAndCheckCharges(interaction);

                    //Should only ever be one of the overlay
                    return;
                }
            }

            //Only allow 5 graffiti overlays on a tile
            if (graffitiAlreadyOnTile.Count > 5)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer,
                                             "Adding any more graffiti would make the art messy");
                return;
            }

            //Add overlay
            ToolUtils.ServerUseToolWithActionMessages(interaction, timeToDraw,
                                                      $"You begin to {(isCan ? "spray" : "draw")} on the {(isWall ? "wall" : "floor")}...",
                                                      $"{interaction.Performer.ExpensiveName()} starts to {(isCan ? "spray" : "draw")} on the {(isWall ? "wall" : "floor")}...",
                                                      $"You {(isCan ? "spray" : "draw")} on the {(isWall ? "wall" : "floor")}",
                                                      $"{interaction.Performer.ExpensiveName()} {(isCan ? "sprays" : "draws")} on the {(isWall ? "wall" : "floor")}",
                                                      () =>
            {
                if (charges > 0 || charges == -1)
                {
                    registerItem.TileChangeManager.MetaTileMap.AddOverlay(cellPos, tileToUse, chosenDirection, chosenColour);
                }

                UseAndCheckCharges(interaction);
            }
                                                      );
        }