mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-13 12:14:18 +01:00
Fiddle with hat state some more.
This commit is contained in:
parent
e42a17ebd8
commit
81a1c38e1a
2 changed files with 34 additions and 10 deletions
|
|
@ -80,6 +80,18 @@ public unsafe struct DesignData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly CharacterArmor ArmorWithState(EquipSlot slot)
|
||||||
|
{
|
||||||
|
if (slot is EquipSlot.Head && !IsHatVisible())
|
||||||
|
return CharacterArmor.Empty;
|
||||||
|
|
||||||
|
fixed (byte* ptr = _equipmentBytes)
|
||||||
|
{
|
||||||
|
var armorPtr = (CharacterArmor*)ptr;
|
||||||
|
return armorPtr[slot.ToIndex()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public readonly CharacterWeapon Weapon(EquipSlot slot)
|
public readonly CharacterWeapon Weapon(EquipSlot slot)
|
||||||
{
|
{
|
||||||
fixed (byte* ptr = _equipmentBytes)
|
fixed (byte* ptr = _equipmentBytes)
|
||||||
|
|
|
||||||
|
|
@ -353,10 +353,22 @@ public class StateListener : IDisposable
|
||||||
|
|
||||||
var actorArmor = actor.GetArmor(slot);
|
var actorArmor = actor.GetArmor(slot);
|
||||||
var fistWeapon = FistWeaponGauntletHack();
|
var fistWeapon = FistWeaponGauntletHack();
|
||||||
|
|
||||||
// The actor armor does not correspond to the model armor, thus the actor is transformed.
|
// The actor armor does not correspond to the model armor, thus the actor is transformed.
|
||||||
// This also prevents it from changing values due to hat state.
|
if (actorArmor.Value != armor.Value)
|
||||||
if (actorArmor.Value != armor.Value && !fistWeapon)
|
{
|
||||||
return UpdateState.Transformed;
|
// Update base data in case hat visibility is off.
|
||||||
|
if (slot is EquipSlot.Head && armor.Value == 0 && actorArmor.Value != state.BaseData.Armor(EquipSlot.Head).Value)
|
||||||
|
{
|
||||||
|
var item = _items.Identify(slot, actorArmor.Set, actorArmor.Variant);
|
||||||
|
state.BaseData.SetItem(EquipSlot.Head, item);
|
||||||
|
state.BaseData.SetStain(EquipSlot.Head, actorArmor.Stain);
|
||||||
|
return UpdateState.Change;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fistWeapon)
|
||||||
|
return UpdateState.Transformed;
|
||||||
|
}
|
||||||
|
|
||||||
var baseData = state.BaseData.Armor(slot);
|
var baseData = state.BaseData.Armor(slot);
|
||||||
var change = UpdateState.NoChange;
|
var change = UpdateState.NoChange;
|
||||||
|
|
@ -366,7 +378,7 @@ public class StateListener : IDisposable
|
||||||
change = UpdateState.Change;
|
change = UpdateState.Change;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseData.Set.Id != armor.Set.Id || (baseData.Variant != armor.Variant && !fistWeapon))
|
if (baseData.Set.Id != armor.Set.Id || baseData.Variant != armor.Variant && !fistWeapon)
|
||||||
{
|
{
|
||||||
var item = _items.Identify(slot, armor.Set, armor.Variant);
|
var item = _items.Identify(slot, armor.Set, armor.Variant);
|
||||||
state.BaseData.SetItem(slot, item);
|
state.BaseData.SetItem(slot, item);
|
||||||
|
|
@ -381,10 +393,6 @@ public class StateListener : IDisposable
|
||||||
{
|
{
|
||||||
switch (UpdateBaseData(actor, state, slot, armor))
|
switch (UpdateBaseData(actor, state, slot, armor))
|
||||||
{
|
{
|
||||||
// Transformed also handles invisible hat state.
|
|
||||||
case UpdateState.Transformed when slot is EquipSlot.Head && armor.Value == 0 && state.ModelData.IsHatVisible():
|
|
||||||
armor = state.ModelData.Armor(slot);
|
|
||||||
break;
|
|
||||||
// Base data changed equipment while actors were not there.
|
// Base data changed equipment while actors were not there.
|
||||||
// Update model state if not on fixed design.
|
// Update model state if not on fixed design.
|
||||||
case UpdateState.Change:
|
case UpdateState.Change:
|
||||||
|
|
@ -400,12 +408,16 @@ public class StateListener : IDisposable
|
||||||
apply = true;
|
apply = true;
|
||||||
|
|
||||||
if (apply)
|
if (apply)
|
||||||
armor = state.ModelData.Armor(slot);
|
armor = state.ModelData.ArmorWithState(slot);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// Use current model data.
|
// Use current model data.
|
||||||
|
// Transformed also handles invisible hat state.
|
||||||
case UpdateState.NoChange:
|
case UpdateState.NoChange:
|
||||||
armor = state.ModelData.Armor(slot);
|
armor = state.ModelData.ArmorWithState(slot);
|
||||||
|
break;
|
||||||
|
case UpdateState.Transformed when slot is EquipSlot.Head && armor.Value is 0:
|
||||||
|
armor = state.ModelData.ArmorWithState(slot);
|
||||||
break;
|
break;
|
||||||
case UpdateState.Transformed: break;
|
case UpdateState.Transformed: break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue