-
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.
feat: added linear falloff of .05f per second
- Loading branch information
1 parent
55b3416
commit bc90c41
Showing
4 changed files
with
47 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
namespace Server.Web.Models; | ||
public class ResourcesModel | ||
public class SendResourceModel | ||
{ | ||
public int Oxygen { get; set; } = UpperBounds; | ||
public int Electricity { get; set; } = UpperBounds; | ||
public int Fuel { get; set; } = UpperBounds; | ||
public int Water { get; set; } = UpperBounds; | ||
private readonly ResourcesModel _model; | ||
|
||
public const int UpperBounds = 100; | ||
public SendResourceModel(ResourcesModel model) => _model = model; | ||
|
||
public bool Depleated() => | ||
Oxygen <= 0 || Electricity <= 0 || Fuel <= 0 || Water <= 0; | ||
public SendResourceModel() { } | ||
|
||
public void EnsureBounds() | ||
{ | ||
if (Oxygen > UpperBounds) | ||
Oxygen = UpperBounds; | ||
|
||
if (Fuel > UpperBounds) | ||
Fuel = UpperBounds; | ||
|
||
if (Water > UpperBounds) | ||
Water = UpperBounds; | ||
|
||
if (Electricity > UpperBounds) | ||
Electricity = UpperBounds; | ||
} | ||
public int Oxygen { get => (int)Math.Floor(_model.Oxygen); set => _model.Oxygen = value; } | ||
public int Electricity { get => (int)Math.Floor(_model.Electricity); set => _model.Electricity = value; } | ||
public int Fuel { get => (int)Math.Floor(_model.Fuel); set => _model.Fuel = value; } | ||
public int Water { get => (int)Math.Floor(_model.Water); set => _model.Water = value; } | ||
} |
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,28 @@ | ||
namespace Server.Web.Models; | ||
public class ResourcesModel | ||
{ | ||
public float Oxygen { get; set; } = UpperBounds; | ||
public float Electricity { get; set; } = UpperBounds; | ||
public float Fuel { get; set; } = UpperBounds; | ||
public float Water { get; set; } = UpperBounds; | ||
|
||
public const float UpperBounds = 100; | ||
|
||
public bool Depleated() => | ||
Oxygen <= 0 || Electricity <= 0 || Fuel <= 0 || Water <= 0; | ||
|
||
public void EnsureBounds() | ||
{ | ||
if (Oxygen > UpperBounds) | ||
Oxygen = UpperBounds; | ||
|
||
if (Fuel > UpperBounds) | ||
Fuel = UpperBounds; | ||
|
||
if (Water > UpperBounds) | ||
Water = UpperBounds; | ||
|
||
if (Electricity > UpperBounds) | ||
Electricity = UpperBounds; | ||
} | ||
} |
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