Page MenuHomeWildfire Games

Prototype inheritance for Trigger scripts
AbandonedPublic

Authored by elexis on Jun 10 2017, 6:27 PM.

Details

Reviewers
None
Summary

See #4628.

Test Plan

Serialization should be considered especially.

Event Timeline

elexis created this revision.Jun 10 2017, 6:27 PM
elexis planned changes to this revision.Jun 10 2017, 6:28 PM

This is only a proof of concept yet

Vulcan added a subscriber: Vulcan.Jun 10 2017, 7:05 PM
Executing section Default...
Executing section Source...
Executing section JS...

binaries/data/mods/public/simulation/components/Trigger_Regicide.js
|  34| »   »   ····playersCivs.every(civ·=>·civ·!=·identity.Civ))
|    | [NORMAL] JSHintBear:
|    | Don't make functions within a loop.

binaries/data/mods/public/simulation/components/Trigger_Regicide.js
|  67| »   »   let·spawnPoints·=·cmpRangeManager.GetEntitiesByPlayer(playerID).sort((entity1,·entity2)·=>
|    | [NORMAL] JSHintBear:
|    | Don't make functions within a loop.

binaries/data/mods/public/simulation/components/Trigger_Regicide.js
|  74| »   »   »   let·distanceToShip·=·entity·=>
|    | [NORMAL] JSHintBear:
|    | Don't make functions within a loop.

binaries/data/mods/public/simulation/components/Trigger_Regicide.js
|  76| »   »   »   spawnPoints·=·TriggerHelper.GetLandSpawnPoints().sort((entity1,·entity2)·=>
|    | [NORMAL] JSHintBear:
|    | Don't make functions within a loop.
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/171/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jw:8080/job/phabricator/1531/ for more details.

How is that different (or better) than just making this a component? (Since from a quick glance you don't really need anything from cmpTrigger for this.)

Then the trigger component could be deleted, because there's nothing useful in it, is it?

In D626#25603, @elexis wrote:

Then the trigger component could be deleted, because there's nothing useful in it, is it?

No, that one should be left since it aims to provide a somewhat simplified way to add code.

In D626#25601, @leper wrote:

How is that different (or better) than just making this a component? (Since from a quick glance you don't really need anything from cmpTrigger for this.)

The question would be whether we want

  • the victory condition and map scripts to remain exemplary uses of Trigger scripts (in which case we should use inheritance)
  • or don't use inheritance and remove the unused Trigger component
  • or don't use inheritance and leave the unused Trigger component for any remaining use-case that should be pointed out

If it's the former and if we want to fix the naming conflict issue, then the new Trigger scripts should inherit and use the the inherited file (not because the code needs it, but to remain an example to modders).

In D626#25604, @leper wrote:

No, that one (Trigger.js) should be left since it aims to provide a somewhat simplified way to add code.

The only simplification I could find is having example trigger scripts and a list of usable events in one place.

Wasn't it also about adding an interface that can be accessed from Atlas? (IIRC I've seen an example or actual GUI on old (wfg?) screenshots Vladislav had shown me somewhere).
Though that might need custom/external code, not that specific Trigger cmp code we currently have.
So if we want to keep any benefit (and maintenance costs) of that Trigger component, then we could still use prototype inheritance.

elexis abandoned this revision.Dec 12 2017, 8:41 PM