Page MenuHomeWildfire Games

[WIP] - Building Sockets.
Changes PlannedPublic

Authored by Freagarach on Oct 18 2019, 10:47 PM.

Details

Reviewers
None
Summary

This is a try at being able to use sockets for placing buildings.
Feedback is welcome and anyone who wants to give it a shot by themself is encouraged to commandeer ;)

ToDo:

  • Snapping to sockets.
  • Checking for sockets.

https://github.com/0ADMods/building-sockets/blob/master/simulation/components/BuildingSocket.js
https://gist.github.com/smiley3/001f2fc2dd47eb52ec361ff2ff0e1fb0

Test Plan

Place a socket in Atlas, try to build a building on top. Or something like that,,,

Event Timeline

Freagarach created this revision.Oct 18 2019, 10:47 PM
Owners added a subscriber: Restricted Owners Package.Oct 18 2019, 10:47 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/471/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpObstructionManager.h
|  53| class·ICmpObstructionManager·:·public·IComponent
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classICmpObstructionManager:' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpObstruction.h
|  29| class·ICmpObstruction·:·public·IComponent
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classICmpObstruction:' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpObstruction.cpp
|   1| /*·Copyright·(C)·2018·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2019" year instead of "2018"
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 153| 153| 	}
| 154| 154| 	else if (passClassName == "socket")
| 155| 155| 	{
| 156|    |-//		ret = cmpObstruction.CheckFoundation(passClassName, false, this.template.Socket);
|    | 156|+		//		ret = cmpObstruction.CheckFoundation(passClassName, false, this.template.Socket);
| 157| 157| //return result;
| 158| 158| 	}
| 159| 159| 	else
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 154| 154| 	else if (passClassName == "socket")
| 155| 155| 	{
| 156| 156| //		ret = cmpObstruction.CheckFoundation(passClassName, false, this.template.Socket);
| 157|    |-//return result;
|    | 157|+// return result;
| 158| 158| 	}
| 159| 159| 	else
| 160| 160| 	{
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 154| 154| 	else if (passClassName == "socket")
| 155| 155| 	{
| 156| 156| //		ret = cmpObstruction.CheckFoundation(passClassName, false, this.template.Socket);
| 157|    |-//return result;
|    | 157|+		//return result;
| 158| 158| 	}
| 159| 159| 	else
| 160| 160| 	{
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 235| 235| 		result.message = markForTranslation("%(name)s cannot be built in %(territoryType)s territory. Valid territories: %(validTerritories)s");
| 236| 236| 		result.translateParameters.push("territoryType");
| 237| 237| 		result.translateParameters.push("validTerritories");
| 238|    |-		result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory};
|    | 238|+		result.parameters.territoryType = { "context": "Territory type", "message": invalidTerritory};
| 239| 239| 		// gui code will join this array to a string
| 240| 240| 		result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories()};
| 241| 241| 		return result;	// Fail
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 235| 235| 		result.message = markForTranslation("%(name)s cannot be built in %(territoryType)s territory. Valid territories: %(validTerritories)s");
| 236| 236| 		result.translateParameters.push("territoryType");
| 237| 237| 		result.translateParameters.push("validTerritories");
| 238|    |-		result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory};
|    | 238|+		result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory };
| 239| 239| 		// gui code will join this array to a string
| 240| 240| 		result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories()};
| 241| 241| 		return result;	// Fail
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 237| 237| 		result.translateParameters.push("validTerritories");
| 238| 238| 		result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory};
| 239| 239| 		// gui code will join this array to a string
| 240|    |-		result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories()};
|    | 240|+		result.parameters.validTerritories = { "context": "Territory type list", "list": this.GetTerritories()};
| 241| 241| 		return result;	// Fail
| 242| 242| 	}
| 243| 243| 
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 237| 237| 		result.translateParameters.push("validTerritories");
| 238| 238| 		result.parameters.territoryType = {"context": "Territory type", "message": invalidTerritory};
| 239| 239| 		// gui code will join this array to a string
| 240|    |-		result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories()};
|    | 240|+		result.parameters.validTerritories = {"context": "Territory type list", "list": this.GetTerritories() };
| 241| 241| 		return result;	// Fail
| 242| 242| 	}
| 243| 243| 

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 166| »   »   switch·(ret)
|    | [NORMAL] ESLintBear (default-case):
|    | Expected a default case.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 268| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(id,·IID_Identity);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'cmpIdentity' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 277| »   »   »   »   let·result·=·markForPluralTranslation(
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'result' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 298| »   »   »   »   let·result·=·markForPluralTranslation(
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'result' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 188| »   var·cmpPlayer·=·QueryOwnerInterface(this.entity,·IID_Player);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 262| »   »   var·cmpRangeManager·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_RangeManager);
|    | [NORMAL] JSHintBear:
|    | 'cmpRangeManager' is already defined.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 263| »   »   var·cmpPlayer·=·QueryOwnerInterface(this.entity,·IID_Player);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/986/display/redirect

Stan added a subscriber: Stan.Oct 19 2019, 1:19 AM

The Settlement.js class should be updated/deleted/renamed :)

Some changes must be made to input js for snapping I guess .

I compleately overlooked Settlement.js,,,
A socket building only should check for the socket to exist and whether it is obstructed, not the type of terrain, IMHO.
Furthermore it should have a special check in BuildRestrictions.js, similar to the shore-check, whether the location is within a socket (cmpObstruction.CheckSlotPlacement(SlotTemplate)?).
Snapping should be indeed introduced and can (partly?) be reused from the wall snapping.

Freagarach edited the summary of this revision. (Show Details)
  • Renamed Settlement.js.
  • Every terrain as long as a socket exists (sockets not yet implemented).
  • cmpObstruction.CheckSocketPlacement(SlotTemplate). <- Not used yet.
Freagarach added inline comments.Oct 19 2019, 11:16 PM
source/simulation2/components/CCmpObstruction.cpp
612

This does not work :(

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/473/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/simulation2/components/ICmpObstructionManager.h
|  53| class·ICmpObstructionManager·:·public·IComponent
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classICmpObstructionManager:' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/tests/test_ObstructionManager.h
|  23| class·MockObstruction·:·public·ICmpObstruction
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classMockObstruction:' is invalid C code. Use --std or --language to configure the language.

source/simulation2/components/ICmpObstruction.h
|  29| class·ICmpObstruction·:·public·IComponent
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classICmpObstruction:' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 0.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|  13|  13| 			"</element>";
|  14|  14| 	}
|  15|  15| 
|  16|    |-/*
|    |  16|+	/*
|  17|  17|  * TODO: the vague plan is that this should keep track of who currently owns the settlement,
|  18|  18|  * and some other code can detect this (or get notified of changes) when it needs to.
|  19|  19|  * A civcenter's BuildRestrictions component will see that it's being built on this settlement,
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|  25|  25| 	Init()
|  26|  26| 	{
|  27|  27| 		this.owner = INVALID_PLAYER;
|  28|    |-	};
|    |  28|+	}
|  29|  29| 
|  30|  30| 	/**
|  31|  31| 	 * Initialises construction, thus rendering this socket useless.
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|  49|  49| 		cmpPosition.MoveOutOfWorld();
|  50|  50| 
|  51|  51| 		return true;
|  52|    |-	};
|    |  52|+	}
|  53|  53| 
|  54|  54| 	/**
|  55|  55| 	 * Resets this socket by setting the owner to -1 and moving back to its former position.
|    | [NORMAL] ESLintBear (no-extra-semi):
|    | Unnecessary semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/BuildSlot.js
|  67|  67| 
|  68|  68| 		cmpPosition.JumpTo(this.previousPosition.x, this.previousPosition.z);
|  69|  69| 		delete this.previousPosition;
|  70|    |-	};
|    |  70|+	}
|  71|  71| 
|  72|  72| 	/**
|  73|  73| 	 * Get the current owner.

binaries/data/mods/public/simulation/components/BuildSlot.js
|  28| »   };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/BuildSlot.js
|  52| »   };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/BuildSlot.js
|  70| »   };
|    | [NORMAL] JSHintBear:
|    | Unnecessary semicolon.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 173| »   »   switch·(ret)
|    | [NORMAL] ESLintBear (default-case):
|    | Expected a default case.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 280| »   »   »   var·cmpIdentity·=·Engine.QueryInterface(id,·IID_Identity);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'cmpIdentity' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 289| »   »   »   »   let·result·=·markForPluralTranslation(
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'result' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 310| »   »   »   »   let·result·=·markForPluralTranslation(
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'result' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 191| »   var·cmpPlayer·=·QueryOwnerInterface(this.entity,·IID_Player);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 274| »   »   var·cmpRangeManager·=·Engine.QueryInterface(SYSTEM_ENTITY,·IID_RangeManager);
|    | [NORMAL] JSHintBear:
|    | 'cmpRangeManager' is already defined.

binaries/data/mods/public/simulation/components/BuildRestrictions.js
| 275| »   »   var·cmpPlayer·=·QueryOwnerInterface(this.entity,·IID_Player);
|    | [NORMAL] JSHintBear:
|    | 'cmpPlayer' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/988/display/redirect

Freagarach planned changes to this revision.Mon, Nov 11, 12:12 PM

To js.