Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkborderman committed Sep 7, 2024
0 parents commit 588d23b
Show file tree
Hide file tree
Showing 28 changed files with 336 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text eol=lf
*.jar binary
* linguist-detectable
18 changes: 18 additions & 0 deletions .github/workflows/github-repo-info.yml
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 }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gradle/
build/

# artifacts
jars/
bins/
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.project.sourcePaths": ["src"],
"java.project.referencedLibraries": ["libs/*.jar"]
}
21 changes: 21 additions & 0 deletions LICENSE
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.
7 changes: 7 additions & 0 deletions README.md
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)
40 changes: 40 additions & 0 deletions build.gradle
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')
}
2 changes: 2 additions & 0 deletions data/campaign/submarkets.csv
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 added libs/commons-compiler-jdk.jar
Binary file not shown.
Binary file added libs/commons-compiler.jar
Binary file not shown.
Binary file added libs/fs.common_obf.jar
Binary file not shown.
Binary file added libs/fs.sound_obf.jar
Binary file not shown.
Binary file added libs/janino.jar
Binary file not shown.
Binary file added libs/jinput.jar
Binary file not shown.
Binary file added libs/jogg-0.0.7.jar
Binary file not shown.
Binary file added libs/jorbis-0.0.15.jar
Binary file not shown.
Binary file added libs/json.jar
Binary file not shown.
Binary file added libs/log4j-1.2.9.jar
Binary file not shown.
Binary file added libs/lwjgl.jar
Binary file not shown.
Binary file added libs/lwjgl_util.jar
Binary file not shown.
Binary file added libs/starfarer.api.jar
Binary file not shown.
Binary file added libs/starfarer_obf.jar
Binary file not shown.
Binary file added libs/xstream-1.4.10.jar
Binary file not shown.
12 changes: 12 additions & 0 deletions metadata.yml
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
10 changes: 10 additions & 0 deletions mod_info.json
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"
}
24 changes: 24 additions & 0 deletions src/mod/ReverseEngineeringPlugin.java
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 src/mod/reverseengineering/ReverseEngineeringScript.java
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 src/mod/reverseengineering/campaign/submarkets/REMarketPlugin.java
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;
}
}

0 comments on commit 588d23b

Please sign in to comment.