public override void Update(GameTime gameTime) { base.Update(gameTime); if (this.Location.Owner != this.Owner || ((this.State == States.MOVING) && (this.Destination.Owner != this.Owner))) { this.Game.DynamicEntityList.Remove(this); } if (this.State == States.ATTACKING) { this.Velocity = Vector2.Zero; this.Attack(TargetEntity, gameTime); } if (HitPoint <= 0) { this.Game.DynamicEntityList.Remove(this); if (TargetEntity != null) { TargetEntity.SetVelocityAndRotation(); TargetEntity.State = States.MOVING; TargetEntity.TargetEntity = null; } } }
/// <summary> /// FIELD MUST BE IN PREIMAGE! Returns the effective value of the field in the context record (gets from the target /// entity or if not in gets from the preimage) /// </summary> public object GetField(string fieldName) { if (TargetEntity != null && TargetEntity.Contains(fieldName)) { return(TargetEntity[fieldName]); } else if (MessageName == PluginMessage.Create) { return(null); } else if (MessageName == PluginMessage.Update) { return(PreImageEntity.GetField(fieldName)); } else if (MessageName == PluginMessage.Delete) { return(null); } else { //not sure how to get status if a setstate message throw new InvalidPluginExecutionException("GetFieldMethod Not Implemented for plugin message " + MessageName); } }
public Insurrection(List <Property> properties, World world) : base(properties, world) { Filters = new List <string>(); foreach (Property property in properties) { switch (property.Name) { case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break; case "target_enid": TargetEntity = world.GetEntity(Convert.ToInt32(property.Value)); break; case "ordinal": Ordinal = Convert.ToInt32(property.Value); break; } } Name = "The " + GetOrdinal(Ordinal) + " Insurrection in " + Site; InsurrectionStarted insurrectionStart = Collection.OfType <InsurrectionStarted>().FirstOrDefault(); if (insurrectionStart != null) { insurrectionStart.ActualStart = true; } TargetEntity.AddEventCollection(this); Site.AddEventCollection(this); }
public override bool CanResolve(Entity owner, string key, bool fallback = false) { return((key == Constants.OutputArgumentName && CommandEntity.Decorate(owner).CommandName.Equals("deploy", StringComparison.OrdinalIgnoreCase)) || (key == EntityKeys.InternalDeployPathKey && TargetEntity.Decorate(owner).HasFullName)); }
public override void Execute() { var lead = TargetEntity.ToEntity <Lead>(); if (lead.NumberOfEmployees > 30) { var teamRepository = CdsRepositoryFactory.GetRepository <ITeamRepository>(); var team = teamRepository.GetSalesTeam(); if (team != null) { var taskRepository = CdsRepositoryFactory.GetRepository <ITaskRepository>(); taskRepository.Create(new Task() { Subject = "Important lead. Please do sales actions ASAP!", RegardingObjectId = lead.ToEntityReference(), OwnerId = team.ToEntityReference() }); taskRepository.SaveChanges(); } else { //Log information about missing sales team } } }
private void When(CommentCreatedEvent @event) { _creatorId = @event.CreatorId; _targetEntity = new TargetEntity(@event.EntityType, @event.EntityId); _text = @event.Text; _repliedCommentId = @event.RepliedCommentId; }
public void load_associated_when_target_is_null() { TargetEntity target = new TargetEntity { Id = 1, Name = "target", Associated = null }; SourceEntity source = new SourceEntity { Id = 1, Name = "source", Associated = new SourceAssociated { Id = 2, Name = "source_associated" } }; MapperContext context = new MapperContext(); var mapped = mapper.Map(source, target, context); Assert.NotNull(mapped.Associated); Assert.Null(mapped.Associated.Name); // properties are not mapped Assert.Equal(2, mapped.Associated.Id); // key is mapped // there is no tracking for disposed entity. Assert.False(context.TryGetEntry <TargetAssociated>(new EntityKey <int>(1), out MapperContextEntry entry)); // new entity is loaded. Assert.True(context.TryGetEntry <TargetAssociated>(new EntityKey <int>(2), out MapperContextEntry entry2)); Assert.Equal(MapperActionType.Attach, entry2.ActionType); }
public override Entity Resolve(Entity owner, string key, bool fallback = false) { if (key == EntityKeys.InternalDeployPathKey) { TargetEntity targetEntity = TargetEntity.Decorate(owner); BuildEntity buildEntity = BuildEntity.Decorate(owner); Entity project = owner.Root; CommandEntity commandOrigin = CommandEntity.Decorate(owner.Origin); VirtualDirectory outputRoot = fileSystem.GetDirectory(commandOrigin.Output, project.Path); VirtualDirectory deployRoot = outputRoot.Directory(targetEntity.FullName.Replace(',', '_'), buildEntity.BuildType); return(owner.Create(key, deployRoot.FullName, deployRoot)); } CommandEntity command = CommandEntity.Decorate(owner); FileEntity projectFileEntity = FileEntity.Decorate(owner.Root); string outputDirectory = command.GetSingleValueArgument(Constants.OutputArgumentName); if (string.IsNullOrEmpty(outputDirectory)) { outputDirectory = projectFileEntity.Directory .Directory(Constants.LibraryFolderName) .FullName; } return(owner.Create(key, outputDirectory)); }
public void Execute(Entity dataModel, ChangeObservable observable) { ProjectEntity project = ProjectEntity.Decorate(dataModel.Root); IEnumerable <Entity> targets = project.Targets.ToArray(); if (!targets.Any()) { throw new FormattableException("Please use --target to specify for which targets the library shall be generated."); } foreach (Entity target in targets) { VirtualDirectory deployRoot = DeployEntity.Decorate(target).DeployDirectory; VirtualDirectory deployDirectory = deployRoot.Directory("lib", project.Name); BuildEntity buildEntity = BuildEntity.Decorate(target); if (!buildEntity.HasBuildSystem) { TargetEntity targetEntity = TargetEntity.Decorate(target); executionContext.WriteWarning(new CMakeBuildSystemNotFoundException(targetEntity.FullName, buildEntity.BuildType).Message); return; } foreach (string externalLibrary in buildEntity.BuildSystem.ExternalLibraries) { VirtualFile newFile = fileSystem.GetFile(externalLibrary).CopyTo(deployDirectory); executionContext.Observable.OnNext(new Change(() => newFile.Delete(), $"Copied {externalLibrary} to {newFile.FullName}.")); } } }
public override void RemoveFromGame(GameTime gameTime) { this.IsAlive = false; if (this.Owner == Owners.ENEMY) { if (TargetEntity == null) { this.Game.Enemy.AddPath(UnitType.INFANTRY, this.VisitedPath); } else { this.Game.Enemy.AddPath(TargetEntity.unitType, this.VisitedPath); } } this.Game.DynamicEntityList.Remove(this); this.Location.Occupant = null; if (TargetEntity != null) { TargetEntity.State = States.STOPPED; //TargetEntity.OldState = States.NONE; TargetEntity.Update(gameTime); TargetEntity.TargetEntity = null; } if (TargetTown != null) { TargetTown.TargetEntity = null; } }
public void SetTargetShape(TargetShape shape, TargetEntity entity) { _targetShape = shape; _targetEntity = entity; // Reset actual tile _mouseTile = -1; }
/// <summary>Creates a new, empty TargetEntity object.</summary> /// <returns>A new, empty TargetEntity object.</returns> public override IEntity Create() { IEntity toReturn = new TargetEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewTarget // __LLBLGENPRO_USER_CODE_REGION_END return(toReturn); }
public override void Attack() { SoundManager.instanece.PlayEffect(1); base.Attack(); if (TargetEntity != null) { TargetEntity.TakeDamage(Damage); } }
internal static Comment Initialize(Guid userId, TargetEntity targetEntity, string text, Guid?repliedCommentId = null) { var comment = new Comment(Guid.NewGuid()); comment.ApplyChange(new CommentCreatedEvent(comment.Id, comment.GetNextVersion(), userId, targetEntity.Type, targetEntity.Id, text, repliedCommentId)); return(comment); }
public virtual void RaiseNewTargetEntity(TargetEntity e) { var targetEntityEvent = new TargetEntityEvent(this, e); var handler = NewTargetEntity; if (handler != null) { handler(this, targetEntityEvent); } }
private void loadSubject(TargetEntity te, XmlNode node) { DecisionNodeEntity ce = new DecisionNodeEntity(); TargetConditionEntity tce = new TargetConditionEntity(); tce.Target = te; tce.DecisionNode = ce; loadCondition(ce, node); }
public void map_owned_collection_null_keys() { TargetEntity target = new TargetEntity { Id = 1, Name = "target_root", OwnedList = new List <TargetOwnedItem> { new TargetOwnedItem { Id = 1, Name = "Item 1" }, new TargetOwnedItem { Id = 2, Name = "Item 2" }, new TargetOwnedItem { Id = 3, Name = "Item 3" }, } }; SourceEntityStringKey source = new SourceEntityStringKey { Id = "1", Name = "target_root", OwnedList = new List <SourceOwnedItemStringKey> { new SourceOwnedItemStringKey { Id = "2", Name = "Item 2" }, new SourceOwnedItemStringKey { Name = "Item 4" }, // new has null key. } }; MapperContext context = new MapperContext(); TargetEntity mapped = mapper.Map(source, target, context); Assert.NotNull(mapped.OwnedList); Assert.Equal(2, mapped.OwnedList.Count); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(1), out MapperContextEntry entry1)); Assert.Equal(MapperActionType.Delete, entry1.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(2), out MapperContextEntry entry2)); Assert.Equal(MapperActionType.Update, entry2.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(3), out MapperContextEntry entry3)); Assert.Equal(MapperActionType.Delete, entry3.ActionType); Assert.True(context.TryGetEntry <TargetOwnedItem>(new EntityKey <int>(0), out MapperContextEntry entry4)); Assert.Equal(MapperActionType.Create, entry4.ActionType); }
private void StartShooting() { Loaded = false; StartCoroutine(Shoot(SHOOTING_TIME)); _audioManager.PlaySound(_audioSource, "Gun"); if (_aim.TargetCentered(_shootingPosition, TargetEntity.Transform.tag, Id)) { TargetEntity.Die(_turretHead); } }
public async Task Write(TargetEntity entity) { using var dynamoDbClient = new AmazonDynamoDBClient(new BasicAWSCredentials(accessKey, secretKey), RegionEndpoint.GetBySystemName(regionName)); await dynamoDbClient.PutItemAsync(tableName, new Dictionary <string, AttributeValue> { { "Folder", new AttributeValue(entity.Folder) }, { "Id", new AttributeValue(entity.Id) }, { "Name", new AttributeValue(entity.Name) }, { "PasswordHash", new AttributeValue(entity.PasswordHash) }, { "Created", new AttributeValue(entity.Created) } }); }
public void MapPropertiesShouldCopyProperties() { var source = CreateSourceEntity(); var target = new TargetEntity(); IObjectConverter converter = new ObjectConverter(); converter.MapProperties(source, target); Assert.AreEqual(source.Id, target.Id); Assert.AreEqual(source.Username, target.Username); }
private void CopyExternalLibrariesToOutputDirectory(Entity target, Dictionary <Entity, VirtualFile> projectLibraries, out IEnumerable <string> externalLibraries, out IEnumerable <VirtualFile> copiedLibraries) { VirtualDirectory deployDirectory = DeployEntity.Decorate(target).DeployDirectory; VirtualDirectory externalDirectory = deployDirectory.Directory("auto-deployed-external-libraries"); externalDirectory.Clear(); executionContext.Observable.OnNext(new Change(() => externalDirectory.UnClear(), "Cleared automatic copied external libraries.")); externalLibraries = Enumerable.Empty <string>(); copiedLibraries = Enumerable.Empty <VirtualFile>(); List <VirtualFile> newLibraryFiles = new List <VirtualFile>(); if (deployDirectory.Files("*.so", true).Except(projectLibraries.Values).Any()) { externalLibraries = deployDirectory.Files("*.so", true).Except(projectLibraries.Values) .Select(f => f.FullName).ToArray(); //external libraries where copied by user; no further action is required return; } BuildEntity buildEntity = BuildEntity.Decorate(target); if (!buildEntity.HasBuildSystem) { TargetEntity targetEntity = TargetEntity.Decorate(target); executionContext.WriteWarning(new CMakeBuildSystemNotFoundException(targetEntity.FullName, buildEntity.BuildType).Message); return; } externalLibraries = buildEntity.BuildSystem.ExternalLibraries; TargetEntity entity = TargetEntity.Decorate(target); if (entity.Version >= new Version(20, 6)) { foreach (string externalLibrary in buildEntity.BuildSystem.ExternalLibraries) { VirtualFile newFile = fileSystem.GetFile(externalLibrary).CopyTo(deployDirectory); newLibraryFiles.Add(newFile); executionContext.Observable.OnNext(new Change(() => newFile.Delete(), $"Copied {externalLibrary} to {newFile.FullName}.")); } } else { foreach (string externalLibrary in buildEntity.BuildSystem.ExternalLibraries) { executionContext.WriteWarning($"The library {externalLibrary} must be transferred to the device {entity.FullName} into the directory \"usr/local/lib\" manually."); } } copiedLibraries = newLibraryFiles; }
public void replace_owned_entity_when_key_not_matching() { // GIVEN models SourceDTO source = new SourceDTO { Id = 1, Name = "dto", Owned = new OwnedDTO { Id = 2, Name = "owned_dto" } }; TargetEntity target = new TargetEntity { Id = 1, Name = "entity", ExtraProperty = "extra_prop_not_mapped", Owned = new OwnedEntity { Id = 3, Name = "owned_entity" } }; int targetCheck = target.GetHashCode(); int ownedCheck = target.Owned.GetHashCode(); MapperContext context = new MapperContext(); // WHEN mapped TargetEntity mapped = mapper.Map(source, target, context); // THEN Assert.Equal(targetCheck, mapped.GetHashCode()); // root is merged Assert.Equal(1, mapped.Id); Assert.Equal("dto", mapped.Name); Assert.Equal("extra_prop_not_mapped", mapped.ExtraProperty); // extra property is not overwritten Assert.NotNull(mapped.Owned); Assert.NotEqual(ownedCheck, target.Owned.GetHashCode()); // owned is replaced Assert.Equal(2, mapped.Owned.Id); Assert.Equal("owned_dto", mapped.Owned.Name); Assert.True(context.TryGetEntry <OwnedEntity>(new EntityKey <int>(2), out MapperContextEntry createdEntry)); Assert.Equal(MapperActionType.Create, createdEntry.ActionType); Assert.True(context.TryGetEntry <OwnedEntity>(new EntityKey <int>(3), out MapperContextEntry deletedEntry)); Assert.Equal(MapperActionType.Delete, deletedEntry.ActionType); }
/// <summary> /// FIELD MUST BE IN PREIMAGE! Returns the effective value of the field in the context record (gets from the target /// entity or if not in gets from the preimage) /// </summary> public IEnumerable <Entity> GetActivityParties(string fieldName) { if (TargetEntity.Contains(fieldName)) { return(TargetEntity.GetActivityParties(fieldName)); } else if (!IsMessage(PluginMessage.Create)) { var lookThisUp = XrmService.Retrieve(TargetType, TargetId, new[] { fieldName }); PreImageEntity.SetField(fieldName, lookThisUp.GetField(fieldName)); return(PreImageEntity.GetActivityParties(fieldName)); } return(new Entity[0]); }
public EntityPersecuted(List <Property> properties, World world) : base(properties, world) { ExpelledHfs = new List <HistoricalFigure>(); ExpelledCreatures = new List <int>(); ExpelledPopIds = new List <int>(); ExpelledNumbers = new List <int>(); PropertyConfiscatedFromHfs = new List <HistoricalFigure>(); foreach (Property property in properties) { switch (property.Name) { case "persecutor_hfid": PersecutorHf = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break; case "persecutor_enid": PersecutorEntity = world.GetEntity(Convert.ToInt32(property.Value)); break; case "target_enid": TargetEntity = world.GetEntity(Convert.ToInt32(property.Value)); break; case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break; case "shrine_amount_destroyed": ShrineAmountDestroyed = Convert.ToInt32(property.Value); break; case "destroyed_structure_id": DestroyedStructureId = Convert.ToInt32(property.Value); break; case "property_confiscated_from_hfid": PropertyConfiscatedFromHfs.Add(world.GetHistoricalFigure(Convert.ToInt32(property.Value))); break; case "expelled_hfid": ExpelledHfs.Add(world.GetHistoricalFigure(Convert.ToInt32(property.Value))); break; case "expelled_creature": ExpelledCreatures.Add(Convert.ToInt32(property.Value)); break; case "expelled_pop_id": ExpelledPopIds.Add(Convert.ToInt32(property.Value)); break; case "expelled_number": ExpelledNumbers.Add(Convert.ToInt32(property.Value)); break; } } if (Site != null) { DestroyedStructure = Site.Structures.FirstOrDefault(structure => structure.Id == DestroyedStructureId); DestroyedStructure.AddEvent(this); } PersecutorHf.AddEvent(this); PersecutorEntity.AddEvent(this); TargetEntity.AddEvent(this); Site.AddEvent(this); foreach (HistoricalFigure expelledHf in ExpelledHfs.Where(eHf => eHf != HistoricalFigure.Unknown)) { expelledHf.AddEvent(this); } }
static public TargetEntity dupTarget(TargetEntity original) { TargetEntity copy = new TargetEntity(original.Id); duplicator.MarkEntityDirty(copy); copy.IsNew = true; foreach (TargetConditionEntity tce in original.TargetCondition) { TargetConditionEntity tceCopy = new TargetConditionEntity(); tceCopy.DecisionNode = dupCondition(tce.DecisionNode); tceCopy.Target = copy; } return(copy); }
public override void Attack() { base.Attack(); if (TargetEntity != null) { Vector3 effectpos = new Vector3(TargetEntity.transform.position.x, TargetEntity.transform.position.y + 5f, TargetEntity.transform.position.z); var ef = Instantiate(effect, effectpos, transform.rotation); if (ef != null) { ef.gameObject.SetActive(true); } TargetEntity.TakeDamage(Damage); } }
private metaDataTemplate FindFieldTemplate(string name, Entity owner) { IEnumerable <metaDataTemplate> possibleTemplates = templateRepository.FieldTemplates.Where(t => t.name.Equals(name, StringComparison.OrdinalIgnoreCase) && FirmwareVersionIsSupported(t.supportedFirmwareVersions)); metaDataTemplate fieldTemplate = NewestTemplate(possibleTemplates); return(fieldTemplate); bool FirmwareVersionIsSupported(string supportedFirmwareVersion) { if (supportedFirmwareVersion == null) { return(true); } ProjectEntity project = ProjectEntity.Decorate(owner.IsRoot() ? owner : owner.Root); Version minTarget = project.Targets.Min(t => TargetEntity.Decorate(t).Version); if (minTarget == null) { return(true); } NuGetVersion targetVersion = new NuGetVersion(minTarget); if (VersionRange.TryParse(supportedFirmwareVersion, out VersionRange supportedVersion)) { return(supportedVersion.Satisfies(targetVersion)); } return(true); } metaDataTemplate NewestTemplate(IEnumerable <metaDataTemplate> templates) { IEnumerable <metaDataTemplate> templatesWithVersion = templates.Where(t => t.supportedFirmwareVersions != null); if (!templatesWithVersion.Any()) { return(templates.FirstOrDefault()); } return(templatesWithVersion.Where(template => template.supportedFirmwareVersions.Equals( templatesWithVersion.Max(t => t.supportedFirmwareVersions), StringComparison.OrdinalIgnoreCase)) .FirstOrDefault()); } }
public void map_back_reference() { TargetEntity target = new TargetEntity { Id = 1, Name = "target_root", OwnedList = new List <TargetOwnedItem> { new TargetOwnedItem { Id = 1, Name = "Item 1" }, new TargetOwnedItem { Id = 2, Name = "Item 2" }, new TargetOwnedItem { Id = 3, Name = "Item 3" }, } }; SourceEntity source = new SourceEntity { Id = 1, Name = "target_root", OwnedList = new List <SourceOwnedItem> { new SourceOwnedItem { Id = 1, Name = "Item 1" }, new SourceOwnedItem { Id = 2, Name = "Item 2" }, new SourceOwnedItem { Id = 3, Name = "Item 3" }, } }; MapperContext context = new MapperContext(); var mapped = mapper.Map(source, target, context); Assert.Equal(mapped, mapped.OwnedList[0].Parent); Assert.Equal(mapped, mapped.OwnedList[1].Parent); Assert.Equal(mapped, mapped.OwnedList[2].Parent); }
public void map_associated_collection() { TargetEntity target = new TargetEntity { Id = 1, Name = "target_root", AssociatedList = new List <TargetAssociatedItem> { new TargetAssociatedItem { Id = 1, Name = "Item 1" }, new TargetAssociatedItem { Id = 2, Name = "Item 2" }, new TargetAssociatedItem { Id = 3, Name = "Item 3" }, } }; SourceEntity source = new SourceEntity { Id = 1, Name = "target_root", AssociatedList = new List <SourceAssociatedItem> { new SourceAssociatedItem { Id = 2, Name = "Item 2" }, new SourceAssociatedItem { Id = 4, Name = "Item 4" }, } }; MapperContext context = new MapperContext(); var mapped = mapper.Map(source, target, context); Assert.NotNull(mapped.AssociatedList); Assert.Equal(2, mapped.AssociatedList.Count); Assert.True(context.TryGetEntry <TargetAssociatedItem>(new EntityKey <int>(4), out MapperContextEntry entry4)); Assert.Equal(MapperActionType.Attach, entry4.ActionType); }
/// <summary> /// MAYBE TRUE FOR DELETE! FIELD MUST BE IN PREIMAGE FOR UPDATE STEP! Returns if the fields value is logically changing /// by inspecting the Target and Preimage /// </summary> public bool FieldChanging(string fieldName) { if (MessageName == PluginMessage.Create || MessageName == PluginMessage.Update) { return(TargetEntity.Contains(fieldName) && !XrmEntity.FieldsEqual(PreImageEntity.GetField(fieldName), TargetEntity.GetField(fieldName))); } else if (MessageName == PluginMessage.Delete) { return(GetFieldFromPreImage(fieldName) != null); } else { //not sure how to get status if a setstate message throw new InvalidPluginExecutionException("FieldChanging Not Implemented for plugin message " + MessageName); } }