Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ComponentsDataFeed and ComponentDataItemInterface, and add a PostBuildEvent to send the .DLL to the Libraries folder #34

Merged
merged 6 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using Elements.Core;
using FrooxEngine;

namespace Obsidian;

public class ComponentData
{
public SlimList<ISyncMember> members;

public Component component;

public bool Submitted { get; private set; }

public string MainName
{
get
{
return component.Name;
}
}

public int MemberCount => members.Count;

public ComponentData(Component component)
{
this.component = component;
}

public void MarkSubmitted()
{
if (Submitted)
{
throw new InvalidOperationException("This item is already marked as submitted");
}
Submitted = true;
}

public void ClearSubmitted()
{
if (!Submitted)
{
throw new InvalidOperationException("This item isn't marked as submitted");
}
Submitted = false;
}

public void AddMember(ISyncMember member)
{
members.Add(member);
}

public bool MatchesSearchParameters(List<string> optionalTerms, List<string> requiredTerms, List<string> excludedTerms)
{
foreach (string excludedTerm in excludedTerms)
{
if (MatchesTerm(excludedTerm))
{
return false;
}
}
foreach (string requiredTerm in requiredTerms)
{
if (!MatchesTerm(requiredTerm))
{
return false;
}
}
if (requiredTerms.Count > 0)
{
return true;
}
if (optionalTerms.Count == 0)
{
return true;
}
foreach (string optionalTerm in optionalTerms)
{
if (MatchesTerm(optionalTerm))
{
return true;
}
}
return false;
}

public bool MatchesTerm(string term)
{
if (component != null)
{
if (ContainsTerm(component.Name, term))
{
return true;
}
}
return false;
}

private static bool ContainsTerm(string str, string term)
{
if (string.IsNullOrEmpty(str))
{
return false;
}
return str.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0;
}

public override string ToString()
{
return $"Name: {MainName}, ReferenceID: {component.ReferenceID}, Members: {members.Count}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Elements.Core;
using FrooxEngine;

namespace Obsidian;

public class ComponentDataFeedItem : DataFeedItem
{
public SlimList<DataFeedEntity<ISyncMember>> Members;

public ComponentData Data { get; private set; }

public ComponentDataFeedItem(ComponentData componentData)
{
InitBase(componentData.component.ReferenceID.ToString(), null, null, componentData.MainName);
Data = componentData;
foreach (ISyncMember member in componentData.members)
{
DataFeedEntity<ISyncMember> dataFeedEntity = new DataFeedEntity<ISyncMember>();
dataFeedEntity.InitBase(member.ReferenceID.ToString(), null, null, member.Name);
dataFeedEntity.InitEntity(member);
Members.Add(dataFeedEntity);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using FrooxEngine;

namespace Obsidian;

public readonly struct ComponentDataResult
{
public readonly ComponentData data;

public readonly DataFeedItemChange change;

public ComponentDataResult(ComponentData data, DataFeedItemChange change)
{
this.data = data;
this.change = change;
}
}
Loading