Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power Cells and Power Cell Press #370

Merged
merged 18 commits into from
Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Scripts/Controllers/JobSpriteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void Start()
{
jobGameObjectMap = new Dictionary<Job, GameObject>();
fsc = GameObject.FindObjectOfType<FurnitureSpriteController>();

WorldController.Instance.world.jobQueue.cbJobCreated += OnJobCreated;
}

Expand Down
21 changes: 21 additions & 0 deletions Assets/StreamingAssets/Data/Furniture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@
<LocalizationCode>furn_metal_smelter</LocalizationCode>
<UnlocalizedDescription>furn_metal_smelter_desc</UnlocalizedDescription>
</Furniture>

<Furniture objectType="Power Cell Press">
<Name>Power Cell Press</Name>
<Description>A press that converts steel plate and something into power cells.</Description>
<MovementCost>1</MovementCost>
<Width>2</Width>
<Height>2</Height>

<BuildingJob jobTime="1"/>

<Params>
<Param name="presstime" value="0" />
<Param name="presstime_required" value="15" />
</Params>

<OnUpdate FunctionName="PowerCellPress_UpdateAction" />

<LocalizationCode>furn_power_cell_press</LocalizationCode>
<UnlocalizedDescription>furn_power_cell_press_desc</UnlocalizedDescription>

</Furniture>

<Furniture objectType="Small Landing Pad">
<Name>Small Landing Pad</Name>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/StreamingAssets/Images/Furniture/Power Cell Press.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Sprites>
<Sprite name="Power Cell Press" x="0" y="0" w="128" h="128" pixelPerUnit="64" />
</Sprites>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions Assets/StreamingAssets/Images/Inventory/Power Cell.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/StreamingAssets/Images/Inventory/PowerCell.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Sprites>
<Sprite name="Power Cell" x="0" y="0" w="128" h="128" pixelPerUnit="128" />
</Sprites>
8 changes: 8 additions & 0 deletions Assets/StreamingAssets/Images/Inventory/PowerCell.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions Assets/StreamingAssets/LUA/Furniture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,68 @@ function MetalSmelter_JobComplete(j)
end
end

function PowerCellPress_UpdateAction(furniture, deltaTime)
spawnSpot = furniture.GetSpawnSpotTile()

if(spawnSpot.inventory == nil) then
if(furniture.JobCount() == 0) then
itemsDesired = {Inventory.__new("Steel Plate", 10, 0)}

jobSpot = furniture.GetJobSpotTile()

j = Job.__new(
jobSpot,
nil,
nil,
1,
itemsDesired,
Job.JobPriority.Medium,
false
)

j.RegisterJobCompletedCallback("PowerCellPress_JobComplete")

furniture.AddJob(j)
end
else
furniture.ChangeParameter("presstime", deltaTime)

if(furniture.GetParameter("presstime") >= furniture.GetParameter("presstime_required")) then
furniture.SetParameter("presstime", 0)

outputSpot = World.current.GetTileAt(spawnSpot.X+2, spawnSpot.y)

if(outputSpot.inventory == nil) then
World.current.inventoryManager.PlaceInventory( outputSpot, Inventory.__new("Power Cell", 5, 1) )

spawnSpot.inventory.stackSize = spawnSpot.inventory.stackSize-10
else
if(outputSpot.inventory.stackSize <= 4) then
outputSpot.inventory.stackSize = outputSpot.inventory.stackSize+1

spawnSpot.inventory.stackSize = spawnSpot.inventory.stackSize-10
end
end

if(spawnSpot.inventory.stackSize <= 0) then
spawnSpot.inventory = nil
end
end
end
end

function PowerCellPress_JobComplete(j)
spawnSpot = j.tile.furniture.GetSpawnSpotTile()

for k, inv in pairs(j.inventoryRequirements) do
if(inv.stackSize > 0) then
World.current.inventoryManager.PlaceInventory(spawnSpot, inv)

return
end
end
end

function CloningPod_UpdateAction(furniture, deltaTime)

if( furniture.JobCount() > 0 ) then
Expand Down
2 changes: 2 additions & 0 deletions Assets/StreamingAssets/Localization/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ furn_cloning_pod=Cloning Pod
furn_cloning_pod_desc=Creates an additional worker, then is destroyed.
furn_power_generator=Power Generator
furn_power_generator_desc=Generates power out of nothing.
furn_power_cell_press=Power Cell Press
furn_power_cell_press_desc=Presses metal and flux into Power Cells
furn_small_landing_pad=Small Landing Pad
furn_small_landing_pad_desc=A landing pad for small spaceboats to land.