This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 588d23b
Showing
28 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text eol=lf | ||
*.jar binary | ||
* linguist-detectable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Update Github repository information | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Update Github repo info | ||
uses: Darkborderman/github-actions/github-repo-info@master | ||
env: | ||
YML_PATH: metadata.yml | ||
GH_TOKEN: ${{ secrets.PAT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.gradle/ | ||
build/ | ||
|
||
# artifacts | ||
jars/ | ||
bins/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"java.project.sourcePaths": ["src"], | ||
"java.project.referencedLibraries": ["libs/*.jar"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Darkborderman | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Starsector-ReverseEngineering | ||
|
||
Reverse engineering owned ships, weapons, and fighters easily in Starsector. | ||
|
||
## Mod archived | ||
|
||
### The mod has been integrated into [Starsector-IndustryOverhaul](https://github.com/DarkbordermanModding/Starsector-IndustryOverhaul) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apply plugin: 'java' | ||
|
||
// project level config | ||
sourceSets.main.java.srcDir 'src' | ||
sourceCompatibility = 1.7 | ||
targetCompatibility = 1.7 | ||
archivesBaseName = 'reverseengineering' | ||
|
||
build { | ||
doLast { | ||
copy { | ||
from jar | ||
into 'jars' | ||
} | ||
} | ||
} | ||
|
||
task release(type: Zip) { | ||
description 'Create releaseable zip file.' | ||
def cmdOutput = 'jq -rj .version mod_info.json'.execute().text | ||
from '.' | ||
include 'src/' | ||
include 'data/' | ||
include 'graphics/' | ||
include 'sounds/' | ||
include 'jars/' | ||
include 'mod_info.json' | ||
archiveName archivesBaseName + '-' + cmdOutput + '.zip' | ||
destinationDir(file('bins/')) | ||
} | ||
|
||
clean { | ||
description 'Cleanup files' | ||
delete fileTree('jars/') { include '*.jar' } | ||
delete fileTree('bins/') { include '*.zip' } | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: './libs/', include: '*.jar') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,faction,desc,script,icon,order | ||
reverse_engineering,Reverse Engineering,player,"Ship conversions using Kassadari tech are usually performed on order only, but if one knows where to ask, there is a market here for old and damaged hulls that are no longer suitable for service in the Kassadari fleet.",mod.reverseengineering.campaign.submarkets.REMarketPlugin,,801 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
github: | ||
description: Reverse engineering owned ships, weapons, and fighters easily in Starsector. | ||
enable_discussions: false | ||
enable_issues: false | ||
enable_projects: false | ||
enable_wiki: false | ||
homepage: https://github.com/DarkbordermanModding/Starsector-ReverseEngineering | ||
template: false | ||
topics: | ||
- mod | ||
- starsector | ||
- starsector-mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id":"darkborderman.reverseengineering", | ||
"name":"Reverse Engineering", | ||
"author":"Darkborderman", | ||
"version":"0.0.0", | ||
"description":"Reverse engineering owned ships, weapons, and fighters easily.", | ||
"gameVersion":"0.97a-RC11", | ||
"jars":["jars/reverseengineering.jar"], | ||
"modPlugin":"mod.ReverseEngineeringPlugin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mod; | ||
|
||
import com.fs.starfarer.api.BaseModPlugin; | ||
import com.fs.starfarer.api.Global; | ||
import com.fs.starfarer.api.campaign.SectorEntityToken; | ||
import org.apache.log4j.Level; | ||
import org.apache.log4j.Logger; | ||
import mod.reverseengineering.ReverseEngineeringScript; | ||
|
||
public class ReverseEngineeringPlugin extends BaseModPlugin | ||
{ | ||
private static Logger logger = Global.getLogger(ReverseEngineeringPlugin.class); | ||
|
||
public void onGameLoad(boolean newGame) { | ||
logger.log(Level.INFO, "---Terraforming Platform, best platform---"); | ||
SectorEntityToken neturalPlatform = Global.getSector().getEntityById("corvus_abandoned_station"); | ||
if(newGame){ | ||
neturalPlatform.getMarket().addSubmarket("reverse_engineering"); | ||
} | ||
if (!Global.getSector().hasScript(ReverseEngineeringScript.class)) { | ||
Global.getSector().addScript(new ReverseEngineeringScript()); | ||
} | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/mod/reverseengineering/ReverseEngineeringScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package mod.reverseengineering; | ||
|
||
import org.apache.log4j.Level; | ||
import org.apache.log4j.Logger; | ||
|
||
import com.fs.starfarer.api.EveryFrameScript; | ||
import com.fs.starfarer.api.fleet.FleetMemberAPI; | ||
import com.fs.starfarer.api.impl.campaign.ids.Items; | ||
import com.fs.starfarer.api.impl.campaign.ids.Submarkets; | ||
|
||
import com.fs.starfarer.api.Global; | ||
import com.fs.starfarer.api.campaign.CampaignClockAPI; | ||
import com.fs.starfarer.api.campaign.CargoStackAPI; | ||
import com.fs.starfarer.api.campaign.FleetDataAPI; | ||
import com.fs.starfarer.api.campaign.SectorEntityToken; | ||
import com.fs.starfarer.api.campaign.SpecialItemData; | ||
import com.fs.starfarer.api.campaign.CargoAPI.CargoItemQuantity; | ||
import com.fs.starfarer.api.campaign.econ.SubmarketAPI; | ||
import com.fs.starfarer.api.combat.ShipHullSpecAPI; | ||
|
||
|
||
public class ReverseEngineeringScript implements EveryFrameScript{ | ||
public boolean firstHour = true; | ||
public int lastHourChecked = 0; | ||
public boolean firstDay = true; | ||
public int lastDayChecked = 0; | ||
public boolean firstMonth = true; | ||
public int lastMonthChecked = 0; | ||
private static Logger logger = Global.getLogger(ReverseEngineeringScript.class); | ||
|
||
public boolean isDone() {return false;} | ||
|
||
public boolean runWhilePaused() {return false;} | ||
|
||
// Remove Dmods and others, get base blueprint hull | ||
private ShipHullSpecAPI getBaseShipHullSpec(ShipHullSpecAPI spec) { | ||
ShipHullSpecAPI base = spec.getDParentHull(); | ||
if (!spec.isDefaultDHull() && !spec.isRestoreToBase()) { | ||
base = spec; | ||
} | ||
if (spec.isRestoreToBase()) { | ||
base = spec.getBaseHull(); | ||
} | ||
return base; | ||
} | ||
|
||
// Check a hour passed or not | ||
private boolean newHour(){ | ||
CampaignClockAPI clock = Global.getSector().getClock(); | ||
if (firstHour) { | ||
lastHourChecked = clock.getHour(); | ||
firstHour = false; | ||
return false; | ||
} else if (clock.getHour() != lastHourChecked) { | ||
lastHourChecked = clock.getHour(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
// Check a month passed or not | ||
private boolean newMonth() { | ||
CampaignClockAPI clock = Global.getSector().getClock(); | ||
if (firstMonth) { | ||
lastMonthChecked = clock.getMonth(); | ||
firstMonth = false; | ||
return false; | ||
} else if (clock.getMonth() != lastMonthChecked) { | ||
lastMonthChecked = clock.getMonth(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void advance(float var1){ | ||
// Reverse engineering weapon/fighters/ships each hour | ||
if (newHour()){ | ||
SectorEntityToken neturalPlatform = Global.getSector().getEntityById("corvus_abandoned_station"); | ||
SubmarketAPI reverseEngineeringMarket = neturalPlatform.getMarket().getSubmarket("reverse_engineering"); | ||
SubmarketAPI storage = neturalPlatform.getMarket().getSubmarket(Submarkets.SUBMARKET_STORAGE); | ||
|
||
if(!reverseEngineeringMarket.getCargo().getWeapons().isEmpty()){ | ||
String weaponId = ""; | ||
int weaponCount = 0; | ||
for(CargoItemQuantity<String> weapon: reverseEngineeringMarket.getCargo().getWeapons()){ | ||
weaponId = weapon.getItem(); | ||
weaponCount = weapon.getCount(); | ||
break; | ||
} | ||
reverseEngineeringMarket.getCargo().removeWeapons(weaponId, weaponCount); | ||
SpecialItemData data = new SpecialItemData(Items.WEAPON_BP, weaponId); | ||
storage.getCargo().addSpecial(data, weaponCount); | ||
} | ||
if(!reverseEngineeringMarket.getCargo().getFighters().isEmpty()){ | ||
String fighterId = ""; | ||
int fighterCount = 0; | ||
for(CargoItemQuantity<String> fighter: reverseEngineeringMarket.getCargo().getFighters()){ | ||
fighterId = fighter.getItem(); | ||
fighterCount = fighter.getCount(); | ||
break; | ||
} | ||
reverseEngineeringMarket.getCargo().removeFighters(fighterId, fighterCount); | ||
SpecialItemData data = new SpecialItemData(Items.FIGHTER_BP, fighterId); | ||
storage.getCargo().addSpecial(data, fighterCount); | ||
} | ||
FleetDataAPI storedShips = reverseEngineeringMarket.getCargo().getMothballedShips(); | ||
if (!storedShips.getMembersListCopy().isEmpty()){ | ||
String blueprintId = ""; | ||
for(FleetMemberAPI ship: storedShips.getMembersListCopy()){ | ||
blueprintId = getBaseShipHullSpec(ship.getHullSpec()).getHullId(); | ||
storedShips.removeFleetMember(ship); | ||
break; | ||
} | ||
//add the blueprint to storage | ||
SpecialItemData data = new SpecialItemData(Items.SHIP_BP, blueprintId); | ||
storage.getCargo().addSpecial(data, 1); | ||
} | ||
} | ||
// Cleanup blueprint stack each month | ||
if(newMonth()){ | ||
SectorEntityToken neturalPlatform = Global.getSector().getEntityById("corvus_abandoned_station"); | ||
SubmarketAPI reverseEngineeringMarket = neturalPlatform.getMarket().getSubmarket("reverse_engineering"); | ||
for(CargoStackAPI stack: reverseEngineeringMarket.getCargo().getStacksCopy()){ | ||
if(stack.getSpecialDataIfSpecial() != null){ | ||
String specialId = stack.getSpecialDataIfSpecial().getId(); | ||
if(specialId.equals("fighter_bp") || specialId.equals("ship_bp") || specialId.equals("weapon_bp")){ | ||
// TODO: Separate each blueprint (weapon, fighter, hull) price | ||
float blueprintCredit = 500f; | ||
logger.log(Level.INFO, stack.getSpecialDataIfSpecial().getData()); | ||
logger.log(Level.INFO, stack.getSize()); | ||
logger.log(Level.INFO, stack.getSpecialDataIfSpecial().getId()); | ||
Global.getSector().getPlayerFleet().getCargo().getCredits().add(blueprintCredit * stack.getSize()); | ||
reverseEngineeringMarket.getCargo().removeStack(stack); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/mod/reverseengineering/campaign/submarkets/REMarketPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mod.reverseengineering.campaign.submarkets; | ||
|
||
import com.fs.starfarer.api.campaign.*; | ||
import com.fs.starfarer.api.campaign.econ.SubmarketAPI; | ||
import com.fs.starfarer.api.fleet.FleetMemberAPI; | ||
import com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin; | ||
|
||
public class REMarketPlugin extends BaseSubmarketPlugin { | ||
|
||
@Override | ||
public void init(SubmarketAPI submarket) {super.init(submarket);} | ||
|
||
@Override | ||
public float getTariff() {return 0f;} | ||
|
||
@Override | ||
public boolean isFreeTransfer() {return true;} | ||
|
||
@Override | ||
public String getBuyVerb() {return "Take";} | ||
|
||
@Override | ||
public String getSellVerb() {return "Leave";} | ||
|
||
@Override | ||
public boolean isEnabled(CoreUIAPI ui) {return true;} | ||
|
||
@Override | ||
public boolean isParticipatesInEconomy() {return false;} | ||
|
||
@Override | ||
public void updateCargoPrePlayerInteraction() { | ||
return; | ||
} | ||
|
||
@Override | ||
public boolean isIllegalOnSubmarket(CargoStackAPI stack, TransferAction action) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isIllegalOnSubmarket(String commodityId, TransferAction action) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isIllegalOnSubmarket(FleetMemberAPI member, TransferAction action) { | ||
return false; | ||
} | ||
} |