-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add component and tech for gravitational surveys
Update JPSurveyableDB to use the same format as GeoSurveyableDB
- Loading branch information
1 parent
43bfabf
commit b1898cc
Showing
8 changed files
with
151 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Newtonsoft.Json; | ||
using Pulsar4X.Components; | ||
using Pulsar4X.Datablobs; | ||
using Pulsar4X.Engine; | ||
using Pulsar4X.Interfaces; | ||
|
||
namespace Pulsar4X.Atb; | ||
|
||
public class GravSurveyAtb : IComponentDesignAttribute | ||
{ | ||
[JsonProperty] | ||
public uint Speed { get; set; } = 1; | ||
|
||
public GravSurveyAtb(int speed) | ||
{ | ||
Speed = (uint)speed; | ||
} | ||
|
||
public void OnComponentInstallation(Entity parentEntity, ComponentInstance componentInstance) | ||
{ | ||
if(parentEntity.TryGetDatablob<GravSurveyAbilityDB>(out var gravSurveyAbilityDB)) | ||
{ | ||
gravSurveyAbilityDB.Speed += Speed; | ||
} | ||
else | ||
{ | ||
parentEntity.SetDataBlob<GravSurveyAbilityDB>(new GravSurveyAbilityDB() { Speed = Speed }); | ||
} | ||
} | ||
|
||
public void OnComponentUninstallation(Entity parentEntity, ComponentInstance componentInstance) | ||
{ | ||
if(parentEntity.TryGetDatablob<GravSurveyAbilityDB>(out var gravSurveyAbilityDB)) | ||
{ | ||
if(Speed >= gravSurveyAbilityDB.Speed) | ||
{ | ||
parentEntity.RemoveDataBlob<GravSurveyAbilityDB>(); | ||
} | ||
else | ||
{ | ||
gravSurveyAbilityDB.Speed -= Speed; | ||
} | ||
} | ||
} | ||
|
||
public string AtbName() | ||
{ | ||
return "Gravitational Surveyor"; | ||
} | ||
|
||
public string AtbDescription() | ||
{ | ||
return $"Speed {Speed}"; | ||
} | ||
} |
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,9 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Pulsar4X.Datablobs; | ||
|
||
public class GravSurveyAbilityDB : BaseDataBlob | ||
{ | ||
[JsonProperty] | ||
public uint Speed { get; set; } | ||
} |
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