It's week 2 of Google Summer of Code! This meant taking the next step in the project--working on implementing factions.

The idea of factions is simple--the player will choose a team to be on, red or black, and depending on their current faction they will be able to interact with the world in different ways. For instance, a player cannot pick up their team's flag when the flag is at the base.

To begin, I worked on tracking the player's own faction. Thankfully, some of the existing code in the Light and Shadow module made this easier. The previously created LASTeam component keeps track of the team of the item it's a component of as a String. I attached an LASTeam component to the player using a delta of player.prefab:

{
"LASTeam" : {
"team" : "white"
}
}


I set the team initially to white because part of the idea of the L&S world is that players begin as part of a neutral faction (the white faction) and can join the red or black teams. I then added some logic to the flag pickup statements so that you can only pick them up if you are on the opposite team.

Changing a line in TakeBlockInActivationSystem:
if (flagTeamComponent.team.equals("red") && playerTeamComponent.team.equals("black")) {

Note: This will need tweaking once players pick up and drop flags places, since you should not be able to pick them up only when they are on the base.

Finally, I set the flag blocks as non-destructible (by setting their mass to 0 in LightAndShadowResources) so that the block can only be taken by pressing E rather than destroying it, so taking the flags and checks needed for that only went through one system.

These changes can be seen in these pull requests:

After this, I started working on some more changes. I decided to switch over the the main LightAndShadow world, just adding the BaseProvider and BaseRasterizer to the world gen lineup, because it already came with the previously created platform and dialog to choose which faction you'd be a part of. (Note: Still need to figure out how to get the y axis of the platform to spawn just above ground level, rather than a fixed y coordinate).


Ready to jump off this platform and fight
I edited the current dialog for the faction-giving NPC to allow the player to join red or black team, and teleport them to the base.
Unfortunately at some point here the game began to crash and throw some error in an unrelated module, and led me down a path of trying to fix something wonky going on in my workspace. As of writing this, I just un-borked whatever the problem was, so tomorrow I'm going to go back through the code I've been working on to ensure it works before pushing.
I'll cover this code in more detail once I get it working (next week's blog post).
Figuring out how to fix this and push my new changes for this week is top priority, after which is figuring out what to do next. I'd like to start working on UI for teams/scoring as well as setting up the logic for the scoring--where the player returns to base with the opposing team's flag and scores a point--as per suggestions from last week. Also super useful would be multiplayer testing! Hopefully can try out more of that in days to come.