using System; using System.Linq; using JD.SceneExplorer.Utils; namespace JD.SceneExplorer.ViewModels { public class Actor : ObjectWithRef { private string[] m_components; private ResourcePath m_lua; public Actor(uint objectRef, SceneTree parent) : base(objectRef, parent, parent != null ? parent.PropertyChangedHandler : null) { m_friendlyName = ""; m_components = null; m_lua = new ResourcePath(""); } public override ObjectWithRefType Type { get { return ObjectWithRefType.Actor; } } protected override int GetChildrenCount() { return 0; } protected override void LoadChildren() { } public string[] Components { get { return m_components; } set { if (m_components != value) { m_components = value; RaisePropertyChanged("Components"); } } } public ResourcePath Lua { get { return m_lua; } set { if (m_lua != value) { m_lua = value; FilePath = value.Directory + "\\" + value.Filename; RaisePropertyChanged("Lua"); } } } /// /// fill in data from blob /// /// public static Actor LoadFromBlob(JD.Remoting.IBlob _blob, SceneTree parent) { uint objectRef = _blob.ExtractUInt(); Actor newActor = new Actor(objectRef, parent); string luaPath = ""; newActor.FriendlyName = _blob.ExtractString(); string componentsString = _blob.ExtractString(); newActor.Components = componentsString.Split(','); luaPath = _blob.ExtractPath(); newActor.Lua = new ResourcePath(luaPath); newActor.Active = _blob.ExtractBool(); newActor.Visible = !_blob.ExtractBool(); uint tagsCount = _blob.ExtractUInt(); for (int i = 0; i < tagsCount; i++) { newActor.Tags.Add(_blob.ExtractString()); } if (newActor.Tags.FirstOrDefault(tag => tag == "actor") == null) newActor.Tags.Add("actor"); newActor.IconSource = EditorIconsManager.Instance.GetIconLocationFromTags(newActor.Tags); return newActor; } } }