Skip to content

Commit

Permalink
[Done]New cloning pod With Animation (#1005)
Browse files Browse the repository at this point in the history
* adding new cloning pod sprite

* [WIP] Trying to get animation to work

* More Changes. Still does not work, but at least no errors. Cannot get the sprite to update

* Ok. We have basic animation working now. :) Not 100% yet

* Now the animation works. This code is not 100% but it functions and that is what matters now

* Some code cleanup.

* Updated cloning_pod.xml to be in line with the new xml format for sprites.

* Optimization by @TomMalbran and some more cleanup

* Fix for error and fixedx timer

* Slowed animation for tranbaby
  • Loading branch information
longtomjr authored and alexanderfast committed Aug 29, 2016
1 parent 8a06e5e commit 2383c87
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Assets/StreamingAssets/Data/Furniture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
</Furniture>


<Furniture objectType="Cloning Pod">
<Furniture objectType="cloning_pod">
<Name>Cloning Pod</Name>
<Description>Creates an additional worker, then is destroyed.</Description>
<MovementCost>50</MovementCost>
Expand All @@ -228,10 +228,16 @@
<Inventory objectType="Steel Plate" amount="15" />
</DeconstructJob>

<Params>
<Param name="animationTimer" value="1" />
<Param name="animationStep" value="0" />
</Params>

<JobSpotOffset X="0" Y="-1" />
<JobSpawnSpotOffset X="1" Y="-1" />

<Action event="OnUpdate" functionName="CloningPod_UpdateAction" />
<GetSpriteName FunctionName="CloningPod_GetSpriteName" />

<LocalizationCode>furn_cloning_pod</LocalizationCode>
<UnlocalizedDescription>furn_cloning_pod_desc</UnlocalizedDescription>
Expand Down
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/Furniture/cloning_pod.png.meta

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

6 changes: 6 additions & 0 deletions Assets/StreamingAssets/Images/Furniture/cloning_pod.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Sprites>
<Sprite name="cloning_pod_0" x="0" y="4" w="2" h="4" pixelPerUnit="32" />
<Sprite name="cloning_pod_1" x="2" y="4" w="2" h="4" pixelPerUnit="32" />
<Sprite name="cloning_pod" x="0" y="0" w="2" h="4" pixelPerUnit="32" />
</Sprites>
8 changes: 8 additions & 0 deletions Assets/StreamingAssets/Images/Furniture/cloning_pod.xml.meta

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

20 changes: 20 additions & 0 deletions Assets/StreamingAssets/LUA/Furniture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,31 @@ function CloningPod_UpdateAction(furniture, deltaTime)
false
)

j.RegisterJobWorkedCallback("CloningPod_JobRunning")
j.RegisterJobCompletedCallback("CloningPod_JobComplete")
j.JobDescription = "job_cloning_pod_cloning_desc"
furniture.AddJob(j)
end

function CloningPod_JobRunning(j)
local step = 0
if (math.floor(math.abs(j.JobTime * j.furniture.Parameters["animationTimer"].ToFloat())) % 2 == 0) then
step = 1
end
if (j.furniture.Parameters["animationStep"].ToFloat() != step) then
j.furniture.Parameters["animationStep"].SetValue(step)
j.furniture.UpdateOnChanged(j.furniture)
end
end

function CloningPod_GetSpriteName(furniture)
local baseName = "cloning_pod"
if (furniture.JobCount() < 1) then
return baseName
end
return baseName .. "_" .. furniture.Parameters["animationStep"].ToFloat()
end

function CloningPod_JobComplete(j)
World.Current.CreateCharacter(j.furniture.GetSpawnSpotTile())
j.furniture.Deconstruct()
Expand Down

0 comments on commit 2383c87

Please sign in to comment.