Skip to content

Instantly share code, notes, and snippets.

View MadStool's full-sized avatar
🐕
woof-woof!!

MadStool

🐕
woof-woof!!
View GitHub Profile
@MadStool
MadStool / gist:35fc5485798bd775287afaaaff17daf8
Last active August 12, 2025 07:24
Боты сборщики
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(BaseScanner))]
public class BotsBase : MonoBehaviour
{
[Header("Base Settings")]
[SerializeField] private Transform _resourcesParent;
[SerializeField] private float _timeBetweenBaseTicks = 0.5f;
@MadStool
MadStool / gist:2256d2c5c6f4201fb2f7c5ac556aa639
Created August 10, 2025 08:27
Мастер джоинтов
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Catapult : MonoBehaviour
{
private const float MinVelocity = 0.1f;
[SerializeField] private SpringJoint _springJoint;
[SerializeField] private Rigidbody _rigidbody;
@MadStool
MadStool / gist:81fb1af5a57b1650b77a411c1926aa46
Created July 27, 2025 13:06
Имя параметра дублируется в имени метода
public void Shoot(Player target) {}
public string Find(int index) {}
@MadStool
MadStool / gist:73f9fafc114e46427bfcae13ac58fcfa
Created July 27, 2025 13:02
Аргументы-флаги - это плохо
public void Enable()
{
_enable = true;
_effects.StartEnableAnimation();
}
public void Disable()
{
_enable = false;
_pool.Free(this);
@MadStool
MadStool / gist:fde654931d12fcf6e842ff610a0f003f
Last active July 27, 2025 13:34
Замена условной логики полиморфизмом
using System;
using System.Collections.Generic;
using System.Linq;
namespace IMJunior
{
class Program
{
static void Main(string[] args)
{
@MadStool
MadStool / gist:1f4e2df14927abee214b3fef084ebc4d
Last active August 1, 2025 19:15
В функции можно использовать функции её уровня и на один ниже
using System;
using System.Data;
using System.Data.SQLite;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
public static class Program
@MadStool
MadStool / gist:0cd35a02cdfd221719b1d5536bb32731
Last active July 27, 2025 13:29
Группировка полей по префиксу
public class Player
{
private readonly Movement _movement;
private readonly WeaponController _weapon;
private readonly PlayerProfile _profile;
public Player(string name, int age)
{
_profile = new PlayerProfile(name, age);
_movement = new Movement();
@MadStool
MadStool / gist:254cd2e153a1c399677a0ae60392e054
Created July 27, 2025 12:21
Методы set должны устанавливать значение из параметра
public static void CreateMapObject()
{
// Создание объекта на карте
}
public static void RandomizeChance()
{
_chance = Random.Range(0, 100);
}
@MadStool
MadStool / gist:6e19248af523f02d22ed5934cf73d266
Created July 27, 2025 12:15
Имена классов и объектов должны предоставлять собой существительные
class Player { }
class Weapon { }
class Follower { }
class UnitCollection
{
public IReadOnlyCollection<Unit> AvailableUnits { get; private set; }
}
@MadStool
MadStool / gist:ceaacb28fc6d69620bf979ae15f62126
Created July 27, 2025 12:12
Берите имена из предметной области. Не мяукало, а кошка.
class Pistol
{
public void Fire() { }
}