private void Awake() { _initialParent = transform.parent; _entityLink = GetComponent <EntityLink>(); _rigidbody = GetComponent <Rigidbody>(); _collider = GetComponent <Collider>(); }
public void BeforeEach() { _pool = new Pool(1); _entity = _pool.CreateEntity(); _gameObject = new GameObject(); _link = _gameObject.AddComponent <EntityLink>(); }
public Entity CreateEntity(params ComponentType[] types) { var entityType = new EntityType(types); var data = GetOrCreateData(entityType.Hash, types, types.Length); var entityId = availableIndices.Count > 0 ? availableIndices.Dequeue() : entityLinks.Count; var version = 0; EntityLink link; if (entityLinks.Count > entityId) { link = entityLinks[entityId]; version = link.Entity.Version + 1; } else { link = new EntityLink(); entityLinks.SetAt(entityId, link); } var entity = new Entity(entityId, version); var dataIndex = data.AddEntity(entity, null); link.Data = data; link.IndexInData = dataIndex; link.Entity = entity; return(entity); }
public static Core.EntityLink MakeEntityLink(EntityLink unityEntityLink) { if (unityEntityLink.Entity == null) { return(new Core.EntityLink(string.Empty, string.Empty, string.Empty, 0)); } if (unityEntityLink.IsDataIdentifierEntityLink) { Assert.IsNotNull(unityEntityLink.DataIdentifier); Assert.IsFalse(string.IsNullOrEmpty(unityEntityLink.DataIdentifier.Identifier)); Assert.IsFalse(string.IsNullOrEmpty(unityEntityLink.NameInArchive)); return(new Core.EntityLink("DATA_IDENTIFIER", unityEntityLink.DataIdentifier.Identifier, unityEntityLink.NameInArchive, 0)); } var dataSetAsset = AssetDatabase.LoadAssetAtPath <DataSetAsset>(AssetDatabase.GUIDToAssetPath(unityEntityLink.Entity.DataSetGuid)); var package = AssetDatabase.LoadAssetAtPath <PackageDefinition>(AssetDatabase.GUIDToAssetPath(dataSetAsset.PackageGuid)); var packagePath = AssetToFoxPath(package); // Weirdly, EntityLinks reference .fpks instead of .fpkds, so remove the 'd' at the end. if (!string.IsNullOrEmpty(packagePath)) { packagePath = packagePath.Remove(packagePath.Length - 1); } var archivePath = AssetToFoxPath(dataSetAsset); var nameInArchive = unityEntityLink.Entity.Name; return(new Core.EntityLink( packagePath, archivePath, nameInArchive, unityEntityLink.Address)); }
public override void CreateStaticNodesIfNotPresent() { base.CreateStaticNodesIfNotPresent(); if(InputEvents.Count == 0) { EntityLink<MonsterTestBase> InputLink = new EntityLink<MonsterTestBase>(); InputLink.SetOwner(this); InputLink.Name = "Input"; InputEvents.Add(InputLink); } /* if(OutputEvents.Count != NumberOfOutputs) { for(int CurrentLink = OutputEvents.Count; CurrentLink < NumberOfOutputs; ++CurrentLink) { EntityLink<MonsterTestBase> OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Option " + CurrentLink; OutputEvents.Add(OutputLink); } for(int CurrentLink = NumberOfOutputs; CurrentLink < OutputEvents.Count;) { OutputEvents[CurrentLink].BreakAllLinks(); OutputEvents.RemoveAt(CurrentLink); } }*/ }
protected override void Execute(List <InputEntity> entities) { if (EventSystem.current.IsPointerOverGameObject() || EventSystem.current.currentSelectedGameObject != null) { return; } InputEntity pointerPosition = inputContext.GetGroup(InputMatcher.InputPointerPosition).Last(); foreach (var e in entities) { Ray pointRay = Camera.main.ScreenPointToRay(pointerPosition.inputPointerPosition.position); RaycastHit hit; if (Physics.Raycast(pointRay, out hit, float.PositiveInfinity, LayerMask.GetMask("Interactable"))) { EntityLink entityLink = hit.collider.gameObject.GetEntityLink(); if (entityLink != null) { inputContext.CreateEntity().AddInteractableClick((entityLink.entity as IId).id.value); } } else if (Physics.Raycast(pointRay, out hit, float.PositiveInfinity, LayerMask.GetMask("Terrain"))) { inputContext.CreateEntity().AddTerrainClick(hit.point, hit.normal); } } }
public static bool CheckCondition(BaseEntity ent) { if (ModelConditionTest_WallTriangleRight.CheckSocketOccupied(ent, "wall/sockets/wall-female")) { return(false); } if (ModelConditionTest_WallTriangleRight.CheckSocketOccupied(ent, "wall/sockets/floor-female/1")) { return(false); } if (ModelConditionTest_WallTriangleRight.CheckSocketOccupied(ent, "wall/sockets/floor-female/2")) { return(false); } if (ModelConditionTest_WallTriangleRight.CheckSocketOccupied(ent, "wall/sockets/stability/2")) { return(false); } EntityLink entityLink = ent.FindLink("wall/sockets/neighbour/1"); if (entityLink == null) { return(false); } for (int i = 0; i < entityLink.connections.Count; i++) { BuildingBlock item = entityLink.connections[i].owner as BuildingBlock; if (!(item == null) && !(item.blockDefinition.info.name.token != "roof") && Vector3.Angle(ent.transform.forward, -item.transform.forward) <= 10f) { return(true); } } return(false); }
public override void CreateStaticNodesIfNotPresent() { base.CreateStaticNodesIfNotPresent(); if(InputEvents.Count != 1) { InputEvents.Clear(); EntityLink<MonsterTestBase> InputLink = new EntityLink<MonsterTestBase>(); InputLink.SetOwner(this); InputLink.Name = "Start Dialogue"; InputEvents.Add(InputLink); } if(OutputEvents.Count != 3) { EntityLink<MonsterTestBase> OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Game Finished"; OutputEvents.Add(OutputLink); OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Problem Encountered"; OutputEvents.Add(OutputLink); OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Navigation Required"; OutputEvents.Add(OutputLink); } }
public void InitializeSupports() { this.supports = new List <StabilityEntity.Support>(); if (this.grounded) { return; } List <EntityLink> entityLinks = base.GetEntityLinks(true); for (int i = 0; i < entityLinks.Count; i++) { EntityLink item = entityLinks[i]; if (item.IsMale()) { if (item.socket is StabilitySocket) { this.supports.Add(new StabilityEntity.Support(this, item, (item.socket as StabilitySocket).support)); } if (item.socket is ConstructionSocket) { this.supports.Add(new StabilityEntity.Support(this, item, (item.socket as ConstructionSocket).support)); } } } }
// Navigate up the islocated relationship public Building GetContainerBuilding(EntityLink location, Company company) { Building building = null; try { if (location.Href != null) { var resp = HttpHelper.Get <Building>(company, location.Href, _tokenProvider); if (resp != null) { if (resp.Type.Id == "Building") { building = resp; } else { building = GetContainerBuilding(resp.Location, company); } } } } catch (Exception) { building = null; } return(building); }
public static EntityLink MakeEntityLink(DataSet owningDataSet, Core.EntityLink foxEntityLink, EntityFactory.EntityInitializeFunctions.GetEntityFromAddressDelegate getEntityByAddress, Func <string, Data> getEntityByName) { var link = new EntityLink( foxEntityLink.PackagePath, foxEntityLink.ArchivePath, foxEntityLink.NameInArchive, foxEntityLink.EntityHandle); if (link.IsDataIdentifierEntityLink) { return(link); } // Store the archivePath for convenience later. if (string.IsNullOrEmpty(link.ArchivePath)) { link.ArchivePath = AssetDatabase.GUIDToAssetPath(owningDataSet.DataSetGuid); } // If the EntityLink references an Entity inside its own DataSet, resolve it now. if (Path.GetFileNameWithoutExtension(link.ArchivePath) != owningDataSet.OwningDataSetName) { return(link); } else if (link.Address != 0) { link.Entity = getEntityByAddress(link.Address) as Data; } else if (!string.IsNullOrEmpty(link.NameInArchive)) { link.Entity = getEntityByName(link.NameInArchive); } return(link); }
public EntityLink LinkEntity(Entity linkedEntity, ModelComponent modelComponent, string boneName) { var modelEntityData = matchingEntities[modelComponent.Entity]; var nodeIndex = modelEntityData.ModelComponent.ModelViewHierarchy.Nodes.IndexOf(x => x.Name == boneName); var entityLink = new EntityLink { Entity = linkedEntity, ModelComponent = modelComponent, NodeIndex = nodeIndex }; if (nodeIndex == -1) { return(entityLink); } linkedEntity.Transform.isSpecialRoot = true; linkedEntity.Transform.UseTRS = false; if (modelEntityData.Links == null) { modelEntityData.Links = new List <EntityLink>(); } modelEntityData.Links.Add(entityLink); return(entityLink); }
public override bool DoTest(BaseEntity ent) { BuildingBlock buildingBlock = ent as BuildingBlock; if (buildingBlock == null) { return(false); } EntityLink entityLink = ent.FindLink(stairs_sockets_female); if (entityLink == null) { return(false); } for (int i = 0; i < entityLink.connections.Count; i++) { BuildingBlock buildingBlock2 = entityLink.connections[i].owner as BuildingBlock; if (!(buildingBlock2 == null) && buildingBlock2.grade == buildingBlock.grade) { return(false); } } EntityLink entityLink2 = ent.FindLink(floor_sockets_female); if (entityLink2 == null) { return(true); } if (!entityLink2.IsEmpty()) { return(false); } return(true); }
public void BeforeEach() { _context = new GameContext(); _entity = _context.CreateEntity(); _gameObject = new GameObject("TestGameObject"); _link = _gameObject.AddComponent <EntityLink>(); }
// Use this for initialization private void Start() { BeforeStart(); EntityLink link = gameObject.GetEntityLink(); IContext context = GetContext(); if (link != null) { controllerEntity = (GameEntity)link.entity; controllerEntity.AddController(this); } else { controllerEntity = Contexts.sharedInstance.game.CreateEntity(); controllerEntity.AddController(this); controllerEntity.AddView(gameObject); gameObject.Link(controllerEntity); } CreateSystems(context); updateSystems.Initialize(); fixedUpdateSystems.Initialize(); lateUpdateSystems.Initialize(); AfterStart(); }
/// <summary> /// Adds constraints for the given link. /// </summary> /// <param name="linkName"></param> /// <param name="filterOperator"></param> /// <param name="relatedEntity"></param> public void AddConstraintsForLink(EntityLink link, SqlOperator filterOperator, IList relatedEntities) { if (link == null) { throw new ArgumentNullException("link"); } if (Creator == null) { throw new ArgumentNullException("Creator"); } if (relatedEntities == null) { throw new ArgumentNullException("relatedEntities"); } // check... if (link is ChildToParentEntityLink) { this.AddConstraintsForLink((ChildToParentEntityLink)link, filterOperator, relatedEntities); } else { throw new NotSupportedException(string.Format(Cultures.Exceptions, "Cannot handle '{0}'.", link.GetType())); } }
public void InitializeSupports() { this.supports = new List <StabilityEntity.Support>(); if (this.grounded) { return; } List <EntityLink> entityLinks = this.GetEntityLinks(true); for (int index = 0; index < entityLinks.Count; ++index) { EntityLink link = entityLinks[index]; if (link.IsMale()) { if (link.socket is StabilitySocket) { this.supports.Add(new StabilityEntity.Support(this, link, (link.socket as StabilitySocket).support)); } if (link.socket is ConstructionSocket) { this.supports.Add(new StabilityEntity.Support(this, link, (link.socket as ConstructionSocket).support)); } } } }
public override bool DoTest(BaseEntity ent) { EntityLink entityLink = ent.FindLink(socket); if (entityLink == null) { return(false); } for (int i = 0; i < entityLink.connections.Count; i++) { BuildingBlock buildingBlock = entityLink.connections[i].owner as BuildingBlock; if (!(buildingBlock == null) && !(buildingBlock.blockDefinition.info.name.token == "foundation_steps")) { if (buildingBlock.grade == BuildingGrade.Enum.TopTier) { return(false); } if (buildingBlock.grade == BuildingGrade.Enum.Metal) { return(false); } if (buildingBlock.grade == BuildingGrade.Enum.Stone) { return(false); } } } return(true); }
public static void MergeQuotations(List <KnowledgeItem> quotations) { // Static Variables Project project = Program.ActiveProjectShell.Project; if (project == null) { return; } Reference reference = quotations.FirstOrDefault().Reference; if (reference == null) { return; } List <Annotation> annotations = quotations.Where ( q => q.EntityLinks.Any() && q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication && e.Target is Annotation).Count() > 0 ) .Select ( q => ((Annotation) q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication && e.Target is Annotation).FirstOrDefault().Target) ) .ToList(); // The Magic List <QuotationType> quotationTypes = quotations.Select(q => q.QuotationType).Distinct().ToList(); var itemToRemove = quotationTypes.SingleOrDefault(q => q == QuotationType.Highlight); quotationTypes.Remove(itemToRemove); if (quotationTypes.Count > 1) { MessageBox.Show("Can't merge quotations, more than one type of quotation is selected."); return; } KnowledgeItem newQuotation = CombineQuotations(quotations); Annotation newAnnotation = CombineAnnotations(annotations); EntityLink newEntityLink = new EntityLink(project); newEntityLink.Source = newQuotation; newEntityLink.Target = newAnnotation; newEntityLink.Indication = EntityLink.PdfKnowledgeItemIndication; project.EntityLinks.Add(newEntityLink); reference.Quotations.RemoveRange(quotations); Program.ActiveProjectShell.ShowKnowledgeItemFormForExistingItem(Program.ActiveProjectShell.PrimaryMainForm, newQuotation); }
public bool CanConnect(EntityLink link) { if (this.IsOccupied() || link == null || link.IsOccupied()) { return(false); } return(this.socket.CanConnect(((Component)this.owner).get_transform().get_position(), ((Component)this.owner).get_transform().get_rotation(), link.socket, ((Component)link.owner).get_transform().get_position(), ((Component)link.owner).get_transform().get_rotation())); }
public string GenerateForeignKeyRollbackScript(EntityLink link) { string table = link.ForeignKeyField.Entity.EntityName; string keyTable = link.PrimaryKeyField.Entity.EntityName; string sql = $"ALTER TABLE [{table}] DROP CONSTRAINT [FK_{table}_{keyTable}];\n"; return(sql); }
public static EntityLink EntityLinkField(Rect rect, EntityLink value, Action <Data> entitySelectedCallback, Action <DataIdentifier, string> onDataIdentifierEntitySelectedCallback) { if (value == null) { value = new EntityLink(); } // TODO Icon var labelText = "None (EntityLink)"; if (value.IsDataIdentifierEntityLink) { labelText = $"{value.NameInArchive} (EntityLink)"; } else if (value.Entity != null) { labelText = $"{value.Entity.Name} (EntityLink)"; } var textFieldStyle = EditorStyles.textField; textFieldStyle.clipping = TextClipping.Clip; var mainButtonRect = rect; mainButtonRect.width -= 18; if (GUI.Button(mainButtonRect, labelText, textFieldStyle)) { if (value.IsDataIdentifierEntityLink) { if (value.DataIdentifier != null) { //DataListWindow.GetInstance().OpenDataSet(value.DataIdentifier.DataSetGuid, value.DataIdentifier.Name); } } else { if (value.Entity != null) { DataListWindow.GetInstance().OpenDataSet(value.Entity.DataSetGuid, value.Entity.Name); } } } var editorSkin = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector); var openButtonRect = rect; openButtonRect.width = 14; openButtonRect.position = new Vector2( mainButtonRect.position.x + mainButtonRect.width + 4, mainButtonRect.position.y); if (GUI.Button(openButtonRect, string.Empty, editorSkin.GetStyle("IN ObjectField"))) { SelectEntityWindow.Create(entitySelectedCallback, onDataIdentifierEntitySelectedCallback); } return(value); }
public static void AddLinks(this List <EntityLink> links, BaseEntity entity, Socket_Base[] sockets) { foreach (Socket_Base socket in sockets) { EntityLink entityLink = Pool.Get <EntityLink>(); entityLink.Setup(entity, socket); links.Add(entityLink); } }
/// <summary> /// Remove a static entity from the world /// </summary> /// <param name="entity">The Entity chunk linke</param> /// <param name="sourceDynamicId">The owner the event</param> /// <returns>Removed entity</returns> public IStaticEntity RemoveEntity(EntityLink entity, uint sourceDynamicId = 0) { IStaticEntity entityRemoved; var chunk = _manager.GetChunk(entity.ChunkPosition); chunk.Entities.RemoveById(entity.Tail[0], sourceDynamicId == 0 ? OwnerDynamicId : sourceDynamicId, out entityRemoved); return(entityRemoved); }
// Use DI in real application instead public void Init(EntityLink link) { _link = link; // Set initial position Transform.position = LinkedEntity.position.Value; // Set initial rotation Transform.LookAt(Transform.position + LinkedEntity.velocity.Value, Vector3.up); // Apply initial velocity Rigidbody.velocity = LinkedEntity.velocity.Value; }
public static void AddLinks(this List <EntityLink> links, BaseEntity entity, Socket_Base[] sockets) { for (int i = 0; i < (int)sockets.Length; i++) { Socket_Base socketBase = sockets[i]; EntityLink entityLink = Pool.Get <EntityLink>(); entityLink.Setup(entity, socketBase); links.Add(entityLink); } }
public static void FreeLinks(this List <EntityLink> links) { for (int i = 0; i < links.Count; i++) { EntityLink item = links[i]; item.Clear(); Pool.Free <EntityLink>(ref item); } links.Clear(); }
public static void FreeLinks(this List <EntityLink> links) { for (int i = 0; i < links.Count; i++) { EntityLink obj = links[i]; obj.Clear(); Pool.Free(ref obj); } links.Clear(); }
private static bool CheckSocketOccupied(BaseEntity ent, string socket) { EntityLink entityLink = ent.FindLink(socket); if (entityLink == null) { return(false); } return(!entityLink.IsEmpty()); }
public bool HasFloorSocketConnection() { EntityLink entityLink = FindLink("elevator/sockets/block-male"); if (entityLink != null && !entityLink.IsEmpty()) { return(true); } return(false); }
public override bool DoTest(BaseEntity ent) { EntityLink entityLink = ent.FindLink("ramp/sockets/block-male/1"); if (entityLink == null) { return(false); } return(!entityLink.IsEmpty()); }
private void btnSave_Click(object sender, EventArgs e) { this.Link = new EntityLink(); Link.ForeignKeyFieldId = (int)cboField.SelectedValue; Link.PrimaryKeyFieldId = (int)lblPrimaryKeyField.Tag; Link.LinkTypeCode = cboLinkType.SelectedValue.ToString(); Link.StatusCode = EntityLinkStatusCodes.Staged; this.DialogResult = DialogResult.OK; this.Close(); }
public override void CreateStaticNodesIfNotPresent() { base.CreateStaticNodesIfNotPresent(); if(InputEvents.Count != 3) { InputEvents.Clear(); EntityLink<MonsterTestBase> InputLink = new EntityLink<MonsterTestBase>(); InputLink.SetOwner(this); InputLink.Name = "Start New Game"; InputEvents.Add(InputLink); InputLink = new EntityLink<MonsterTestBase>(); InputLink.SetOwner(this); InputLink.Name = "Load Saved Game"; InputEvents.Add(InputLink); InputLink = new EntityLink<MonsterTestBase>(); InputLink.SetOwner(this); InputLink.Name = "Quit"; InputEvents.Add(InputLink); } if(OutputEvents.Count != 3) { EntityLink<MonsterTestBase> OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Game Started"; OutputEvents.Add(OutputLink); OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Game Failed To Start"; OutputEvents.Add(OutputLink); OutputLink = new EntityLink<MonsterTestBase>(); OutputLink.SetOwner(this); OutputLink.Name = "Quit"; OutputEvents.Add(OutputLink); } }
public override void TriggerLink(EntityLink<MonsterTestBase> InputLink) { base.TriggerLink(InputLink); if(InputLink.Name == "Start New Game") { bShouldStartNewGame = true; } else if(InputLink.Name == "Load Saved Game") { bShouldLoadGame = true; } else if(InputLink.Name == "Quit") { bShouldQuit = true; } }
// 2013-11-08 TRS: First commit with basic functionality. Uses GraphViz // for rendering graphs to human-viewable form. Only minimal // processing is implemented, i.e. scale timestamp-based weights // into [0.0, 1.0] and remove links lighter than 1%. // 2013-11-13 TRS: Adjusted processing so that new links are initialized // to t^2 and repeat links get t added. Postprocessing now scales and // applies a highpass filter at 90%. Also, filenames are now inlcuded // in the nodes; thanks Braden. // TODO: // - Make the DOT files prettier, e.g. different node styles for // different types. // - Improve/tune postprocessing. // - Add functional-style utilities (I love lisps). // Including classes tends to blow everyone else // away since classes contain everything but get // parsed in the same way; including comments and, // to a lesser extent, attributes makes the // graph noisy. // private static SourceCodeEntityType[] EXCLUDED_TYPES = { // SourceCodeEntityType.COMMENT, // SourceCodeEntityType.CLASS, // //SourceCodeEntityType.ATTRIBUTE, // //SourceCodeEntityType.METHOD, // }; public static Dictionary<EntityLink, double> gen_graph( GazeResults gaze_results, SourceCodeEntitiesFileCollection collection) { Dictionary<EntityLink,double> src2src_links = new Dictionary<EntityLink,double> (); HashSet <SourceCodeEntity> previous = null; HashSet <SourceCodeEntity> current = new HashSet <SourceCodeEntity>(); foreach (GazeData gaze_data in gaze_results.gazes) { // find out which SourceCodeEntity the subject // was looking at for this GazeData foreach (SourceCodeEntitiesFile file in collection) { if (gaze_data.filename != file.FileName) { continue; } foreach (SourceCodeEntity entity in file) { // if this GazeData looks at an ignored type, skip // if (((IList<SourceCodeEntityType>) EXCLUDED_TYPES).Contains( // entity.Type)) { // continue; // } // Sorry about the ugliness, but I hate code // duplication more than this; i"1.0" encoding=t should be // write-only, anyway. if (((gaze_data.line > entity.LineStart) && (gaze_data.line < entity.LineEnd)) || ((gaze_data.line == entity.LineStart) && (gaze_data.col >= entity.ColumnStart)) || ((gaze_data.line == entity.LineEnd) && (gaze_data.col <= entity.ColumnEnd))) { current.Add(entity); //break; } } } // if there was a change of entity, make a note of it if ((current != previous) && (previous != null) && (previous.Count > 0) && (current.Count > 0)) { EntityLink link = new EntityLink (); link.left = new HashSet <SourceCodeEntity> (previous); link.right = new HashSet <SourceCodeEntity> (current); if (src2src_links.ContainsKey (link)) { //src2src_links [link] += Math.Pow (gaze_data.timestamp, 2.0); src2src_links [link] += Math.Pow (100, gaze_data.timestamp); } else { //src2src_links [link] = Math.Pow (gaze_data.timestamp, 2.0); src2src_links [link] = Math.Pow (100, gaze_data.timestamp); } } previous = current; current = new HashSet <SourceCodeEntity> (); } return src2src_links; }
public override void TriggerLink(EntityLink<MonsterTestBase> InputLink) { base.TriggerLink(InputLink); }