public void IncludesEntityGroup() { var component = PlayerComponent.Create(); JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save()); Assert.Equal(PlayerComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString()); }
public static Entity CreatePlayerEntity(int currentTick) { var e = CreateEntity(Guid.NewGuid().ToString(), "You"); // TODO: modify PlayerAIComponent to it doesn't, you know...need these. e.AddComponent(new PlayerAIComponent()); e.AddComponent(AIRotationComponent.Create(.60, true)); e.AddComponent(AIMoraleComponent.Create(100, 100)); var statusEffectTrackerComponent = StatusEffectTrackerComponent.Create(); e.AddComponent(ActionTimeComponent.Create(currentTick)); e.AddComponent(AttackerComponent.Create(e.EntityId, power: 8, meleeAttack: 55, rangedAttack: 10)); // TODO: make player not Ares e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: false)); e.AddComponent(DefenderComponent.Create(baseDefense: 0, maxHp: 70, maxFooting: 95, meleeDefense: 30, rangedDefense: 60, isInvincible: false)); e.AddComponent(DisplayComponent.Create(_texPlayerPath, "It's you!", false, ENTITY_Z_INDEX)); e.AddComponent(FactionComponent.Create(FactionName.PLAYER)); e.AddComponent(OnDeathComponent.Create(new List <string>() { OnDeathEffectType.PLAYER_DEFEAT })); e.AddComponent(PlayerComponent.Create(isInFormation: true)); e.AddComponent(SpeedComponent.Create(baseSpeed: 100)); e.AddComponent(statusEffectTrackerComponent); e.AddComponent(XPTrackerComponent.Create(levelUpBase: 200, levelUpFactor: 150)); return(e); }
public void EntityWithComponent() { Entity entity = Entity.Create("some id", "some name"); entity.AddComponent(PlayerComponent.Create(baseCuttingLaserPower: 99)); var saved = JsonSerializer.Serialize(entity); var loaded = JsonSerializer.Deserialize <Entity>(saved); Assert.Equal(entity._Components.Count, loaded._Components.Count); Assert.NotNull(loaded.GetComponent <PlayerComponent>()); Assert.Equal(99, loaded.GetComponent <PlayerComponent>().BaseCuttingLaserPower); }
public void SerializesAndDeserializesAutopilotZoneCorrectly() { var zoneId = "123854"; var component = PlayerComponent.Create(); component.BeginAutoexploring(zoneId); string saved = component.Save(); var newComponent = PlayerComponent.Create(saved); Assert.Equal(component.ActiveAutopilotMode, newComponent.ActiveAutopilotMode); Assert.Null(component.AutopilotPath); Assert.Equal(component.AutopilotPath, newComponent.AutopilotPath); Assert.Equal(component.AutopilotZoneId, newComponent.AutopilotZoneId); }
public void PullsStatusEffectTrackerFromEntity() { var entity = Entity.Create("", ""); var playerComponent = PlayerComponent.Create(baseCuttingLaserPower: 5); entity.AddComponent(playerComponent); var trackerComponent = new StatusEffectTrackerComponent(); entity.AddComponent(trackerComponent); Assert.Equal(5, playerComponent.CuttingLaserPower); trackerComponent.AddEffect(new StatusEffectTimedPowerBoost(10, 5, 5)); Assert.Equal(15, playerComponent.CuttingLaserPower); }
public static Entity CreatePlayerEntity(int currentTick) { var e = CreateEntity(Guid.NewGuid().ToString(), "player"); var statusEffectTrackerComponent = StatusEffectTrackerComponent.Create(); e.AddComponent(ActionTimeComponent.Create(currentTick)); e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: false)); e.AddComponent(DefenderComponent.Create(baseDefense: 0, maxHp: 100, isInvincible: false)); e.AddComponent(DisplayComponent.Create(_texPlayerPath, "It's you!", false, ENTITY_Z_INDEX)); e.AddComponent(InventoryComponent.Create(inventorySize: 26)); e.AddComponent(OnDeathComponent.Create(new List <string>() { OnDeathEffectType.PLAYER_DEFEAT })); e.AddComponent(PlayerComponent.Create()); e.AddComponent(SpeedComponent.Create(baseSpeed: 100)); e.AddComponent(statusEffectTrackerComponent); e.AddComponent(XPTrackerComponent.Create(levelUpBase: 200, levelUpFactor: 150)); return(e); }
public void SerializesAndDeserializesCorrectly() { var path = new EncounterPath(new List <EncounterPosition>() { new EncounterPosition(15, 53) }); var component = PlayerComponent.Create(); component.LayInAutopilotPathForTravel(path); component.RegisterIntel(3); string saved = component.Save(); var newComponent = PlayerComponent.Create(saved); Assert.Equal(component.KnowsIntel(0), newComponent.KnowsIntel(0)); Assert.Equal(component.KnowsIntel(1), newComponent.KnowsIntel(1)); Assert.Equal(component.KnowsIntel(2), newComponent.KnowsIntel(2)); Assert.Equal(component.KnowsIntel(3), newComponent.KnowsIntel(3)); Assert.Equal(component.CuttingLaserRange, newComponent.CuttingLaserRange); Assert.Equal(component.BaseCuttingLaserPower, newComponent.BaseCuttingLaserPower); Assert.Equal(component.ActiveAutopilotMode, newComponent.ActiveAutopilotMode); Assert.Equal(component.AutopilotPath.CurrentPosition, newComponent.AutopilotPath.CurrentPosition); }