using UnityEngine; using System.Collections; public class NetworkDefaultJungleTree : JungleTree { private readonly AtomicReference Repository; private readonly string Uuid; private readonly string TreeName; private readonly ChangeListWriter Writer; private readonly TreeEditor Editor; public NetworkDefaultJungleTree(string name, TreeContext tc, string uid, ChangeListWriter writer, TreeEditor edit) { this.TreeName = name; this.Repository = new AtomicReference(tc); this.Uuid = uid; this.Writer = writer; this.Editor = edit; } public JungleTreeEditor getTreeEditor() { TreeContext tc = Repository.Get(); NetworkTransactionManager txManager = new NetworkTransactionManager(this.TreeName, this.Writer, tc, this.Repository, this.Uuid); TreeNode root = tc.getRoot(); return new NetworkDefaultJungleTreeEditor(this.TreeName, root, txManager, this.Editor); } public JungleTreeEditor getLocalTreeEditor () { TreeContext tc = this.Repository.Get(); NetworkTransactionManager txManager = new NetworkTransactionManager(this.TreeName, this.Writer, tc, this.Repository, this.Uuid); TreeNode root = tc.getRoot(); return NetworkDefaultJungleTreeEditor.NewLocalTreeEditor(this.TreeName, root, txManager, this.Editor); } public TreeNode getRootNode () { TreeContext tc = this.Repository.Get(); return tc.getRoot(); } public long revision () { return 0; } public Either getOldTree (long rev) { TreeContext tc = this.Repository.Get(); while(tc.getRevision() != rev) { // If I mistake this code, change this code. tc = tc.prev(); if (tc == null) { return DefaultEither.newA(GetOldTreeError.OLD_TREE_NOT_FOUND); } } string oldTreeUuid = this.Uuid + revision().ToString(); JungleTree oldTree = new DefaultJungleTree(tc, oldTreeUuid, this.Writer, this.Editor); return DefaultEither.newB(oldTree); } public TreeMap>> getIndex () { TreeContext tc = this.Repository.Get(); return tc.getIndex(); } public Either getNodeOfPath (NodePath path) { TreeNode node = this.Repository.Get().getRoot(); foreach(var num in path) { if (num == -1) { continue; } Either either = node.getChildren().at(num); if (either.isA()){ return either; } node = either.b(); } return DefaultEither.newB(node); } public void setBufferSize (int num) { } }