You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the mod example you'd like to see
A lengthy description of all functions methods etc for making autogen UI's for world object components using AutogenClass and Autogen/SyncToView attributes and tooltips with updates based on property value changes
General things to cover:
How to make an autogen ui
How to display it in different ways (if possible)
how to get the client to update on value changes
how to connect RPC methods to value changes
how to disable changing of the values
Tooltips as well
2023-11-28.21-32-40.mp4
Additional context
Currently making any kind of UI for components is a pain and the fact that I have spent countless hours trying to figure this out and have no results is kind of annoying so documentation would help.
For example i have code that just wont work shown here:
using Eco.Core.Controller;
using Eco.Core.Items;
using Eco.Gameplay.Items;
using Eco.RM.Items;
using Eco.Shared.Localization;
using Eco.Shared.Serialization;
using Eco.Shared.Utils;
using Eco.Gameplay.Objects;
using Eco.Gameplay.Components.Storage;
using System.ComponentModel;
namespaceEco.RM.Components
{
[Serialized]
[AutogenClass]
[RequireComponent(typeof(PublicStorageComponent))]
[LocDisplayName("Battery Storage")]
[LocDescription("Battery storage for a object.")]
[HasIcon("BatteryStorageComponentIcon")]
[CreateComponentTabLoc("Battery Storage")]
[Ecopedia("[RM] Stored Power", "Batteries", true, true, "Battery Storage")]
public partial classBatteryStorageComponent : WorldObjectComponent
{
[Serialized, SyncToView, Autogen, ReadOnly(true)]
public float MaxCharge { get; set; }
[Serialized, SyncToView, Autogen, ReadOnly(true)]
public float MaxDischargeRate { get; set; }
[Serialized, SyncToView, Autogen, ReadOnly(true)]
public float MaxChargeRate { get; set; }
[Serialized, SyncToView, Autogen, ReadOnly(true)]
public float CurrentCharge { get; set; }
[Serialized, SyncToView, Autogen, ReadOnly(true)]
public float EnergyTransferRate { get; set; }
public Inventory Inventory => Parent.GetOrCreateComponent<PublicStorageComponent>().Inventory;
float energyChangeLastTick;
public voidUpdateStats()
{
MaxCharge = Inventory.NonEmptyStacks.Sum((itemStack) => ((BatteryItem)itemStack.Item).MaxCharge);
MaxDischargeRate = Inventory.NonEmptyStacks.Sum((itemStack) => ((BatteryItem)itemStack.Item).MaxDischargeRate);
MaxChargeRate = Inventory.NonEmptyStacks.Sum((itemStack) => ((BatteryItem)itemStack.Item).MaxChargeRate);
UpdateCharge();
}
public voidUpdateCharge()
{
CurrentCharge = Inventory.NonEmptyStacks.Sum((itemStack) => ((BatteryItem)itemStack.Item).CurrentCharge);
}
public voidInitialize(int slots)
{
Parent.GetOrCreateComponent<PublicStorageComponent>().Initialize(slots);
Inventory.AddInvRestriction(newTagRestriction(new Tag[] {TagManager.GetOrMake("Battery")}));
Inventory.SetOwner(Parent);
UpdateStats();
}
public floatCharge(float watts)
{
var og_watts = watts;
Inventory.NonEmptyStacks.ForEach((itemStack) => {
watts -= ((BatteryItem)itemStack.Item).Charge(watts);
});
energyChangeLastTick += og_watts - watts;
return og_watts - watts;
}
public floatDischarge(float watts)
{
var og_watts = watts;
Inventory.NonEmptyStacks.ForEach((itemStack) => {
watts -= ((BatteryItem)itemStack.Item).Discharge(watts);
});
energyChangeLastTick -= og_watts - watts;
return og_watts - watts;
}
public overridevoidLateTick()
{
if (energyChangeLastTick > 0) UpdateCharge();
if (energyChangeLastTick != EnergyTransferRate) EnergyTransferRate = energyChangeLastTick;
energyChangeLastTick = 0;
}
}
}
The text was updated successfully, but these errors were encountered:
Describe the mod example you'd like to see
A lengthy description of all functions methods etc for making autogen UI's for world object components using AutogenClass and Autogen/SyncToView attributes and tooltips with updates based on property value changes
General things to cover:
2023-11-28.21-32-40.mp4
Additional context
Currently making any kind of UI for components is a pain and the fact that I have spent countless hours trying to figure this out and have no results is kind of annoying so documentation would help.
For example i have code that just wont work shown here:
The text was updated successfully, but these errors were encountered: