Skip to content

Commit

Permalink
fix: Fixes commodity resource property hue (#1875)
Browse files Browse the repository at this point in the history
### Summary

- Fixes resource commodities so the hue changes when setting the resource
- Fixes some commodities not being able to be modified in-game.
  • Loading branch information
kamronbatman authored Jul 20, 2024
1 parent eed11be commit 3cb688a
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Projects/UOContent/Items/Food/Cooking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public SackFlour() : base(0x1039)
_quantity = 20;
}

[CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int Quantity
{
get => _quantity;
Expand Down
25 changes: 19 additions & 6 deletions Projects/UOContent/Items/Resources/Blacksmithing/Ingots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Server.Items;
[SerializationGenerator(2, false)]
public abstract partial class BaseIngot : Item, ICommodity
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private CraftResource _resource;

public BaseIngot(CraftResource resource, int amount = 1) : base(0x1BF2)
{
Stackable = true;
Expand All @@ -21,6 +16,24 @@ public BaseIngot(CraftResource resource, int amount = 1) : base(0x1BF2)

public override double DefaultWeight => 0.1;

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber
{
get
Expand Down Expand Up @@ -162,4 +175,4 @@ public partial class ValoriteIngot : BaseIngot
public ValoriteIngot(int amount = 1) : base(CraftResource.Valorite, amount)
{
}
}
}
21 changes: 17 additions & 4 deletions Projects/UOContent/Items/Resources/Blacksmithing/Ore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@ public BaseOre(CraftResource resource, int amount = 1) : base(RandomSize())
_resource = resource;
}

[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private CraftResource _resource;
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber
{
Expand Down
23 changes: 18 additions & 5 deletions Projects/UOContent/Items/Resources/Blacksmithing/Scales.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Server.Items;
[SerializationGenerator(1, false)]
public abstract partial class BaseScales : Item, ICommodity
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private CraftResource _resource;

public BaseScales(CraftResource resource, int amount = 1) : base(0x26B4)
{
Stackable = true;
Expand All @@ -19,6 +14,24 @@ public BaseScales(CraftResource resource, int amount = 1) : base(0x26B4)
_resource = resource;
}

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber => 1053139; // dragon scales

public override double DefaultWeight => 0.1;
Expand Down
23 changes: 18 additions & 5 deletions Projects/UOContent/Items/Resources/Masonry/Granite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Server.Items;
[SerializationGenerator(2, false)]
public abstract partial class BaseGranite : Item
{
[InvalidateProperties]
[SerializableField(0)]
[SerializedCommandProperty(AccessLevel.GameMaster)]
private CraftResource _resource;

public BaseGranite(CraftResource resource) : base(0x1779)
{
Hue = CraftResources.GetHue(resource);
Expand All @@ -20,6 +15,24 @@ public BaseGranite(CraftResource resource) : base(0x1779)

public override double DefaultWeight => Core.ML ? 1.0 : 10.0;

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber => 1044607; // high quality granite

private void Deserialize(IGenericReader reader, int version)
Expand Down
26 changes: 20 additions & 6 deletions Projects/UOContent/Items/Resources/Tailor/Hides.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using ModernUO.Serialization;
using Server.Engines.Craft;

namespace Server.Items;

[SerializationGenerator(2, false)]
public abstract partial class BaseHides : Item, ICommodity
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private CraftResource _resource;

public BaseHides(CraftResource resource, int amount = 1) : base(0x1079)
{
Stackable = true;
Expand All @@ -20,6 +16,24 @@ public BaseHides(CraftResource resource, int amount = 1) : base(0x1079)
_resource = resource;
}

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber
{
get
Expand Down Expand Up @@ -183,4 +197,4 @@ public bool Scissor(Mobile from, Scissors scissors)

return true;
}
}
}
25 changes: 19 additions & 6 deletions Projects/UOContent/Items/Resources/Tailor/Leathers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ namespace Server.Items;
[SerializationGenerator(2, false)]
public abstract partial class BaseLeather : Item, ICommodity
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private CraftResource _resource;

public BaseLeather(CraftResource resource, int amount = 1) : base(0x1081)
{
Stackable = true;
Expand All @@ -20,6 +15,24 @@ public BaseLeather(CraftResource resource, int amount = 1) : base(0x1081)
_resource = resource;
}

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public override int LabelNumber
{
get
Expand Down Expand Up @@ -111,4 +124,4 @@ public partial class BarbedLeather : BaseLeather
public BarbedLeather(int amount = 1) : base(CraftResource.BarbedLeather, amount)
{
}
}
}
22 changes: 18 additions & 4 deletions Projects/UOContent/Items/Skill Items/Carpenter Items/Board.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ namespace Server.Items;
[SerializationGenerator(4, false)]
public partial class Board : Item, ICommodity
{
[InvalidateProperties]
[SerializableField(0)]
private CraftResource _resource;

[Constructible]
public Board(int amount = 1) : this(CraftResource.RegularWood, amount)
{
Expand All @@ -25,6 +21,24 @@ public Board(CraftResource resource, int amount = 1) : base(0x1BD7)
Hue = CraftResources.GetHue(resource);
}

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

int ICommodity.DescriptionNumber
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public MessageInABottle(Map map, int level) : base(0x099F)

public override int LabelNumber => 1041080; // a message in a bottle

[CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int Level
{
get => _level;
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public override int LabelNumber
[CommandProperty(AccessLevel.GameMaster)]
public bool IsAncient => _level >= 4;

[CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public int Level
{
get => _level;
Expand Down
23 changes: 18 additions & 5 deletions Projects/UOContent/Items/Skill Items/Lumberjack/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ namespace Server.Items;
[Flippable(0x1bdd, 0x1be0)]
public partial class Log : Item, ICommodity, IAxe
{
[InvalidateProperties]
[SerializedCommandProperty(AccessLevel.GameMaster)]
[SerializableField(0)]
private CraftResource _resource;

[Constructible]
public Log(int amount = 1) : this(CraftResource.RegularWood, amount)
{
Expand All @@ -32,6 +27,24 @@ public Log(CraftResource resource, int amount) : base(0x1BDD)
Hue = CraftResources.GetHue(resource);
}

[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public CraftResource Resource
{
get => _resource;
set
{
if (_resource != value)
{
_resource = value;
Hue = CraftResources.GetHue(value);

InvalidateProperties();
this.MarkDirty();
}
}
}

public virtual bool Axe(Mobile from, BaseAxe axe) => TryCreateBoards(from, 0, new Board());

int ICommodity.DescriptionNumber => CraftResources.IsStandard(_resource)
Expand Down
2 changes: 1 addition & 1 deletion Projects/UOContent/Items/Special/MiniHouses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public MiniHouseAddon(MiniHouseType type = MiniHouseType.StoneAndPlaster)
Construct();
}

[CommandProperty(AccessLevel.GameMaster)]
[SerializableProperty(0)]
[CommandProperty(AccessLevel.GameMaster)]
public MiniHouseType Type
{
get => _type;
Expand Down

0 comments on commit 3cb688a

Please sign in to comment.