Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tank : Unit
- {
- public void DoSomething() => World.CreateTank();
- }
- public class Unit
- {
- protected readonly World World;
- public Unit(World world) => this.World = world;
- }
- public class World
- {
- public World()
- {
- _units = new Units();
- _unitFactory = new UnitFactory(this);
- }
- public void CreateTank() => _units.Add(_unitFactory.CreateTank());
- UnitFactory _unitFactory;
- Units _units;
- }
- public class UnitFactory
- {
- public void Create(string name) => new Unit(_world);
- public void CreateTank() => new Tank(_world);
- readonly World _world;
- public UnitFactory(World world) => this._world = world;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement