Exemplo n.º 1
0
        public static RemoteObject Load(
            IRemoteRenderingMachine machine,
            RemoteItemBase remoteData,
            GameObject containerPrefab,
            Transform parent = null,
            Action <RemoteObject> initailizeAction = null)
        {
            if (remoteData == null)
            {
                return(null);
            }

            var newObject = containerPrefab == null ? new GameObject() : GameObject.Instantiate(containerPrefab);

            newObject.SetActive(false);
            newObject.transform.SetParent(parent, false);

            var remoteObject = newObject.EnsureComponent <RemoteObject>();

            remoteObject.PrimaryMachine = machine;
            remoteObject.Data           = remoteData;

            initailizeAction?.Invoke(remoteObject);
            newObject.SetActive(true);

            return(remoteObject);
        }
        public static RemoteObject Load(
            RemoteItemBase remoteData,
            GameObject containerPrefab,
            Transform parent = null,
            Action <RemoteObject> initailizeAction = null)
        {
            GameObject newObject;

            if (containerPrefab == null)
            {
                newObject = new GameObject();
                // avoid scripts from running when adding to object
                newObject.SetActive(false);
            }
            else
            {
                // avoid scripts from running right when initantiated and adding to object
                containerPrefab.SetActive(false);
                newObject = GameObject.Instantiate(containerPrefab);
            }
            newObject.transform.SetParent(parent, true);

            var remoteObject = newObject.EnsureComponent <RemoteObject>();

            remoteObject.Data = remoteData;

            initailizeAction?.Invoke(remoteObject);
            newObject.SetActive(true);

            return(remoteObject);
        }
Exemplo n.º 3
0
 public static RemoteObject Load(
     RemoteItemBase remoteData,
     GameObject containerPrefab,
     Transform parent = null,
     Action <RemoteObject> initailizeAction = null)
 {
     // The RemoteObject will manage getting the "primary machine"
     return(Load(null, remoteData, containerPrefab, parent, initailizeAction));
 }
Exemplo n.º 4
0
        private string OrgPathToPath(RemoteItemBase orgItem)
        {
            string path = orgItem.FullPath;

            if (string.IsNullOrEmpty(path) || (_server as CarotCryptSystem).cryptRootPath == path)
            {
                return("");
            }

            if (!path.StartsWith((_server as CarotCryptSystem).cryptRootPath))
            {
                throw new Exception("internal error: CarotCryptSystemItem rootpath");
            }

            var ret = new List <string>();

            path = path.Substring((_server as CarotCryptSystem).cryptRootPath.Length);

            while (!string.IsNullOrEmpty(path))
            {
                var m = Regex.Match(path, @"^(?<current>[^/\\]*)(/|\\)?(?<next>.*)$");
                path = m.Groups["next"].Value;
                if (string.IsNullOrEmpty(m.Groups["current"].Value))
                {
                    continue;
                }
                if (m.Groups["current"].Value == ".")
                {
                    continue;
                }
                if (m.Groups["current"].Value == "..")
                {
                    if (ret.Count > 0)
                    {
                        ret.RemoveAt(ret.Count - 1);
                    }
                }
                else
                {
                    ret.Add((_server as CarotCryptSystem).CryptCarot.DecryptFilename(orgItem.PathDecode(m.Groups["current"].Value)));
                }
            }
            return(string.Join("/", ret.Select(x => Uri.EscapeDataString(x))));
        }