-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Raft returning back to the island after looting; Added shipwrec…
…k resources spawner once in a hour;
- Loading branch information
Showing
11 changed files
with
129 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package constants | ||
|
||
const ( | ||
ShipwreckMinWoodAmount = 5 | ||
ShipwreckMaxWoodAmount = 10 | ||
ShipwreckMinWoodAmount = 50 | ||
ShipwreckMaxWoodAmount = 100 | ||
) | ||
|
||
const ( | ||
ShipwreckMinStoneAmount = 5 | ||
ShipwreckMaxStoneAmount = 10 | ||
ShipwreckMinStoneAmount = 50 | ||
ShipwreckMaxStoneAmount = 100 | ||
) | ||
|
||
const ( | ||
ShipwreckMinFishAmount = 5 | ||
ShipwreckMaxFishAmount = 10 | ||
ShipwreckMinFishAmount = 50 | ||
ShipwreckMaxFishAmount = 100 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package system | ||
|
||
import ( | ||
"pkg.world.dev/world-engine/cardinal" | ||
"pkg.world.dev/world-engine/cardinal/search/filter" | ||
"pkg.world.dev/world-engine/cardinal/types" | ||
|
||
comp "oceanus-shard/component" | ||
"oceanus-shard/constants" | ||
) | ||
|
||
// ShipwreckResourcesSpawner - | ||
func ShipwreckResourcesSpawner(world cardinal.WorldContext) error { | ||
return cardinal.NewSearch().Entity( | ||
filter.Contains(filter.Component[comp.Player](), filter.Component[comp.ShipwreckResources]())). | ||
Each(world, func(id types.EntityID) bool { | ||
shipwreckResources, _ := cardinal.GetComponent[comp.ShipwreckResources](world, id) | ||
if (shipwreckResources.LastSpawnTime + | ||
uint64(constants.ShipwreckResourcesRespawnInterval.Milliseconds())) < world.Timestamp() { | ||
return true | ||
} | ||
if shipwreckResources.Resources != nil { | ||
return true | ||
} | ||
|
||
shipWreckResources := make([]comp.Resource, len(comp.GetShipwreckResourceTypes())) | ||
for i, resourceType := range comp.GetShipwreckResourceTypes() { | ||
shipWreckResources[i] = comp.Resource{ | ||
Type: resourceType, | ||
Amount: comp.GetShipwreckDefaultResourceAmount(resourceType), | ||
} | ||
} | ||
shipwreckResources.Resources = &shipWreckResources | ||
_ = cardinal.SetComponent(world, id, shipwreckResources) | ||
return true | ||
}) | ||
} |