Skip to content

Commit

Permalink
Power Cells and Power Cell Press (#370)
Browse files Browse the repository at this point in the history
* Power Cells

*added textures for press and cells
*added xml for press and cells
*rendering of press does not work properly don't know why
*Press job is at the moment just a dummy, have to find out why the job breaks the game

* [WIP] Power Cells

*added textures for press and cells
*added xml for press and cells
*rendering of press does not work properly don't know why
*Press job is at the moment just a dummy, have to find out why the job breaks the game

* Update JobSpriteController.cs

Don't know why it was there

* Updated Power Cell

* Sprite of press is loaded
* added job for press
* press takes steel and outputs power cells

* Localisation

* added Localisation for en_US

* Revert "Update JobSpriteController.cs"

This reverts commit 724c7c8.

* Added the right param

* Added the right param in funiture.lua
* fixed the indention from furniture.xml

* Added the right param

* Added the right param in funiture.lua
* fixed the indention from furniture.xml

* Idention Fix

* indention fix for Furniture.xml

* Idention Fix

* indention fix for Furniture.xml

* Update JobSpriteController.cs
  • Loading branch information
Xeni91 authored and vogonistic committed Aug 22, 2016
1 parent 21efb24 commit df7ae02
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 1 deletion.
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 @@ -287,6 +287,68 @@ function MetalSmelter_JobWorked(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 @@ -48,5 +48,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.

0 comments on commit df7ae02

Please sign in to comment.