-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Nytra/main
Add ComponentsDataFeed and ComponentDataItemInterface, and add a PostBuildEvent to send the .DLL to the Libraries folder
- Loading branch information
Showing
7 changed files
with
515 additions
and
0 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
ProjectObsidian/Components/Radiant UI/Data Feeds/Feeds/ComponentData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
ProjectObsidian/Components/Radiant UI/Data Feeds/Feeds/ComponentDataFeedItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
ProjectObsidian/Components/Radiant UI/Data Feeds/Feeds/ComponentDataResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.