<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Architecture &#8211; Games Architecture</title>
	<atom:link href="http://gamesarchitecture.com/category/architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamesarchitecture.com</link>
	<description>For indie developers who already know that making games is not easy</description>
	<lastBuildDate>Sat, 30 Dec 2017 20:29:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.8</generator>
	<item>
		<title>Don&#8217;t bring web development toys to Unity&#8217;s kindergarten</title>
		<link>http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/</link>
		<comments>http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/#comments</comments>
		<pubDate>Fri, 17 Nov 2017 22:18:51 +0000</pubDate>
		<dc:creator><![CDATA[Bartosz]]></dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Unity]]></category>

		<guid isPermaLink="false">http://gamesarchitecture.com/?p=466</guid>
		<description><![CDATA[<p>That&#8217;s right, I said it. It looks like some web developers want to bring their habits to Unity with them. I understand that you expect it will be easier this way. But I think it may be easier for you (at the beginning), but not for other game developers. Especially not for Unity developers. I &#8230; </p>
<p class="link-more"><a href="http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/" class="more-link">Continue reading<span class="screen-reader-text"> "Don&#8217;t bring web development toys to Unity&#8217;s kindergarten"</span></a></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/">Don&#8217;t bring web development toys to Unity&#8217;s kindergarten</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-467" src="http://gamesarchitecture.com/wp-content/uploads/2017/11/1325383397346.png" alt="" width="1534" height="630" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/11/1325383397346.png 1534w, http://gamesarchitecture.com/wp-content/uploads/2017/11/1325383397346-300x123.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/11/1325383397346-768x315.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/11/1325383397346-1024x421.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">That&#8217;s right, I said it. It looks like some web developers want to bring their habits to Unity with them. I understand that you expect it will be easier this way. But I think it may be easier for you (at the beginning), but not for other game developers. Especially not for Unity developers. I came across a couple blog posts, and I saw in the comments that people that thank for the &#8220;MVC for Unity tutorial&#8221; are the ones that are already familiar with MVC and want to do something in Unity. I find it a quite dangerous approach. It looks like they don&#8217;t know what MVC is for, WHY do we even use it. Main benefits of using it shatter in Unity when understood wrong. When I want to learn Unity, I should look for &#8220;Unity tutorial&#8221; in Google. Or &#8220;Xamarin tutorial,&#8221; or &#8220;Ruby on Rails tutorial.&#8221; Looking for something like &#8220;How to make a web page in Unity&#8221; doesn&#8217;t seem the most effective path, though it may be an interesting adventure. It’s a good idea to explain some new concepts basing on the ones you are already familiar with (i.e. <a href="https://docs.unrealengine.com/latest/INT/GettingStarted/FromUnity/" target="_blank" rel="noopener">Unreal Engine for Unity developers</a>). But then you should familiarize with the new framework and its &#8220;culture.&#8221; And don&#8217;t get me wrong, it&#8217;s totally okay to try new, even weird, things. It may only develop you as a programmer. Go, have fun, make a game in assembly or banking app in Unity. But if you really want to learn something new, then learn something new. Don&#8217;t stick to your habits just because you feel safe. Let&#8217;s get to some technical details.<span id="more-466"></span></p>
<h1>Content</h1>
<p>What is MVC and what it gives us<br />
How we work in Unity<br />
Where is the MVC?<br />
My problems with that understanding of MVC<br />
Summary<br />
Some links</p>
<h1 style="text-align: justify;">What is MVC and what it gives us</h1>
<p>MVC is an architectural concept that separates application to three domains.</p>
<ul>
<li>Model &#8211; Data and data access. It does nothing except containing data and (eventually) providing API for data management.</li>
<li>View &#8211; The visual presentation that is responsible for displaying Model in some way (tables, scroll views, etc.) The View never changes the Model directly.</li>
<li>Controller – A bunch of scripts that interpret user input, change Model according to it and deciding which View to display next.</li>
</ul>
<p style="text-align: justify;">Through all these years (<a href="http://heim.ifi.uio.no/~trygver/1979/mvc-2/1979-12-MVC.pdf" target="_blank" rel="noopener">the oldest paper I found is from 1979</a>), MVC got many varieties. You can approach different definitions of MVC if you ask different people with different development backgrounds. I’ll provide you with sources I based on. Anyway, MVC has been adapted to many platforms, and Unity is one of them.</p>
<p>Alright, that&#8217;s the basic idea, but what are the benefits of using MVC?</p>
<ol>
<li>Separation of a back-end (often &#8211; a model and a controller) from the front-end (a view), so web designers can focus on a page look and developers on managing data, connections with databases, etc.</li>
<li>Controller separation, so if we want to add or change the way data is processed (application behavior), view and model don&#8217;t care,</li>
<li>View separation so that we can have multiple views (i.e. for different platform/browser) or we&#8217;re able to reskin web page easily, without bothering developers.</li>
<li>Probably more. Can you add something?</li>
</ol>
<h1>How we work in Unity</h1>
<p>I&#8217;m assuming you know Unity, or at least its architecture based on components and how to combine them to make something work. We&#8217;ll need an understanding of &#8220;<a href="http://gamesarchitecture.com/cohesive-abstraction-solving-most-of-your-dilemmas-in-an-easy-way/" target="_blank" rel="noopener">class cohesion</a>&#8221; as well.</p>
<p style="text-align: justify;">When we (me and my teammates, whatever a team was) made a game, everyone who worked in Unity was a Unity developer. Unity was a front-end. A separate server (i.e. GameSparks, something on Azure) and a database were a back-end. Unity talked with the server via a REST API (Get, Post, etc.) if a game needed it. The server was responsible for communication with the database. Artists worked on graphics and sound assets, and very often they didn&#8217;t have Unity installed at all. Designers worked on scenes (level design, aligning UI) and tweaked values in the Inspector.</p>
<h1>Where is the MVC?</h1>
<p>We can look for MVC architecture in the project in a couple of ways. Everything depends on how far we zoomed out our perspective.</p>
<ul>
<li style="text-align: justify;">F2P or multiplayer games usually need a server and a database (back-end). Users data and values for level definitions/difficulty are kept in the database. Game logic (the rules; how you play the game) are scripted in Unity. But some of the things, like if a player should win a reward, should be implemented on the server to prevent cheating. Okay, so what in that case is M, V, and C in our MVC concept? For me, it looks like the database is a Model (data part), the server (with a bunch of scripts) is a Model (data access part) and Controller (method for random reward winning), and Unity is a Controller (game logic) and a View. If you&#8217;ve got a different perspective of that, remember to share it with us in comments.</li>
<li style="text-align: justify;">Singleplayer games usually don&#8217;t need a server or database (maybe for analytics). In this case, Unity is responsible for all the letters in &#8220;MVC,&#8221; and forcing MVC concepts here is risky. In <a href="https://www.toptal.com/unity-unity3d/unity-with-mvc-how-to-level-up-your-game-development" target="_blank" rel="noopener">this very popular blog post</a> about it, the author cuts a Player to three different scripts (one per M, V, and C). I don&#8217;t agree with that concept, and here&#8217;s why.</li>
</ul>
<h1>My problems with that understanding of MVC</h1>
<ul>
<li style="text-align: justify;">MVC adds another level of complexity you have to manage and maintain. It&#8217;s not natural for Unity projects, so it is harder to get used to for Unity developers.</li>
<li style="text-align: justify;">Unity supports building for different platforms and does the hardest part for you. Is it Android or iPhone UI? For Unity, in most cases, it doesn&#8217;t matter. You can do a reskin in the editor. It doesn&#8217;t matter if a reskinned object has some behavior on it or not. Designer updates only one of its component anyway.</li>
<li style="text-align: justify;">It kills and pees the <a href="https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)" target="_blank" rel="noopener">encapsulation</a>. A Player object that has some scripts on it, another PlayerView object with a Renderer and yet another one with Health field? It&#8217;s not like object-oriented programming works. Classes are collections of data and behavior. MVC (in above understanding) separates these two things from each other.</li>
<li style="text-align: justify;">It does the same to hermetization (hiding) and makes reasoning about a code much harder. &#8220;This access will allow every MVC class to reach every other.&#8221; Without any constraints, the code flow may (and will) complicate very quickly. Hermetization is one of the most important (if not the most) OOP paradigm (though it is often described as a part of the encapsulation).</li>
<li style="text-align: justify;">The sentence <em>&#8220;By splitting the thinking process into data, interface, and decisions, developers can reduce the number of source files that must be searched in order to add or fix functionality.&#8221;</em> is just not true. It&#8217;s exactly the opposite. Instead of one Player script, now we have three of them. To handle a new parameter you&#8217;d have to update THREE files and the code communication between them. Every change is much harder to manage.</li>
<li style="text-align: justify;">It’s slower. Instead of managing the Player in a Player script (it sounds obvious, right?), you&#8217;re wasting resources on sending messages.</li>
</ul>
<h1>Summary</h1>
<p style="text-align: justify;">As you probably noticed, it seems like successfully applying MVC architecture strongly depends on what you consider being M, V, and C. Don&#8217;t adapt known concepts to new environments just because it seems possible. First, you should probably try to learn the new environment to some extent, how it works and what practices are the most broadly used before you consider changing it. Probably. The decision about that shouldn&#8217;t be based only on the convenience or discomfort you feel while thinking about The Great New. Work with others, ask more experienced developers what they think about your idea. MVC is a great architectural concept, but like every other pattern, it shouldn&#8217;t be adapted to new situation carelessly, just because it worked perfectly somewhere else. Maybe someday someone will show great examples of &#8220;MVC for Unity.&#8221; Don&#8217;t stop looking for better workflows and don&#8217;t forget to inform me if you find something interesting.</p>
<h1>Some links</h1>
<ul>
<li><a href="http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html" target="_blank" rel="noopener">Sources about MVC (dated to 1979)</a></li>
<li><a href="http://heim.ifi.uio.no/~trygver/1979/mvc-2/1979-12-MVC.pdf" target="_blank" rel="noopener">Trygve Reenskaug &#8211; MODELS &#8211; VIEWS &#8211; CONTROLLERS (1979)</a></li>
<li><a href="https://www.toptal.com/unity-unity3d/unity-with-mvc-how-to-level-up-your-game-development" target="_blank" rel="noopener">Unity with MVC: How to Level Up Your Game Development</a></li>
<li><a href="https://blog.codinghorror.com/understanding-model-view-controller/" target="_blank" rel="noopener">Understanding Model-View-Controller (Coding Horror)</a></li>
<li><a href="http://blog.iandavis.com/2008/12/what-are-the-benefits-of-mvc/" target="_blank" rel="noopener">What Are The Benefits of MVC?</a></li>
</ul>
<div class="grammarly-disable-indicator"></div>
<div class="grammarly-disable-indicator"></div>
<div class="grammarly-disable-indicator"></div>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/">Don&#8217;t bring web development toys to Unity&#8217;s kindergarten</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamesarchitecture.com/dont-bring-web-development-toys-to-unitys-kindergarten/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Read it like a book &#8211; Painless way of programming Game Modes and Skills (Part III)</title>
		<link>http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/</link>
		<comments>http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/#comments</comments>
		<pubDate>Fri, 29 Sep 2017 20:01:08 +0000</pubDate>
		<dc:creator><![CDATA[Bartosz]]></dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://gamesarchitecture.com/?p=431</guid>
		<description><![CDATA[<p>Strategy is a meritorious pattern, and I think it may interest you. Why? Because you want your code to be flexible. That flexibility allows you, for example, to switch behavior with ease, whenever you like. You don’t want to replace half of the classes when the rules of your game change. Or maybe you want &#8230; </p>
<p class="link-more"><a href="http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/" class="more-link">Continue reading<span class="screen-reader-text"> "Read it like a book &#8211; Painless way of programming Game Modes and Skills (Part III)"</span></a></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/">Read it like a book &#8211; Painless way of programming Game Modes and Skills (Part III)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-440" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_skills_tapir.png" alt="" width="1176" height="546" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_skills_tapir.png 1176w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_skills_tapir-300x139.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_skills_tapir-768x357.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_skills_tapir-1024x475.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;"><em>Strategy</em> is a meritorious pattern, and I think it may interest you. Why? Because you want your code to be flexible. That flexibility allows you, for example, to switch behavior with ease, whenever you like. You don’t want to replace half of the classes when the rules of your game change. Or maybe you want to have different game modes, and you’re struggling with <code>switch</code> statements all around the place? <em>Strategy</em> pattern allows you to code another game mode without the fear of breaking the rest of the game.</p>
<p><span id="more-431"></span></p>
<h1>&#8216;Read it like a book&#8217; series</h1>
<p><a href="http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i" target="_blank" rel="noopener">Part I &#8211; Centralized Control</a><br />
<a href="http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/" target="_blank" rel="noopener">Part II &#8211; What to do when Centralized Control does not work?</a><br />
Part III &#8211; Painless way of programming Game Modes and Skills (this)<br />
Part IV &#8211; Soon</p>
<h1>Content</h1>
<p>When you might need a Strategy?<br />
Strategy Example &#8211; Player Skills<br />
Strategy Example &#8211; Game Modes<br />
One more thing<br />
Summary</p>
<h1>When you might need a Strategy?</h1>
<p style="text-align: justify;">Even if you&#8217;ve got only two game modes you&#8217;ll make use of the <em>Strategy</em>, because of the effortless switching between them in runtime. Cases where you&#8217;ll take advantage of the pattern, don&#8217;t have to be such big things like whole game modes, though. Maybe you&#8217;ve got a bunch of skills (mapped from 1 to 9 on the keyboard) that are used by pressing a key, but their behavior differs from each other fundamentally. One skill will increase the player&#8217;s HP; another one will change him into a super-fast blue tapir. All the skills have few things in common:</p>
<ul>
<li style="text-align: justify;">They all are used by the player the same way &#8211; press a key, and wait for an animation to end.</li>
<li style="text-align: justify;">The class that uses them shouldn&#8217;t know the difference between one and another, so it won’t be dependent on their implementation &#8211; the skills are interchangeable.</li>
<li>They can be switched between the keys on the fly.</li>
<li style="text-align: justify;">They change the player somehow, so they need a reference to him or a proper player’s interface. We assume that skills are very different, so we cannot extract common parameters for them. In that case, the best solution is to pass the player’s object to them (if a &#8216;Dependency Injection&#8217; term came up to your mind, you’re damn right).</li>
<li style="text-align: justify;">You want to add/remove/update skills independently from the rest of the codebase, and you probably wish to have a painless way of doing that.</li>
</ul>
<p>Let&#8217;s see how the <em>Strategy</em> pattern looks like in general:<br />
<img class="aligncenter size-full wp-image-441" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_pattern.png" alt="" width="1660" height="880" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_pattern.png 1660w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_pattern-300x159.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_pattern-768x407.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_pattern-1024x543.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">You&#8217;ve got a <em>Strategy</em> abstract class that the <code>Context</code> uses. Concrete strategies derive from a <em>Strategy</em> to define a particular behavior. Each of them has its class so that they can be defined independently.<br />
<code>Context</code> is configured with a concrete strategy by another class or by itself. It delegates the operation to its current strategy class to avoid <code>switch</code> statements here and there.</p>
<h1>Strategy Example &#8211; Player Skills</h1>
<p>Below you can see how the <em>Strategy</em> may look like when put into the player’s skills scenario:<br />
<img class="aligncenter size-full wp-image-442" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills.png" alt="" width="1690" height="878" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills.png 1690w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills-300x156.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills-768x399.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills-1024x532.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">The most important question now is probably &#8216;How to configure the <code>Player</code> with a concrete <code>PlayerSkill</code> class?&#8217;</p>
<p style="text-align: justify;">The simplest solution is probably to call an event in <code>SkillBar</code> script every time the player had pressed a proper key. Catch that event in the <code>UIController</code>, which has a reference to the player, and cast a chosen skill from there.</p>
<p><img class="aligncenter size-full wp-image-443" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills_initializing.png" alt="" width="1250" height="656" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills_initializing.png 1250w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills_initializing-300x157.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills_initializing-768x403.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_player_skills_initializing-1024x537.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">The above solution lets you add many skills without worrying that it&#8217;ll affect the rest of the game. You don&#8217;t have to have <code>switch</code> statements with a <code>case</code> for every skill. You don&#8217;t need an additional <code>enum</code> field in skills or dynamic casting to know which skill is it. You may have a few other programmers working on their skills implementation without interfering with each other. How does it sound?</p>
<h1>Strategy Example &#8211; Game Modes</h1>
<p>While <code>Player</code>&#8211;<code>Skill</code> relation is quite ephemeral (we&#8217;re using a skill and moving on), <code>Gameboard</code> will definitely keep a reference to the <code>GameMode</code> through the whole play:<br />
<img class="aligncenter size-full wp-image-444" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_game_modes.png" alt="" width="1464" height="950" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_game_modes.png 1464w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_game_modes-300x195.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_game_modes-768x498.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/strategy_game_modes-1024x664.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;"><code>Gameboard</code> delegates a few different operations to the <code>GameMode</code> <em>Strategy</em>. We’ve got a Chess game and two modes: Classic and Battle.<br />
<code>Classic</code>:<br />
<code>StartGame()</code>: Set up chess normally.<br />
<code>EndGame()</code>: Clear out the board and show statistics.<br />
<code>OnPlayerMoved()</code>: Switch active player</p>
<p><code>Battle</code>:<br />
<code>StartGame()</code>: Set up chess and randomize positions of a few pawns for both players.<br />
<code>EndGame()</code>: Clear out the board and show statistics (same behavior as <code>Classic</code>).<br />
<code>OnPlayerMoved()</code>: Disable random empty field, so the chess cannot be moved there.</p>
<p style="text-align: justify;">And <code>Gameboard</code> doesn’t know about any of that. It is initialized with a particular <code>GameMode</code> depending on a button the player clicks. All its operations which behavior depends on a game mode are delegated to the <em>Strategy</em> pattern. Do you need a new game mode? Create a new class that derives from a <code>GameMode</code>, implement its abstract interface and place a new game mode button in the menu. Simple as that.</p>
<h1>One more thing</h1>
<p style="text-align: justify;">It is worth to mention one more variation of the pattern. If you’ve got many operations in the <em>Strategy</em> and a bunch of game modes that differ only in one or two of them, you can have a default game mode with virtual methods. It would be placed between the abstract class (<code>GameMode</code>) and concrete strategies (<code>Classic</code> and <code>Battle</code>). If your game mode doesn’t change default behavior it doesn’t override its method.</p>
<h1>Summary</h1>
<p style="text-align: justify;">Today, we haven’t mentioned the <em>Singleton</em>. The <em>Strategy</em> MIGHT help you avoid using <em>Singleton</em>, but it isn&#8217;t its primary purpose and the biggest advantage. However, it is a very precious tool in your arsenal as many games would make a very good use of it. In the next post, you&#8217;ll see a design pattern that is very similar to the <em>Singleton</em> but somehow better. It should fill all the gaps that we haven&#8217;t filled yet.</p>
<p style="text-align: justify;"><em>And now I wish to ask you for advice. Tell me how do you feel about the Games Architecture. Do you think that I should change something, or everything is perfect for you? Maybe you&#8217;ve got a particular problem and want to share it with us so we can think how to solve it together? I&#8217;m here, and I can hear you.</em></p>
<div class="grammarly-disable-indicator"></div>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/">Read it like a book &#8211; Painless way of programming Game Modes and Skills (Part III)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Read it like a book &#8211; What to do when Centralized Control does not work? (Part II)</title>
		<link>http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/</link>
		<comments>http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/#respond</comments>
		<pubDate>Fri, 01 Sep 2017 19:48:49 +0000</pubDate>
		<dc:creator><![CDATA[Bartosz]]></dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://gamesarchitecture.com/?p=412</guid>
		<description><![CDATA[<p>In the previous post of &#8216;Read it like a book&#8217; series we talked about Centralized Control. In this basic object-oriented concept, high-level classes call methods on lower-level ones. Lower-level classes call events that the high-level classes listened and reacted to. But it is not always the best or even a possible solution. Observers are great, &#8230; </p>
<p class="link-more"><a href="http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/" class="more-link">Continue reading<span class="screen-reader-text"> "Read it like a book &#8211; What to do when Centralized Control does not work? (Part II)"</span></a></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/">Read it like a book &#8211; What to do when Centralized Control does not work? (Part II)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify;"><img class="aligncenter size-full wp-image-417" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.38.16.png" alt="" width="1608" height="600" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.38.16.png 1608w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.38.16-300x112.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.38.16-768x287.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.38.16-1024x382.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" />In the previous post of &#8216;Read it like a book&#8217; series we talked about Centralized Control. In this basic object-oriented concept, high-level classes call methods on lower-level ones. Lower-level classes call events that the high-level classes listened and reacted to. But it is not always the best or even a possible solution. Observers are great, but there are cases where using them leads to classes that cause some nasty problems. In the next two posts of the series we&#8217;ll introduce design patterns that&#8217;ll help you to handle foreign services (databases, analytics), multi-platform development (analogical, but separate services for Android and iOS, like In-App Purchases or Leaderboards) and such everyday things like Audio or Input Managers.<br />
<span id="more-412"></span></p>
<h1>&#8216;Read it like a book&#8217; series</h1>
<p><a href="http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i" target="_blank" rel="noopener">Part I &#8211; Centralized Control</a><br />
Part II &#8211; What to do when Centralized Control does not work? (this)<br />
<a href="http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/" target="_blank" rel="noopener">Part III &#8211; Painless way of programming Game Modes and Skills</a><br />
Part IV &#8211; Soon</p>
<h1>Content:</h1>
<p>A few more information about Centralized Control<br />
Devil&#8217;s favor of the Singleton<br />
What did they tell you about Inversion of Control?<br />
Just pass it</p>
<h1>A few more information about Centralized Control</h1>
<p style="text-align: justify;">1. Remember about the cohesive abstraction. If your <em>UIController</em> operates on too low-level objects, consider creating a class in the middle. If, for example, the <em>UIController</em> turns on and off whole game screens and, on the other hand, keeps track of player&#8217;s score value and <em>Text</em> component that displays that value, something smells bad. You can create <em>ScoreUI</em> class with <code>AddPoints(int)</code> interface method, which will do the same, but it will hide it behind a single method call. If you add animation after the score updates, you have to update only that method. Having abstraction in mind somehow forces you to write more methods, and the more named pieces of code, the better. You get greater flexibility and easier codebase maintenance.</p>
<p style="text-align: justify;">2. Cohesive abstraction helps to maintain a beautiful tree of a class hierarchy, but it is quite difficult to keep that abstraction tight. Mainly because in game development we often want to program smaller features fast. This is where the little bugs come from. Sometimes it is tempting to add the score handling to the <em>UIController</em> because it is faster than creating a new class for it. Especially if you just want to add points. If you create a <em>ScoreUI</em> class with only <code>AddPoints()</code> procedure, you may &#8220;feel&#8221; like you HAVE TO add the whole interface right away. <code>Reset()</code>, <code>GetScore()</code>, <code>Save()</code>, <code>Subtract()</code> and maybe a few more. You know what? You don&#8217;t have to. Add the <em>ScoreUI</em> class with the interface you need RIGHT NOW. If you or someone else will need new API later, the right script is already there.</p>
<h1>Devil&#8217;s favor of the Singleton</h1>
<p style="text-align: justify;">Singleton pattern arouses many emotions. It is a class that can only has one instance, and it can be used from every corner of the codebase &#8211; it is globally available. In game development it’s so popular, that we can see it almost everywhere. <em>Audio Manager</em>? Singleton. <em>Input Manager</em>? Singleton. <em>Analytics Controller</em>? Singleton. It is not bad on its own, but it is often used very dangerously. Robert Nystrom has already written an <a href="http://gameprogrammingpatterns.com/singleton.html" target="_blank" rel="noopener">excellent piece</a> about it, and I strongly advise you to read it.</p>
<p>You can use it just like that:<br />
<code>AchievementsController.Instance().UnlockAchievement(Achievements.SINGLETON_ARTICLE_READ);</code></p>
<p style="text-align: justify;">If you do not see why this is bad, read the above article first with a strong emphasis on <a href="http://gameprogrammingpatterns.com/singleton.html#why-we-regret-using-it" target="_blank" rel="noopener">Why We Regret Using It</a> section. I wish to add one more thing to the What We Can Do Instead part.</p>
<p style="text-align: justify;">Let&#8217;s take an <em>Achievement Controller</em> as an example. To avoid coupling everything that unlocks an achievement to a singleton class you can consider events. Did a player jump off from a gigantic cliff? Send <code>PlayerFeltFromHeight(float)</code> event and allow <em>Achievement Controller</em> to decide if the achievement should be unlocked or not. Some of the events may seem like they exist for only that particular reason, so what? You lose nothing and gain decoupled classes. You may consider this solution whenever you need to call something, and a return value is not expected (send analytics data, post leaderboards score, update database and so on.). Of course, it&#8217;s not always possible, but we&#8217;ll get to it.</p>
<p style="text-align: justify;">A more tricky situation is when you need something FROM the Singleton class.<br />
<code>IAPController.Instance().GetPrice(Items.BAZOOKA);</code><br />
or<br />
<code>InputController.GetActionDown(Actions.JUMP);</code><br />
I intentionally left off the &#8216;<code>Instance()</code>&#8216; in the second example. Here, the <em>Input Controller</em> does not have an instance; it is a simple static class. It is often a better choice because you do not always need an object at all. In the above cases, we&#8217;ve got a few options. But first, let me ask you a question.</p>
<h1>What did they tell you about Inversion of Control?</h1>
<p style="text-align: justify;">You may have heard of it as a term interchangeable to Dependency Injection, but it is not accurate. Dependency Injection is a one way to achieve Inversion of Control (IoC). Do you remember the scheme from the previous post with a class tree? IoC is when the arrow goes up, instead of going down (still, only one arrow connects these two classes). Instead of letting the high-level class to decide where to call low-level methods, we allow low-level classes to do the opposite. The control is inverted.</p>
<p style="text-align: justify;">I often struggled with an <em>Audio Controller</em> on multi-scene games (so most of them). I usually had only one <em>Audio Controller</em> with ALL the references from the WHOLE game to listen to events and play sounds according to what happened, but it has a few drawbacks. On a scene change, I had to find the proper references, start to listen to them and stop when the scene changed. When I added (or remove) something &#8220;vocal&#8221; to the scene, I had to update the <em>Audio Controller</em> script to listen and react to that new thing. The class contained mostly one-line methods that only play a sound when something happens. Reading such a class to see what clips play when is a real pain. The standard solution to that is to have <em>Audio Controller</em> as a singleton and call its methods from the classes that need a sound. To be honest, this is a by far more convenient way to solve this. But not every class needs that possibility, so let&#8217;s do something else, what will give us an extra feature and keep the architecture neat.</p>
<p style="text-align: justify;">Let&#8217;s assume we&#8217;ve got an RPG game, where the player can pick a male or female character. With a standard audio singleton, we would need to put some &#8216;ifs&#8217; here and there to play a sound depending on a character&#8217;s sex. Or we could have two derived classes for male and female that differ only with playing sounds. Or we can use Dependency Injection.</p>
<h1>Just pass it</h1>
<p style="text-align: justify;">Dependency Injection is a pattern when you pass the necessary reference through the constructor or some kind of setter method (<code>Initialize()</code> for instance) to the class that needs it. In the above example, the <em>Player</em> class could have an <code>Initialize(..., AudioController, ...)</code> method. Then, whenever it needs to shout, it calls an <em>Audio Controller</em>&#8216;s method. The huge advantage of that solution is that we don&#8217;t have to expect a concrete class. The method used for injecting audio controller can expect an interface. Like this <code>Initialize(..., ICharacterAudio, ...)</code>. Here we did two things. We allowed any class that implements this interface to pass, and we limited the audio only to character&#8217;s realm (i.e., screams, groans or steps). Now we are allowed to write something like this:</p>
<pre class="brush: csharp; collapse: true; light: false; title: ICharacterAudio (click to unfold); toolbar: true; notranslate">
public interface ICharacterAudio
{
    void Scream();
    void Groan();
    void Step();
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: PlayerMaleAudio (click to unfold); toolbar: true; notranslate">
public class PlayerMaleAudio : ICharacterAudio
{
    void Scream() { AudioController.Instance.PlaySound(PLAYER_MALE_SCREAM); }
    void Groan() { AudioController.Instance.PlaySound(PLAYER_MALE_GROAN); }
    void Step() { AudioController.Instance.PlaySound(PLAYER_STEP); } // The same sound for both sexes.
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: PlayerFemaleAudio (click to unfold); toolbar: true; notranslate">
public class PlayerFemaleAudio : ICharacterAudio
{
    // Replace all 'MALE' with 'FEMALE'
}</pre>
<p style="text-align: justify;">Now, allow to <em>Gameplay Controller</em>/<em>Character Creator Controller</em> to do this:</p>
<pre class="brush: csharp; collapse: true; light: false; title: GameplayController/CharacterCreatorController (click to unfold); toolbar: true; notranslate">
ICharacterAudio playerAudio;
if (playerSex == Sex.MALE) // playerSex can be taken for example from the CharacteCreator class or game's save file.
{
    playerAudio = new PlayerMaleAudio();
}
else if (playerSex == Sex.FEMALE)
{
    playerAudio = new PlayerFemaleAudio();
}
[...]

playerCharacter.Initialize(..., playerAudio, ...);</pre>
<p>Scheme for this architecture:<img class="aligncenter size-full wp-image-416" src="http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.37.20.png" alt="" width="2042" height="1238" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.37.20.png 2042w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.37.20-300x182.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.37.20-768x466.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/09/Zrzut-ekranu-2017-09-01-o-21.37.20-1024x621.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">By doing it that way, we can have a whole bunch of controllers for every sex, race (it doesn&#8217;t have to be a human after all) and age. Each one of them is small and very readable. Even more important, we have only one, very liberal, <em>Player</em> class that doesn&#8217;t care about the sex or race.</p>
<p style="text-align: justify;">To achieve even greater flexibility, we can add a setter to the <em>ICharacterAudio</em> to the <em>Player</em> so we can change it at runtime (in the Fable game, our character got older and older, and the voice changed).</p>
<p style="text-align: justify;">Now, we have <em>Audio Controller</em> linked only to the classes strictly responsible for audio. <em>Player</em> uses part of the sounds it needs, and we can add new character&#8217;s types very quickly.</p>
<p style="text-align: justify;">There is yet another way to deal with it. Perhaps more straightforward and popular. We don&#8217;t have to limit the access to sounds only to the classes that definitely need to play audio. We can just assume that every game object should have that possibility. In this case, we can put the reference to the <em>Audio Controller</em> in the base class of every game object (<em>Actor</em>, <em>GameObject</em> or something similar). Every object that is meant to be put on the scene can play a sound through inheritance. We can even go one step further and make <em>Audio Controller</em> a regular class, create an instance of it in some kind of <em>Game Controller</em> and initialize every <em>Game Object</em> with it through dependency injection. But the utility of that last step somehow depends on the engine you&#8217;re using. Remember, the goal is to minimize the number of singletons in your code or get rid of them entirely if possible, but don&#8217;t be so rigorous. If removing the singleton will cause more problems than profits, just drop that idea and maybe try to limit access to it to as few classes as possible.</p>
<p style="text-align: justify;">Sometimes passing that dependency may be a problem. In bigger codebases, it may be required to pass the injected object through a bunch of classes just to lead it to the class that really needs it. In the next part, we&#8217;ll talk about that and about dealing with multi-platform services (Facebook, analytics) and how to decouple the game code from them.</p>
<div class="grammarly-disable-indicator"></div>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/">Read it like a book &#8211; What to do when Centralized Control does not work? (Part II)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read it like a book &#8211; Centralized Control (Part I)</title>
		<link>http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/</link>
		<comments>http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/#comments</comments>
		<pubDate>Mon, 17 Jul 2017 17:37:32 +0000</pubDate>
		<dc:creator><![CDATA[Bartosz]]></dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://gamesarchitecture.com/?p=303</guid>
		<description><![CDATA[<p>Oh, it&#8217;s you, hi! I want to invite you to read the first post in a new series about Centralized Control. This one is an overview of the subject. You&#8217;ll get familiar with the centralized architecture, how it looks like, and what are the biggest benefits of sticking to it. You&#8217;re probably using it already, &#8230; </p>
<p class="link-more"><a href="http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/" class="more-link">Continue reading<span class="screen-reader-text"> "Read it like a book &#8211; Centralized Control (Part I)"</span></a></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/">Read it like a book &#8211; Centralized Control (Part I)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-317" src="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_cancer-1.png" alt="" width="691" height="335" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_cancer-1.png 691w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_cancer-1-300x145.png 300w" sizes="(max-width: 691px) 100vw, 691px" /></p>
<p style="text-align: justify;">Oh, it&#8217;s you, hi! I want to invite you to read the first post in a new series about Centralized Control. This one is an overview of the subject. You&#8217;ll get familiar with the centralized architecture, how it looks like, and what are the biggest benefits of sticking to it. You&#8217;re probably using it already, but the chances are it has got a few holes. When it has the holes, the benefits leak through them like a blood. Are you sure that you&#8217;re okay with that?</p>
<p><span id="more-303"></span></p>
<h1>&#8216;Read it like a book&#8217; series</h1>
<p>Part I &#8211; Centralized Control (this)<br />
<a href="http://gamesarchitecture.com/read-it-like-a-book-what-to-do-when-centralized-control-does-not-work-part-ii/" target="_blank" rel="noopener">Part II &#8211; What to do when Centralized Control does not work?</a><br />
<a href="http://gamesarchitecture.com/painless-way-of-programming-game-modes-and-skills-strategy-pattern/" target="_blank" rel="noopener">Part III &#8211; Painless way of programming Game Modes and Skills</a><br />
Part IV &#8211; Soon</p>
<h1>Content</h1>
<p>What is the Centralized Control?<br />
Project structure and communication between scripts<br />
Some benefits of the Centralized Control</p>
<h1>What is the Centralized Control?</h1>
<p style="text-align: justify;">Centralized control is a relation between classes, where one of them uses the others, the others use yet other ones, and that structure is never inverted. Centralized control doesn&#8217;t have to apply to the whole project, but it can be implemented only in a few modules. These particular modules&#8217; architecture is centralized then. This code structurization is so natural for an object-oriented programming that almost everyone, even unconsciously, tends toward it. But somewhere on the programming trip that centralization starts to shatter. We give the very specialized classes like Fireball a surprising amount of information. The Fireball starts to demand a data about the world from the higher-level classes. It can even force these classes to do things by calling methods on them. Directly! Ugh. The flow of the game code breaks. You start to walk a dark path deeper and deeper into the underworld inhabited by miserably deformed and unfinished games.</p>
<p><img class="aligncenter size-full wp-image-328" src="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_unfinished_games2.png" alt="" width="1114" height="631" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_unfinished_games2.png 1114w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_unfinished_games2-300x170.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_unfinished_games2-768x435.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_unfinished_games2-1024x580.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">Do you really want that for your little baby you sick bastard? No, of course you don&#8217;t want that, my friend. Let&#8217;s see how the structure of the centralized control looks like.</p>
<h1>Project structure and communication between scripts</h1>
<p><img class="aligncenter size-full wp-image-323" src="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_centralized_scheme.png" alt="" width="1191" height="544" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_centralized_scheme.png 1191w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_centralized_scheme-300x137.png 300w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_centralized_scheme-768x351.png 768w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_centralized_scheme-1024x468.png 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">Pretty straightforward, right? Now look at the part of your game&#8217;s codebase and try to draw its scheme. If none of the arrows go back to the upper class, you&#8217;re cool. If there are some places when it happens, watch out. These are the places you should rethink as they might be a source of a major problem in the future. Huge cancer can grow on these arrows.</p>
<p style="text-align: justify;">Broken centralized architecture can be compared to dealing with an official matter in the <em>Department of Spaghetti</em>. You start on the first floor, and you want to submit an application at the window 101. There you&#8217;re being informed that you need a certificate from the window 821 on the third floor to proceed. On the third floor, you hear that you need to go to the second one. On the second floor you are being directed to the fifth floor, then to the first one and suddenly you don&#8217;t know why are you here anymore and where it all ends. Guys from the <em>Department of Centralization</em> organized their work different way. You start on the floor one at window 101 (&#8220;Oh, that is scary&#8221;, you think). Then you&#8217;re being directed to the floor two, three, four, and five. When you&#8217;re on the fourth floor, you know you&#8217;re getting close to the end. When your case is finalized on the fifth floor, you notice an elevator with Ed Sheeran inside it. While you&#8217;re riding down, he plays his guitar and sings gently. An elevator is a place where you can take a deep breath and rethink a whole logical journey.</p>
<p><img class="aligncenter size-full wp-image-319" src="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_ed_sheeran-1.png" alt="" width="695" height="294" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_ed_sheeran-1.png 695w, http://gamesarchitecture.com/wp-content/uploads/2017/07/centralized_control_ed_sheeran-1-300x127.png 300w" sizes="(max-width: 695px) 100vw, 695px" /></p>
<p style="text-align: justify;">Communication between scripts in the centralized architecture is as simple as its structure. High-level classes call methods on the low-level classes and might expect a return value. The low-level classes do their work, and when something interesting happens, they call an event (You remember events, right? <a href="http://gamesarchitecture.com/watch-out-youre-being-observed/" target="_blank" rel="noopener">The Observer pattern?</a>) High-level classes catch these events, and do the same things as they would do in regular methods. Coupling is one-sided.</p>
<h1>Some benefits of the Centralized Control</h1>
<ul>
<li style="text-align: justify;">The flow of the code is easier to understand.</li>
<li style="text-align: justify;">P. J. Plauger says about The Principle of One Right Place, that &#8220;There should be one right place to look for any non-trivial piece of code, and One Right Place to make a likely maintenance change.&#8221; It means that you&#8217;ll find the code you&#8217;re looking for faster, and you&#8217;ll make a change easier.</li>
<li style="text-align: justify;">Controllers’ and Managers’ classes have greater control over subordinate classes. This bullet is somehow related to the previous one. The fewer places where the low-level class is used, the less risk is taken by a high-level class that manages it.</li>
<li style="text-align: justify;">Believe me or not, but the classes&#8217; interfaces become simpler and clearer. That makes writing a code easier, not only reading it! Relax, I&#8217;ll explain it in the next post.</li>
</ul>
<p style="text-align: justify;">Speaking of the next post&#8230; In the next part of the series, we&#8217;ll look at a very different approach and how it may be useful. We&#8217;ll talk a bit about one of the most overused programming patterns in relation to the Centralized Control and code maintenance. You&#8217;ll get some tips about this architecture, its dangers and the solutions. Interested? And you&#8217;re aware, that you can subscribe &amp;&amp;/|| like a <a href="https://www.facebook.com/gamesarchitecture/" target="_blank" rel="noopener">Facebook page</a>, right? Great. So see you there!</p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/">Read it like a book &#8211; Centralized Control (Part I)</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamesarchitecture.com/read-it-like-a-book-centralized-control-part-i/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Watch out, you&#8217;re being observed!</title>
		<link>http://gamesarchitecture.com/watch-out-youre-being-observed/</link>
		<comments>http://gamesarchitecture.com/watch-out-youre-being-observed/#comments</comments>
		<pubDate>Mon, 29 May 2017 17:44:30 +0000</pubDate>
		<dc:creator><![CDATA[Bartosz]]></dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://gamesarchitecture.com/?p=172</guid>
		<description><![CDATA[<p>Hi! Welcome in the essentially first post on Games Architecture. I’m really glad you’re here and just in a minute I’ll let you dive into the substance, but first you need to know something about me. I’ve mentioned it in the very first post, but I think it is quite important to point it out &#8230; </p>
<p class="link-more"><a href="http://gamesarchitecture.com/watch-out-youre-being-observed/" class="more-link">Continue reading<span class="screen-reader-text"> "Watch out, you&#8217;re being observed!"</span></a></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/watch-out-youre-being-observed/">Watch out, you&#8217;re being observed!</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p><img src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa.jpg" alt="" width="948" height="327" class="aligncenter size-full wp-image-183" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa.jpg 948w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa-300x103.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa-768x265.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">Hi! Welcome in the essentially first post on Games Architecture. I’m really glad you’re here and just in a minute I’ll let you dive into the substance, but first you need to know something about me. I’ve mentioned it in the very first post, but I think it is quite important to point it out once again. I try to simplify things wherever I can and the code is first-class example. Programming is more about reading the code than writing it. You really want to make the first one as easy as you can, for future-you and the fellas that will be helping you.</p>
<p style="text-align: justify;">There are a couple of places where you can find some information about this design pattern (and I’ll point you there at the right time) but we will focus on examples and some tangible aspects of it. Ok, so here’s the problem:</p>
<p style="text-align: justify;">Let’s assume we have a monster and a player. Pretty common setting in games, isn’t it? The monster attacks the player, so programming it can be as simple as calling <code>player.TakeDamage()</code>. But (you expected the &#8216;but&#8217; didn&#8217;t you?) the games are rather multimedia experiences, so you’ll probably want to have some audio (<em>ouch!</em>) and maybe a screen effect, on instance red <em>Call of Duty</em> style indicator. Oh, oh, and somewhere on the screen the HP bar is placed. Let&#8217;s write this:</p>
<p><span id="more-172"></span></p>
<pre class="brush: csharp; collapse: true; light: false; title: Enemy (click to unfold); toolbar: true; notranslate">public class Enemy : Actor
{
    private Player _player;

    private int _attackDamage = 10;

    private void Update()
    {
        _player.TakeDamage(_attackDamage);
    }
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: Player (click to unfold); toolbar: true; notranslate">public class Player : Actor
{
    private AudioController _audioController;
    private Camera _effectsCamera;
    private UIController _uiController;

    private int _healthPoints = 100;

    public void TakeDamage(int damageValue)
    {
        _healthPoints -= damageValue;

        _audioController.PlayHitSound();
        _effectsCamera.ShowHitIndicator(seconds: 1);
        _uiController.UpdateHealthBar(newValue: _healthPoints);

        // Deal with players death...
    }
}</pre>
<p>So the diagram looks like this:<br />
<img class="aligncenter size-full wp-image-180" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_before.jpg" alt="" width="954" height="266" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_before.jpg 954w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_before-300x84.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_before-768x214.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">It’s quite possible that you feel that this is somehow wrong. Besides fighting with monsters and caring about our input, the hero has to manage all of the things he shouldn’t know about. To keep abstraction cohesive, player should care about input and his behavior, monster about attacking, audio about playing… you get the idea. But how to call all of these methods without actually calling them from player class? The answer is – don’t call them. Just let the player shout about the fact that it hurts so badly and hope for the best. Or you can make sure that someone is hearing by programming it. The one who hears the player&#8217;s pain is our today&#8217;s star – The Observer:</p>
<p><img class="aligncenter size-full wp-image-183" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa.jpg" alt="" width="948" height="327" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa.jpg 948w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa-300x103.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_tatarataaa-768x265.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">But the Observer is not a separate class, it&#8217;s more like an additional ability or a role of the existing class. He (the Observer) can listen to the others (classes of interest – subjects) and based on that, rule his realm (call appropriate methods). Instead of the above scenario, when subjects come to the Observer and make him do things (<em>&#8220;Hey ruler, play that track for me, mkay?&#8221;</em>), they just do their job and when something interesting happens, like they get hit by an arrow in the knee, they just shout about it. And they don’t know who and how many of them are listening in the moment. It can be a Bard (Audio) Observer that plays a sad song about the fallen hero, or it can be a Painter (UI) Observer, that updates his paintings that portray hero&#8217;s condition. Or it can be both of them. Or none. Nothing changes for the hero. Snap back to the reality (Oh, there goes gravity) and write some code.</p>
<pre class="brush: csharp; collapse: true; light: false; title: Player (click to unfold); toolbar: true; notranslate">public class Player : Actor
{
    /// &lt;summary&gt;
    /// Sends players object that just have died.
    /// &lt;/summary&gt;
    public Action&lt;Player&gt; Dead = delegate { }; // Don't be afraid of that syntax, its use is pretty simple.

    /// &lt;summary&gt;
    /// Sends players object that has been hit and new health value.
    /// &lt;/summary&gt;
    public Action&lt;Player, int&gt; Hit = delegate { };

    private int _healthPoints = 100;
    
    public void TakeDamage(int damageValue)
    {
        _healthPoints -= damageValue;

        Hit(this, _healthPoints); // Shout about being hit.

        if (_healthPoints &lt;= 0)
        {
            //Send another event, about players death and let the Gameplay Controller decide what to do with the body.
            Dead(this);
        }
    }
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: AudioController (click to unfold); toolbar: true; notranslate">public class AudioController
{
    private Player _player;

    private void Start()
    {
        // Start listening.
        _player.Dead += OnPlayerDead;
        _player.Hit += OnPlayerHit;
    }

    private void OnPlayerDead(Player player)
    {
        // Stop listening.
        _player.Dead -= OnPlayerDead;
        _player.Hit -= OnPlayerHit;
    }

    private void OnPlayerHit(Player player, int newHealthValue)
    {
        PlayHitSound();
    }

    private void PlayHitSound()
    {
        // Ouch!
    }
}</pre>
<p>We&#8217;ll skip the <code>Camera</code> and <code>UIController</code> scripts, they are analogous to the above.</p>
<p style="text-align: justify;"><strong>NOTE I:</strong> I&#8217;ve introduced one more event, <code>Dead</code>, to show unsubscribing and some danger related to using events. I&#8217;ll make use of it later.</p>
<p style="text-align: justify;"><strong>NOTE II:</strong> In the above example I’m sending player&#8217;s object. I didn’t have to do that, as every controller knows the player, but if we had a multiplayer game, we would want to know which player has been hit.</p>
<p>So now the diagram looks like that:<br />
<img class="aligncenter size-full wp-image-184" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_a.jpg" alt="" width="950" height="266" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_a.jpg 950w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_a-300x84.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_a-768x215.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;"><strong>NOTE III:</strong> I dropped drawing arrows from the controllers to the player and replaced them with little antennas to keep diagrams more readable, but remember that now they are linked to the player.</p>
<p>Or, we can go for more centralized control:</p>
<pre class="brush: csharp; collapse: true; light: false; title: GameplayController (click to unfold); toolbar: true; notranslate">public class GameplayController
{
    private AudioController _audioController;
    private Camera _effectsCamera;
    private Player _player;
    private UIController _uiController;
    
    private void Start()
    {
        // Start listening.
        _player.Dead += OnPlayerDead;
        _player.Hit += OnPlayerHit;
    }

    private void OnPlayerDead(Player player)
    {
        // Stop listening.
        _player.Dead -= OnPlayerDead;
        _player.Hit -= OnPlayerHit;

        // Restart level.
    }

    private void OnPlayerHit(Player player, int newHealthValue)
    {
        _audioController.PlayHitSound();
        _effectsCamera.ShowHitIndicator(seconds: 1);
        _uiController.UpdateHealthBar(newHealthValue);
    }
}</pre>
<p>And the diagram:<br />
<img class="aligncenter size-full wp-image-187" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_b.jpg" alt="" width="954" height="297" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_b.jpg 954w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_b-300x93.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_after_b-768x239.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;">The first one is simpler but less reusable as the controllers are more rigidly connected to player&#8217;s events. The second one allows for controllers reuse, as the Gameplay Controllers uses their API. Gameplay Controller in that case will be linked to everything, which is a bit harder to manage, but has an advantage in some cases. For example, if your game has a few game modes, changing game behavior is as simple as writing a new Gameplay Controller and switching between them accordingly. In that case making them derive from a common class will possibly be a good idea.</p>
<p style="text-align: justify;">Okay, let’s point out the biggest advantages of using this pattern and then we will move to the another example. Events (this is what the Observer listens) wonderfully decouple classes, so one of them doesn’t have to be aware of the second&#8217;s existence. And what do we get thanks to that?</p>
<ul>
<li>Adding another behaviors or changing existing ones doesn’t entail a change of all the other classes that are involved. Less opportunities to make a mistake.</li>
</ul>
<ul>
<li>It is easier to wrap your mind around programmed features, because you have to focus only on one class at the time. UI, Audio and Image effects can wait until you&#8217;re done with the most important code &#8211; players behavior.</li>
</ul>
<ul>
<li>Changing the Audio System completely, its API, adding and removing image effects (so classes <em>from above</em>*) doesn’t force you to change the player (class <em>from below</em>*). The new Audio System just listens to an appropriate event (but it doesn’t have to, if we don’t want to play that sound anymore) and does whatever it does. Player doesn’t know about it and doesn’t even care. The only thing that can change is adding a new event. And it can be used by every other class, without linking the player to anything.</li>
</ul>
<p style="text-align: justify;">* Not-so-formal definition of what I mean by classes <em>from above</em> and <em>from below</em> sounds as follow: Class <em>from above</em> knows more about game&#8217;s realm <strong>comparing to</strong> class <em>from below</em>. For example, player is class from above for projectile class. The second one may know about itself and about physics engine, while the first one knows about itself and that projectile. It doesn&#8217;t mean that class <em>from above</em> has to have reference to the class <em>from below</em>. It is just an <em>ability to know</em>.</p>
<p>Let&#8217;s jump to the another example.</p>
<p style="text-align: justify;">Imagine a level divided into a hex fields and two armies confronting each other on it. There are a couple of obstacles on some fields. Some of the hexes are placed on the hill, what gives the accuracy boost to the unit that stands there. When the soldier misses his shot, the opposite one has a chance to lead a counterattack. OK, let’s stop here. If you played something like <em>Heroes</em> or <em>Neuroshima Hex</em>, you are probably aware, how complex these systems can be. You can exercise a little and before you start looking closer on the code and the diagram below, you can try to solve this on your own. Oh, hey, you can even share it with me in the comments if you like! When you are ready, there is one of the solutions**:</p>
<p><img class="aligncenter size-full wp-image-196" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_example-1.jpg" alt="" width="950" height="300" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_example-1.jpg 950w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_example-1-300x95.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_diagram_example-1-768x243.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /><br />
The diagram is quite simple, right? I think that we need some code snippets:</p>
<pre class="brush: csharp; collapse: true; light: false; title: Unit (click to unfold); toolbar: true; notranslate">public class Unit
{
    public Action&lt;Unit&gt; AnimationDodgeEnd = delegate { };
    public Action&lt;Unit&gt; Dead = delegate { };
    public Action&lt;Unit, int&gt; Hit = delegate { };

    private int _accuracy = 50;
    private int _damage = 50;
    private int _range = 3;
    private Player _owner;
    private Vector2 _currentPosition;

    public Unit(Player owner, int accuracy, int damage, int range) { /* Initialize private fields. */ }

    // Getters for private fields.

    public void Move(Vector2 newPosition) { /* Move the unit to the new position. */ }

    public void TakeDamage(int damageValue) { /* Pretty same as in player class. */ }

    public void PlayAnimationAttack() { /* ... */ }

    public void PlayAnimationDodge() { /* ... */ }

    public void PlayAnimationHit() { /* ... */ }
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: EnvironmentController (click to unfold); toolbar: true; notranslate">public class EnvironmentController
{
    public int GetFieldAccuracyBonus(Vector2 fieldPosition) { /* Check field bonus and return it. */ }
    
    public bool IsFieldAvailable(Vector2 fieldPosition) { /* Check field availability and return it. */ }

    public bool IsFieldInRange(Vector2 centerField, int range) { /* ... */ }
    
    public void HighlightFieldsAround(Vector2 centerField, int range) { /* Highlight available fields on green and unavailable on red. */ }
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: FieldInputController (click to unfold); toolbar: true; notranslate">public class FieldInputController
{
    public Action&lt;Vector2&gt; FieldClicked = delegate { };
    public Action&lt;Unit&gt; UnitClicked = delegate { };
}</pre>
<pre class="brush: csharp; collapse: true; light: false; title: BattleController (click to unfold); toolbar: true; notranslate">public class BattleController
{
    private EnvironmentController _environmentController;
    private FieldInputController _fieldInputController;
    private Player _currentPlayer;
    private Unit _activeUnit;

    private void StartBattle()
    {
        _fieldInputController.FieldClicked += OnFieldClicked;
        _fieldInputController.UnitClicked += OnUnitClicked;
    }

    private bool IsAttackHit(Unit attackerUnit, int additionalAccuracy) { /* ... */ }

    private void OnFieldClicked(Vector2 fieldPosition)
    {
        // If player clicked on field, move the player there if it is available for him.
    }

    private void OnUnitClicked(Unit clickedUnit)
    {
        // If player clicked on his unit, make it active and highlight available fields around it.
        Player unitOwner = clickedUnit.GetOwner();
        if (unitOwner == _currentPlayer)
        {
            /* ... */
        }
        else // If player clicked on the enemy, attack that enemy unit if it's in range.
        {
            bool playerHit = TryAttackUnitInRange(_activeUnit, clickedUnit); // Plays the attackers attack animation.
            if (playerHit)
            {
                clickedUnit.PlayAnimationHit();
            }
            else
            {
                clickedUnit.PlayAnimationDodge();
                clickedUnit.AnimationDodgeEnd += OnUnitDodgeEnd;

                // Stop listening to input, until the turn ends.
                _fieldInputController.FieldClicked -= OnFieldClicked;
                _fieldInputController.UnitClicked -= OnUnitClicked;
            }
        }
    }

    private void OnUnitDodgeEnd(Unit victimUnit)
    {
        // Oh, yeah, we don't need to listen this anymore.
        victimUnit.AnimationDodgeEnd -= OnUnitDodgeEnd;

        // Give it back!
        bool unitHit = TryAttackUnitInRange(victimUnit, _activeUnit);
        if (unitHit)
        {
            _activeUnit.PlayAnimationHit();
        }
        else
        {
            _activeUnit.PlayAnimationDodge();
        }

        // Switch the current player, end the turn and listen to the input again.
        // We don't need to hear to attackers dodge animation end,
        // because we're assuming here, that end turn animation will last longer.
        // In the actual game you shouldn't rely on animations duration and another event subscription would be needed.

        _fieldInputController.FieldClicked += OnFieldClicked;
        _fieldInputController.UnitClicked += OnUnitClicked;
    }

    private bool TryAttackUnitInRange(Unit attackerUnit, Unit victimUnit) { /* Returns true, if attacker unit hit the victim unit. */ }
}</pre>
<p style="text-align: justify;">** I said &#8216;one of the solutions&#8217;, so can there be more than one? Is that at least the best one? Answer for the first question is <em>yes</em> and for the second one is <em>probably no</em>. It is really good though and easy to understand as this pattern is well known by the programming world. You should always look for the better solution, when you can see flaws in the current one that cannot be accepted. Don’t look for the perfect architecture, because there rarely is one. You should choose a solution that is good enough, be aware of its advantages and disadvantages and be confident that despite the fact that the cons exist, this is the right, conscious choice. And just for the record, we can talk about conscious choice only when you considered more than one solution.</p>
<p style="text-align: justify;">There you go. Use cases for Observer pattern are countless, but don’t get too excited. There are some flaws. You can find more technical one (memory and performance) <a href="http://gameprogrammingpatterns.com/observer.html" target="_blank" rel="noopener noreferrer">here</a> and I&#8217;ll add one more, from the programmer point of view. There are difficulties related to where to start subscribing and where to stop it. In the ideal world, we could hook up to the events on the application start and don’t bother unsubscribing. Or we could do it on level start and level end. But we live in a more challenging world, so for example we’re spawning (or enabling in case of object pooling) objects – monsters, projectiles, map chunks, menu entries and we’re destroying (disabling) them eventually. That’s why we have to spend additional time to check if we have subscribed as many times as we have unsubscribed. And it’s not always that obvious because of the complexity of the code. Consequences of this are very different, they are often hard to find and usually barely visible. The easiest case is when you can see that for one tango down you gain points two times. But it is rarely that easy. That’s why you should take a breath, take some distance (both literally and metaphorically) and double check if everything is fine.</p>
<p style="text-align: justify;">In first example we began listening in Start method and stopped when the player was dead. To make it work, after player&#8217;s death we should restart whole level, so the Start method will be called. When we are just spawning the player (with blinking and immortality?) short after his death, we won’t subscribe to his events.</p>
<p style="text-align: justify;">This inconvenience shouldn’t stop you from using the events, because at the end of the day they are crucial in game development. You’ll make mistakes, everyone does &#8211; especially if this is new to you. But the fear of unknown shouldn’t be the deciding factor in not using them. Go for it!</p>
<p style="text-align: justify;"><em>Okay, we made it. Despite the topic isn’t new, there is still so much codebases that don’t utilize the Observer pattern. That’s why I decided to start with it, even if it might be not the strongest card I could draw in the beginning. As you can see, the blog is new, so every feedback will be very appreciated. Tell me what you think, what are your experiences with the topic, who you are. If we’re sharing the same passion, I want to know.</em></p>
<p><img class="aligncenter size-full wp-image-188" src="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_feedback.jpg" alt="" width="950" height="105" srcset="http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_feedback.jpg 950w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_feedback-300x33.jpg 300w, http://gamesarchitecture.com/wp-content/uploads/2017/05/002_observer_feedback-768x85.jpg 768w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p>
<p style="text-align: justify;"><em>I’ve got a bunch of notes and drafts for the next posts and I’m excited about sharing them with you. If you think that it might be somehow interesting, stay in touch with me.</em></p>
<p style="text-align: justify;"><em>Oh, oh! I hope you&#8217;ve seen the <a href="http://gamesarchitecture.com/hello-world-of-gamedev/" target="_blank">first &#8220;hello world&#8221; post</a> about the blog and its future content. It will give you a better insight in what will be happening here. See you soon!</em></p>
<p>The post <a rel="nofollow" href="http://gamesarchitecture.com/watch-out-youre-being-observed/">Watch out, you&#8217;re being observed!</a> appeared first on <a rel="nofollow" href="http://gamesarchitecture.com">Games Architecture</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gamesarchitecture.com/watch-out-youre-being-observed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
