Commit 0bb339fc authored by James Smith's avatar James Smith

mining rig tweaks

parent 8daa36f8
......@@ -22,6 +22,8 @@ public class MapInfo {
private String mapSize = "";
@NotNull
public float realMapSize = 0;
@NotNull
public int baseIncome = 0;
@NotNull
private String[] factions = new String[0];
......@@ -94,6 +96,14 @@ public class MapInfo {
this.spawnDist = spawnDist;
}
public int getBaseIncome() {
return baseIncome;
}
public void setBaseIncome(int baseIncome) {
this.baseIncome = baseIncome;
}
@NotNull
public String[] getFactions()
{
......
......@@ -16,6 +16,7 @@ objective3 = ""
spawnDist = "0.9"
mapSize = "75000"
factions = [ "Red, (1f,0f,0f,1f)", "Blue, (0f,0f,1f,1f)" ]
baseIncome = 10
#Starting ships for Blue Faction
......
[miner]
speed = 2
speed = 2.5
[power]
powerConsumption = 10
......
package com.drakelinglabs.ironarmada.server.system;
import com.artemis.Aspect;
import com.artemis.BaseSystem;
import com.artemis.ComponentMapper;
import com.artemis.annotations.Wire;
import com.artemis.systems.IteratingSystem;
import com.artemis.utils.IntBag;
import com.badlogic.gdx.math.Vector2;
import com.drakelinglabs.ironarmada.client.component.TileAnimation;
import com.drakelinglabs.ironarmada.common.PrefabSys;
import com.drakelinglabs.ironarmada.common.component.*;
import com.drakelinglabs.ironarmada.common.prefab.Prefab;
import com.drakelinglabs.ironarmada.common.system.NetSys;
import com.drakelinglabs.ironarmada.common.system.PlanetProximitySys;
import com.drakelinglabs.ironarmada.common.system.ShipSys;
import com.drakelinglabs.ironarmada.common.system.ZoneSystem;
import com.drakelinglabs.ironarmada.common.tile.Tile;
import com.drakelinglabs.ironarmada.common.tile.TileArray;
import com.drakelinglabs.ironarmada.common.tile.TileStatus;
import java.util.ArrayList;
public class ResourceSystem extends IteratingSystem {
@Wire
......@@ -25,6 +33,8 @@ public class ResourceSystem extends IteratingSystem {
private ZoneSystem zoneSystem;
@Wire
private PlanetProximitySys planetProximity;
@Wire
private PrefabSys prefabSys;
@Wire
private ComponentMapper<Miner> mMiner;
......@@ -42,16 +52,25 @@ public class ResourceSystem extends IteratingSystem {
private ComponentMapper<Capturable> mCapturable;
@Wire
private ComponentMapper<Faction> mFaction;
@Wire
private ComponentMapper<Ship> mShip;
private String[] resourceNames;
private int[] resources;
public ResourceSystem() {
super(Aspect.all(Miner.class));
}
@Override
protected void initialize() {
baseIncome = prefabSys.getPrefabManager().get(mode.mapName).getBackgroundSpawner().getMapInfo().getBaseIncome();
}
private float elapsedTime;
private int payThisTick;
private int baseIncome;
private float miningSpeed;
@Override
protected void begin()
......@@ -59,12 +78,17 @@ public class ResourceSystem extends IteratingSystem {
super.begin();
elapsedTime += world.getDelta();
payThisTick = 0;
while(elapsedTime > 1){
while(elapsedTime > miningSpeed){
payThisTick += 10;
elapsedTime--;
elapsedTime = 0;
}
}
@Override
protected void inserted(int entityId) {
miningSpeed = mMiner.get(entityId).getSpeed();
}
@Override
protected void process(int entityId) {
if(payThisTick > 0) {
......@@ -83,9 +107,11 @@ public class ResourceSystem extends IteratingSystem {
int resourceCapacity = mResources.get(eShip).getCapacity()[resource];
// if the capacity for the resource is 0, skip it since we have nowhere to store it
if(resourceCapacity <= 0)
if (resourceCapacity <= 0)
continue;
payThisTick = baseIncome / 2;
//if the resource amount is less than we can carry and the resource amount + mined amount is less than we can carry
if (resourceAmount < resourceCapacity) {
mResources.get(eShip).addResource(resource, payThisTick);
......@@ -98,6 +124,23 @@ public class ResourceSystem extends IteratingSystem {
}
}
public int numberOfMinersForPlanet(int ePlanet) {
ArrayList<Integer> ships = zoneSystem.getShipsInZone(zoneSystem.getZone(mPosition.get(ePlanet).get()));
int numberOfMiners = 0;
for(int i = 0; i < ships.size(); i++) {
Ship ship = mShip.get(ships.get(i));
TileArray tiles = ship.getTiles();
for(Tile t : tiles.getListUnsafe()) {
if(t.getDef().getPrefab() != null) {
Prefab p = prefabSys.getPrefabManager().get(t.getDef().getPrefab());
if (p.getMiner() != null)
numberOfMiners++;
}
}
}
return numberOfMiners;
}
public int[] getResourceCapacity() {
int[] capacity = new int[resources.length];
for(int i = 0; i < capacity.length; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment