-
-
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.
- Loading branch information
Showing
8 changed files
with
246 additions
and
69 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,45 @@ | ||
using BowieD.Unturned.AssetExpander.Models; | ||
using SDG.Unturned; | ||
|
||
namespace BowieD.Unturned.AssetExpander.CustomFields.Items | ||
{ | ||
public class StarveCustomField : ICustomField | ||
{ | ||
public string Name => "Starve"; | ||
public EAssetType Type => EAssetType.ITEM; | ||
public void Init() | ||
{ | ||
UseableConsumeable.onConsumePerformed += UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid += UseableConsumeable_onPerformedAid; | ||
} | ||
|
||
private void UseableConsumeable_onPerformedAid(Player instigator, Player target) | ||
{ | ||
var asset = instigator.equipment.asset; | ||
if (asset is ItemConsumeableAsset ica) | ||
consume(target, ica); | ||
} | ||
|
||
private void UseableConsumeable_onConsumePerformed(Player instigatingPlayer, ItemConsumeableAsset consumeableAsset) | ||
{ | ||
consume(instigatingPlayer, consumeableAsset); | ||
} | ||
|
||
private void consume(Player player, ItemConsumeableAsset asset) | ||
{ | ||
if (Plugin.CustomData.TryGetValue(asset.GUID, out var cData)) | ||
{ | ||
if (cData.TryGetValue(Name, out var raw) && byte.TryParse(raw, out byte parsed)) | ||
{ | ||
player.life.serverModifyFood(-parsed); | ||
} | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
UseableConsumeable.onConsumePerformed -= UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid -= UseableConsumeable_onPerformedAid; | ||
} | ||
} | ||
} |
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,45 @@ | ||
using BowieD.Unturned.AssetExpander.Models; | ||
using SDG.Unturned; | ||
|
||
namespace BowieD.Unturned.AssetExpander.CustomFields.Items | ||
{ | ||
public class ThirstCustomField : ICustomField | ||
{ | ||
public string Name => "Thirst"; | ||
public EAssetType Type => EAssetType.ITEM; | ||
public void Init() | ||
{ | ||
UseableConsumeable.onConsumePerformed += UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid += UseableConsumeable_onPerformedAid; | ||
} | ||
|
||
private void UseableConsumeable_onPerformedAid(Player instigator, Player target) | ||
{ | ||
var asset = instigator.equipment.asset; | ||
if (asset is ItemConsumeableAsset ica) | ||
consume(target, ica); | ||
} | ||
|
||
private void UseableConsumeable_onConsumePerformed(Player instigatingPlayer, ItemConsumeableAsset consumeableAsset) | ||
{ | ||
consume(instigatingPlayer, consumeableAsset); | ||
} | ||
|
||
private void consume(Player player, ItemConsumeableAsset asset) | ||
{ | ||
if (Plugin.CustomData.TryGetValue(asset.GUID, out var cData)) | ||
{ | ||
if (cData.TryGetValue(Name, out var raw) && byte.TryParse(raw, out byte parsed)) | ||
{ | ||
player.life.serverModifyWater(-parsed); | ||
} | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
UseableConsumeable.onConsumePerformed -= UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid -= UseableConsumeable_onPerformedAid; | ||
} | ||
} | ||
} |
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,45 @@ | ||
using BowieD.Unturned.AssetExpander.Models; | ||
using SDG.Unturned; | ||
|
||
namespace BowieD.Unturned.AssetExpander.CustomFields.Items | ||
{ | ||
public class TireCustomField : ICustomField | ||
{ | ||
public string Name => "Tire"; | ||
public EAssetType Type => EAssetType.ITEM; | ||
public void Init() | ||
{ | ||
UseableConsumeable.onConsumePerformed += UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid += UseableConsumeable_onPerformedAid; | ||
} | ||
|
||
private void UseableConsumeable_onPerformedAid(Player instigator, Player target) | ||
{ | ||
var asset = instigator.equipment.asset; | ||
if (asset is ItemConsumeableAsset ica) | ||
consume(target, ica); | ||
} | ||
|
||
private void UseableConsumeable_onConsumePerformed(Player instigatingPlayer, ItemConsumeableAsset consumeableAsset) | ||
{ | ||
consume(instigatingPlayer, consumeableAsset); | ||
} | ||
|
||
private void consume(Player player, ItemConsumeableAsset asset) | ||
{ | ||
if (Plugin.CustomData.TryGetValue(asset.GUID, out var cData)) | ||
{ | ||
if (cData.TryGetValue(Name, out var raw) && byte.TryParse(raw, out byte parsed)) | ||
{ | ||
player.life.serverModifyStamina(-parsed); | ||
} | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
UseableConsumeable.onConsumePerformed -= UseableConsumeable_onConsumePerformed; | ||
UseableConsumeable.onPerformedAid -= UseableConsumeable_onPerformedAid; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
using SDG.Unturned; | ||
|
||
namespace BowieD.Unturned.AssetExpander.Models | ||
{ | ||
public interface ICustomField | ||
{ | ||
/// <summary> | ||
/// Field Name | ||
/// </summary> | ||
string Name { get; } | ||
/// <summary> | ||
/// Asset Type | ||
/// </summary> | ||
EAssetType Type { get; } | ||
/// <summary> | ||
/// Used on start of the server to init all the custom fields | ||
/// </summary> | ||
void Init(); | ||
/// <summary> | ||
/// Used to dispose of any custom fields | ||
/// </summary> | ||
void Stop(); | ||
} | ||
} |
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