Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"php": "^8.4",
"symfony/console": "^7.0",
"symfony/console": "^7.0 || ^8.0",
"amasiye/figlet": "^1.2",
"vlucas/phpdotenv": "^5.6",
"atatusoft-ltd/termutil": "^1.1"
Expand Down
34 changes: 34 additions & 0 deletions src/Commands/GenerateMaterial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Sendama\Console\Commands;

use Sendama\Console\Strategies\AssetFileGeneration\MaterialFileGenerationStrategy;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'generate:material',
description: 'Generate a new physics material',
)]
class GenerateMaterial extends Command
Comment on lines +12 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Register material generator in CLI bootstrap

Expose this command through the main CLI application; GenerateMaterial is added here, but bin/sendama still only registers the older command set in Application::addCommands(...), so sendama generate:material will not be discoverable and users will get an unknown-command error despite the new command class existing.

Useful? React with 👍 / 👎.

{
public function configure(): void
{
$this->addArgument('name', InputArgument::REQUIRED, 'The name of the material');
}

public function execute(InputInterface $input, OutputInterface $output): int
{
$strategy = new MaterialFileGenerationStrategy(
$input,
$output,
$input->getArgument('name') ?? 'material',
'materials',
);

return $strategy->generate();
}
}
20 changes: 20 additions & 0 deletions src/Commands/NewGame.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$this->createAssetsScenesDirectory($assetsDirectory);
$this->createAssetsScriptsDirectory($assetsDirectory);
$this->createAssetsMapsDirectory($assetsDirectory);
$this->createAssetsMaterialsDirectory($assetsDirectory);
$this->createAssetsPrefabsDirectory($assetsDirectory);
$this->createAssetsTexturesDirectory($assetsDirectory);

Expand Down Expand Up @@ -238,6 +239,25 @@ private function createAssetsMapsDirectory(string $assetsDirectory): void
}
}

/**
* Create the assets' materials directory.
*
* @param string $assetsDirectory The assets' directory.
*/
private function createAssetsMaterialsDirectory(string $assetsDirectory): void
{
$materialsDirectory = Path::join($assetsDirectory, 'Materials');

if (file_exists($materialsDirectory)) {
$this->output->writeln('<comment>Materials directory already exists...</comment>', OutputInterface::VERBOSITY_VERBOSE);
return;
}

if (!mkdir($materialsDirectory) && !is_dir($materialsDirectory)) {
throw new RuntimeException(sprintf('Directory "%s" was not created', $materialsDirectory));
}
}

/**
* Create the assets' prefabs directory.
*
Expand Down
Loading
Loading