private ILoader GetLoader(ISession session) { using (new SessionIdLoggingContext(Session.SessionId)) { if (indexProjection != null) { ProjectionLoader loader = new ProjectionLoader(); loader.Init(session, SearchFactory, resultTransformer, indexProjection); return(loader); } if (criteria != null) { if (classes.GetLength(0) > 1) { throw new SearchException("Cannot mix criteria and multiple entity types"); } if (criteria is CriteriaImpl) { string targetEntity = ((CriteriaImpl)criteria).EntityOrClassName; if (classes.GetLength(0) == 1 && classes[0].FullName != targetEntity) { throw new SearchException("Criteria query entity should match query entity"); } try { System.Type entityType = ((CriteriaImpl)criteria).GetRootEntityTypeIfAvailable(); classes = new System.Type[] { entityType }; } catch (Exception e) { throw new SearchException("Unable to load entity class from criteria: " + targetEntity, e); } } QueryLoader loader = new QueryLoader(); loader.Init(session, searchFactoryImplementor); loader.EntityType = classes[0]; loader.Criteria = criteria; return(loader); } if (classes.GetLength(0) == 1) { QueryLoader loader = new QueryLoader(); loader.Init(session, searchFactoryImplementor); loader.EntityType = classes[0]; return(loader); } else { ObjectLoader loader = new ObjectLoader(); loader.Init(session, searchFactoryImplementor); return(loader); } } }
/// <summary> /// Move the button to the new z position /// </summary> /// <param name="NewZpos"></param> /// <param name="buttonToMove"></param> void MoveButton(short NewZpos, ObjectInteraction buttonToMove) { buttonToMove.zpos = NewZpos; buttonToMove.BaseObjectData.zpos = NewZpos; Vector3 newPos = ObjectLoader.CalcObjectXYZ(buttonToMove.BaseObjectData.index, 0); buttonToMove.transform.position = newPos; }
public static ObjectStream stream(this ObjectLoader objectLoader) { if (objectLoader.notNull()) { return(objectLoader.OpenStream()); } return(null); }
public override bool use() { trigger_base trigger = null; //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae if (link != 0) { ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(link); if (linkedObject != null) { if (linkedObject.GetItemType() != ObjectInteraction.LOCK) { trigger = linkedObject.GetComponent <trigger_base>(); } } } if (CurrentObjectInHand != null) { ActivateByObject(CurrentObjectInHand); //Clear the object in hand //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; if (trigger != null) { trigger.Activate(this.gameObject); } return(true); } else { //Normal Usage PlayerUse = true; if ((UWCharacter.AutoKeyUse) && (locked())) {//Try each key in the players inventory to see if it can open the door foreach (Transform t in GameWorldController.instance.InventoryMarker.transform) { if (t.gameObject.GetComponent <DoorKey>() != null) { DoorKey key = t.gameObject.GetComponent <DoorKey>(); if (key.KeyId == KeyIndex) { ActivateByObject(key.objInt()); if (trigger != null) { trigger.Activate(this.gameObject); } PlayerUse = false; return(true); } } } } Activate(this.gameObject); PlayerUse = false; return(true); } }
public override GameObject CopySelf(object self = null) { var item_clone = item.Clone() as Item; ((PointItem)item_clone).seq = 0; var clone = ObjectLoader.CloneDecoration(item.pname, item_clone); return(clone); }
//Makes the linked object to this visible. public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { ObjectInteraction obj = ObjectLoader.getObjectIntAt(objInt().link); if (obj != null) { obj.setInvis(0); //make visible. } }
public SpwReaderPlugin(IObjectModifier modifier, IObjectsRepository repository, IPersonalSettings personalSettings, IFileProvider fileProvider) { _objectModifier = modifier; _objectsRepository = repository; _pilotTypes = _objectsRepository.GetTypes(); _loader = new ObjectLoader(repository); _dataObjects = new List<IDataObject>(); _fileProvider = fileProvider; }
//Removes the link on the target object. public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { ObjectInteraction objToUnlink = ObjectLoader.getObjectIntAt(link); if (objToUnlink != null) { objToUnlink.link = 0; } }
/// <exception cref="System.IO.IOException"></exception> private void DoCacheTests() { foreach (WindowCacheGetTest.TestObject o in toLoad) { ObjectLoader or = db.Open(o.id, o.type); NUnit.Framework.Assert.IsNotNull(or); NUnit.Framework.Assert.AreEqual(o.type, or.GetType()); } }
public virtual void TestDelta_SmallObjectChain() { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); byte[] data0 = new byte[512]; Arrays.Fill(data0, unchecked ((byte)unchecked ((int)(0xf3)))); ObjectId id0 = fmt.IdFor(Constants.OBJ_BLOB, data0); TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(64 * 1024); PackHeader(pack, 4); ObjectHeader(pack, Constants.OBJ_BLOB, data0.Length); Deflate(pack, data0); byte[] data1 = Clone(unchecked ((int)(0x01)), data0); byte[] delta1 = Delta(data0, data1); ObjectId id1 = fmt.IdFor(Constants.OBJ_BLOB, data1); ObjectHeader(pack, Constants.OBJ_REF_DELTA, delta1.Length); id0.CopyRawTo(pack); Deflate(pack, delta1); byte[] data2 = Clone(unchecked ((int)(0x02)), data1); byte[] delta2 = Delta(data1, data2); ObjectId id2 = fmt.IdFor(Constants.OBJ_BLOB, data2); ObjectHeader(pack, Constants.OBJ_REF_DELTA, delta2.Length); id1.CopyRawTo(pack); Deflate(pack, delta2); byte[] data3 = Clone(unchecked ((int)(0x03)), data2); byte[] delta3 = Delta(data2, data3); ObjectId id3 = fmt.IdFor(Constants.OBJ_BLOB, data3); ObjectHeader(pack, Constants.OBJ_REF_DELTA, delta3.Length); id2.CopyRawTo(pack); Deflate(pack, delta3); Digest(pack); PackParser ip = Index(pack.ToByteArray()); ip.SetAllowThin(true); ip.Parse(NullProgressMonitor.INSTANCE); NUnit.Framework.Assert.IsTrue(wc.Has(id3), "has blob"); ObjectLoader ol = wc.Open(id3); NUnit.Framework.Assert.IsNotNull(ol, "created loader"); NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, ol.GetType()); NUnit.Framework.Assert.AreEqual(data3.Length, ol.GetSize()); NUnit.Framework.Assert.IsFalse(ol.IsLarge(), "is large"); NUnit.Framework.Assert.IsNotNull(ol.GetCachedBytes()); CollectionAssert.AreEquivalent(data3, ol.GetCachedBytes()); ObjectStream @in = ol.OpenStream(); NUnit.Framework.Assert.IsNotNull(@in, "have stream"); NUnit.Framework.Assert.AreEqual(Constants.OBJ_BLOB, @in.GetType()); NUnit.Framework.Assert.AreEqual(data3.Length, @in.GetSize()); byte[] act = new byte[data3.Length]; IOUtil.ReadFully(@in, act, 0, data3.Length); NUnit.Framework.Assert.IsTrue(Arrays.Equals(act, data3), "same content"); NUnit.Framework.Assert.AreEqual(-1, @in.Read(), "stream at EOF"); @in.Close(); }
/// <summary> /// Called when the mod is loaded. /// </summary> public override void OnLoad() { Invasion.LoadVanilla(); DateEvent.LoadVanilla(); LoadBiomes(); LoadInvasions(); LoadSpawns(); base.OnLoad(); tomeSkillHotkey = options[0]; shadowMirrorHotkey = options[1]; MWorld.managers = new SkillManager[1]; MWorld.tomes = new Item [1]; MWorld.accessories = new Item [1][]; MWorld.tomes [0] = new Item(); for (int i = 0; i < MWorld.accessories.Length; i++) { MWorld.accessories[i] = new Item[ExtraSlots]; for (int j = 0; j < MWorld.accessories[i].Length; j++) { MWorld.accessories[i][j] = new Item(); } } // insert all graphical/UI-related stuff AFTER this check! if (Main.dedServ) { return; } Texture2D gWings = textures["Resources/Wings/Golden Wings"]; foreach (Texture2D t in Main.wingsTexture.Values) { if (gWings == t) { addedWings = true; break; } } if (!addedWings) { GoldenWings = Main.dedServ ? Main.wingsTexture.Count : ObjectLoader.AddWingsToGame(gWings); addedWings = true; } StarterSetSelectionHandler.Init(); }
public void WriteRemarkInXLM(Guid id, int personId) { var loader = new ObjectLoader(_repository); loader.Load(objects => { CreateXmlFile(objects.ToList().Reasons(personId, id)); //CreateXmlFile(objects.ToList().Reasons(personId, id), $@"D:\\Import\\persons.xml"); }, type => true, id); }
public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame) { ObjectLoaderInfo newobjt = ObjectLoader.newObject(Item_ID, 40, StartFrame, 1, 256); ObjectInteraction objInt = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition); objInt.GetComponent <AnimationOverlay>().Looping = false; objInt.GetComponent <AnimationOverlay>().StartFrame = StartFrame; objInt.GetComponent <AnimationOverlay>().NoOfFrames = EndFrame - StartFrame; return(objInt.gameObject); }
/// <summary> /// Creates the fish that the player has caught. /// </summary> /// <returns>The fish.</returns> ObjectInteraction CreateFish() { ObjectLoaderInfo newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256); ObjectInteraction fishy = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position); fishy.gameObject.name = ObjectLoader.UniqueObjectName(newobjt); fishy.isquant = 1; GameWorldController.MoveToInventory(fishy.gameObject); return(fishy); }
public ObjectsManager(ObjectLoader objectLoader, MarioGame game) { StaticObjects = new List <IStatic>(); DynamicObjects = new List <IDynamic>(); NonCollidableObjects = new List <IObject>(); ObjectLoader = objectLoader; Mario = objectLoader.Mario; dynamicLoader = new DynamicLoader(game, objectLoader, this); this.game = game; }
public void test004_lookupDeltifiedObject() { ObjectId id = ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"); ObjectLoader or = db.OpenObject(id); Assert.IsNotNull(or); Assert.IsTrue(or is PackedObjectLoader); Assert.AreEqual(Constants.OBJ_BLOB, or.Type); Assert.AreEqual(18009, or.Size); Assert.AreEqual(537, ((PackedObjectLoader)or).DataOffset); }
/// <summary> /// Creates the fish that the player has caught. /// </summary> /// <returns>The fish.</returns> GameObject CreateFish() { ObjectLoaderInfo newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256); GameObject fishy = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject; fishy.name = ObjectLoader.UniqueObjectName(newobjt); GameWorldController.MoveToInventory(fishy); //newobjt.index= UWCharacter.Instance.playerInventory.ItemCounter++; //fishy.GetComponent<Food>().Nutrition=5; return(fishy); // ObjectInteraction.CreateNewObject(182).gameObject; }
private void DoCacheTests() { foreach (TestObject o in _toLoad) { ObjectLoader or = db.OpenObject(new WindowCursor(), o.Id); Assert.IsNotNull(or); Assert.IsTrue(or is PackedObjectLoader); Assert.AreEqual(o.Type, Constants.typeString(or.Type)); Assert.AreEqual(o.RawSize, or.RawSize); Assert.AreEqual(o.Offset, ((PackedObjectLoader)or).ObjectOffset); } }
private void FixThinPack(ProgressMonitor progress) { GrowEntries(); _packDigest.Reset(); _originalEof = _packOut.Length - 20; var def = new Deflater(Deflater.DEFAULT_COMPRESSION, false); var missing = new List <DeltaChain>(64); long end = _originalEof; foreach (DeltaChain baseId in _baseById) { if (baseId.Head == null) { continue; } ObjectLoader ldr = _repo.OpenObject(_windowCursor, baseId); if (ldr == null) { missing.Add(baseId); continue; } byte[] data = ldr.CachedBytes; int typeCode = ldr.Type; _crc.Reset(); _packOut.Seek(end, SeekOrigin.Begin); WriteWhole(def, typeCode, data); var oe = new PackedObjectInfo(end, (int)_crc.Value, baseId); _entries[_entryCount++] = oe; end = _packOut.Position; ResolveChildDeltas(oe.Offset, typeCode, data, oe); if (progress.IsCancelled) { throw new IOException("Download cancelled during indexing"); } } def.Finish(); foreach (DeltaChain baseDeltaChain in missing) { if (baseDeltaChain.Head != null) { throw new MissingObjectException(baseDeltaChain, "delta base"); } } FixHeaderFooter(_packcsum, _packDigest.Digest()); }
public void LoadNewTaskList() { try { ObjectLoader loader = new ObjectLoader(); _tasks = new ObservableCollection <UserTask>(loader.LoadUserTasksFromTextFile()); } catch (FileNotFoundException e) { SendNoFileErrorMessage(e.FileName); } }
public void LoadAndAddTaskList() { try { ObjectLoader loader = new ObjectLoader(); Tasks = loader.LoadUserTasksFromTextFile(); } catch (FileNotFoundException e) { SendNoFileErrorMessage(e.FileName); } }
/// <exception cref="NGit.Errors.MissingObjectException"></exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception> /// <exception cref="System.IO.IOException"></exception> private byte[] ReadTree(AnyObjectId id) { BaseSearch.TreeWithData tree = treeCache.Get(id); if (tree != null) { return(tree.buf); } ObjectLoader ldr = reader.Open(id, Constants.OBJ_TREE); byte[] buf = ldr.GetCachedBytes(int.MaxValue); treeCache.Add(new BaseSearch.TreeWithData(id, buf)); return(buf); }
protected virtual void OnDrawGizmos() { Gizmos.color = Color.green; if (link != 0) { GameObject target = ObjectLoader.getGameObjectAt(link); if (target != null) { Gizmos.DrawLine(transform.position, target.transform.position); } } }
/// <summary> /// Creates a new spell trap in the object list /// </summary> public override void InventoryEventOnLevelEnter() { if (_RES == GAME_UW2) { return; } //UW2 stores enchantments on the player.dat. This is not implemented yet base.InventoryEventOnLevelEnter(); //Create a spell trap and store it on the map. This occurs before the list is rendered. ObjectLoaderInfo newobj = ObjectLoader.newObject(390, SpellObjectQualityToCreate, SpellObjectOwnerToCreate, SpellObjectLink, 256); //ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobj,GameWorldController.instance.LevelMarker().gameObject,new Vector3(99f*1.2f,0,99f*1.2f)); objInt().link = newobj.index; }
private void OnDrawGizmos() { Gizmos.color = Color.blue; if (link != 0) { GameObject target = ObjectLoader.getGameObjectAt(link); if (target != null) { Gizmos.DrawLine(transform.position, target.transform.position); } } }
/// <summary> /// Handle player choosing how many items to pick up in a stack /// </summary> /// <param name="quant"></param> public void OnSubmitPickup(int quant) { InputField inputctrl = UWHUD.instance.InputControl; inputctrl.text = ""; inputctrl.gameObject.SetActive(false); WindowDetect.WaitingForInput = false; ConversationVM.EnteringQty = false; if (ConversationVM.InConversation == false) { UWHUD.instance.MessageScroll.Clear(); Time.timeScale = 1.0f; } else { UWHUD.instance.ConversationButtonParent.SetActive(true); UWHUD.instance.MessageScroll.Set(""); // UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;//Restore original text } if (quant == 0) {//cancel QuantityObj = null; } if (QuantityObj != null) {//Just do a normal pickup. if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link) { CurrentObjectInHand = QuantityObj; if (this.slotIndex >= 11) { UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11); } UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex); } else { //split the obj. ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>(); objI.link = objI.link - quant; ObjectLoaderInfo newObj = ObjectLoader.newWorldObject(objI.item_id, objI.quality, objI.owner, quant, -1); newObj.is_quant = 1; ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position); GameWorldController.MoveToInventory(NewObjI); CurrentObjectInHand = NewObjI; ObjectInteraction.Split(objI, NewObjI); UWCharacter.Instance.playerInventory.Refresh(); QuantityObj = null; } } }
public static string ReadFile(ObjectLoader loader) { string strModifiedFile = null; using (System.IO.Stream strm = loader.OpenStream()) { using (System.IO.StreamReader sr = new System.IO.StreamReader(strm)) { strModifiedFile = sr.ReadToEnd(); } } return strModifiedFile; } // End Function ReadFile
/// <summary> /// Updates the file in the working tree with content and mode from an entry /// in the index. /// </summary> /// <remarks> /// Updates the file in the working tree with content and mode from an entry /// in the index. The new content is first written to a new temporary file in /// the same directory as the real file. Then that new file is renamed to the /// final filename. /// TODO: this method works directly on File IO, we may need another /// abstraction (like WorkingTreeIterator). This way we could tell e.g. /// Eclipse that Files in the workspace got changed /// </remarks> /// <param name="repo"></param> /// <param name="f"> /// the file to be modified. The parent directory for this file /// has to exist already /// </param> /// <param name="entry">the entry containing new mode and content</param> /// <exception cref="System.IO.IOException">System.IO.IOException</exception> public static void CheckoutEntry(Repository repo, FilePath f, DirCacheEntry entry ) { ObjectLoader ol = repo.Open(entry.GetObjectId()); FilePath parentDir = f.GetParentFile(); FilePath tmpFile = FilePath.CreateTempFile("._" + f.GetName(), null, parentDir); FileOutputStream channel = new FileOutputStream(tmpFile); try { ol.CopyTo(channel); } finally { channel.Close(); } FS fs = repo.FileSystem; WorkingTreeOptions opt = repo.GetConfig().Get(WorkingTreeOptions.KEY); if (opt.IsFileMode() && fs.SupportsExecute()) { if (FileMode.EXECUTABLE_FILE.Equals(entry.RawMode)) { if (!fs.CanExecute(tmpFile)) { fs.SetExecute(tmpFile, true); } } else { if (fs.CanExecute(tmpFile)) { fs.SetExecute(tmpFile, false); } } } if (!tmpFile.RenameTo(f)) { // tried to rename which failed. Let' delete the target file and try // again FileUtils.Delete(f); if (!tmpFile.RenameTo(f)) { throw new IOException(MessageFormat.Format(JGitText.Get().couldNotWriteFile, tmpFile .GetPath(), f.GetPath())); } } entry.LastModified = f.LastModified(); entry.SetLength((int)ol.GetSize()); }
/// <summary> /// Initialise the object class /// </summary> /// <param name="index"></param> /// <param name="map"></param> public ObjectLoaderInfo(int _index, TileMap _map, bool isWorldObject) { index = _index; map = _map; guid = System.Guid.NewGuid(); if (isWorldObject) { parentList = GameWorldController.CurrentObjectList(); } else { parentList = GameWorldController.instance.inventoryLoader; } }
void SetNPCLocation(int index, int xhome, int yhome) { ObjectInteraction obj = ObjectLoader.getObjectIntAt(index); if (obj != null) { NPC npc = obj.GetComponent <NPC>(); if (npc != null) { npc.npc_xhome = (short)xhome; npc.npc_yhome = (short)yhome; } } }
/*protected override void Start () * { * base.Start (); * //this.transform.localScale = new Vector3(4f,4f,4f); * }*/ public override bool ActivateByObject(ObjectInteraction ObjectUsed) { if (ObjectUsed.item_id == 296) {//Bashed with a rock hammer //ObjectInteraction newObj; switch (item_id) { case LargeBoulder1: //Large Boulders case LargeBoulder2: //Split into two boulders for (int i = 0; i < 2; i++) { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(MediumBoulder, 0, 0, 0, 256); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; Destroy(this.gameObject); ObjectInteraction.DestroyObjectFromUW(this.objInt()); } break; case MediumBoulder: //Boulder. //Split into 2 small boulders for (int i = 0; i < 2; i++) { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(342, 0, 0, 0, 256); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; ObjectInteraction.DestroyObjectFromUW(this.objInt()); } break; case SmallBoulder: //Small boulder { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(16, 0, 0, 1, 256); newobjt.is_quant = 1; newobjt.link = Random.Range(1, 3); ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, this.transform.position + new Vector3(Random.Range(-0.6f, 0.6f), 0.0f, Random.Range(-0.6f, 0.6f))); objInt().BaseObjectData.InUseFlag = 0; ObjectInteraction.DestroyObjectFromUW(this.objInt()); break; } } //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault; CurrentObjectInHand = null; return(true); } else { return(base.ActivateByObject(ObjectUsed)); } }
private void treeView1_DragDrop(object sender, DragEventArgs e) { foreach (var item in e.Data.GetFormats()) { Console.WriteLine(new { item }); } //x.SetData("text/html", json); e.Data.GetData("text/html").With( x => { var sz = (string)x; Console.WriteLine(new { sz.Length }); // http://stackoverflow.com/questions/24492809/three-js-export-import-object3d-json var json = JSON.parse(sz); var o = new ObjectLoader(); var z = o.parse(json); Add("?", () => (object)z); //new THREE.JSONLoader().parse //this.treeView1.Nodes. foreach (TreeNode item in this.treeView1.Nodes) { var xScene = item.Tag as Scene; if (xScene != null) { // we like shadows z.castShadow = true; z.AttachTo(xScene); Console.WriteLine("added to scene. can you see it?"); } } } ); }