public static void ApplyDataToGameObject(GameObject obj, CompoundDataPiece piece) { foreach (var participant in obj.GetComponents <Participant>()) { if (HasValidDataForParticipant(participant, piece)) { participant.ReadData(ExtendedDataUtils.GetPieceForParticipantFromRoot(participant, piece)); } } }
public static CompoundDataPiece ReadDataFromGameObject(GameObject obj) { var newCompound = new CompoundDataPiece("root"); foreach (var participant in obj.GetComponents <Participant>()) { participant.WriteData(ExtendedDataUtils.GetPieceForParticipantFromRoot(participant, newCompound)); } return(newCompound); }
static bool ValidateParticipant(ExtendedData.Participant p, CompoundDataPiece piece) { var modid = ExtendedDataUtils.GetModForParticipant(p)?.ModInfo.Id ?? "srml"; return(p.IsDataValid(ExtendedDataUtils.GetPieceForParticipantFromRoot(modid, p, piece))); }
static void InitParticipant(ExtendedData.Participant p, CompoundDataPiece piece) { var modid = ExtendedDataUtils.GetModForParticipant(p)?.ModInfo.Id ?? "srml"; p.InitData(ExtendedDataUtils.GetPieceForParticipantFromRoot(modid, p, piece)); }