public static TitlePacket GenerateTitle(this ICharacterEntity visualEntity) { var data = visualEntity.Titles.Select(s => new TitleSubPacket { TitleId = (short)(s.TitleType - 9300), TitleStatus = (byte)((s.Visible ? 2 : 0) + (s.Active ? 4 : 0) + 1) }).ToList() as List <TitleSubPacket?>; return(new TitlePacket { Data = data.Any() ? data : null }); }
public static TitleInfoPacket GenerateTitInfo(this ICharacterEntity visualEntity) { var visibleTitle = visualEntity.Titles.FirstOrDefault(s => s.Visible)?.TitleType; var effectiveTitle = visualEntity.Titles.FirstOrDefault(s => s.Active)?.TitleType; return(new TitleInfoPacket { VisualId = visualEntity.VisualId, EffectiveTitle = effectiveTitle ?? 0, VisualType = visualEntity.VisualType, VisibleTitle = visibleTitle ?? 0, }); }
//in 9 {vnum} {id} {x} {y} {amount} {IsQuestRelative} 0 {owner} //in 3 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 2 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 1 {IsSitting} {GroupId} {HaveFairy} {FairyElement} 0 {FairyMorph} 0 {Morph} {EqRare} {FamilyId} {SecondName} {Reput} {Invisible} {MorphUpgrade} {faction} {MorphUpgrade2} {Level} {FamilyLevel} {ArenaWinner} {Compliment} {Size} {HeroLevel} //in 1 Carlosta - 754816 71 105 2 0 1 0 14 3 340.4855.4867.4864.4846.802.4150.4142 100 37 0 -1 4 3 0 0 0 7 86 86 2340 ~Luna~(Membre) -2 0 5 0 0 88 10 0 0 10 1 //Character in packet public static InPacket GenerateIn(this ICharacterEntity visualEntity, string prefix) { return(new InPacket { VisualType = visualEntity.VisualType, Name = prefix + visualEntity.Name, VNum = visualEntity.VNum == 0 ? string.Empty : visualEntity.VNum.ToString(), VisualId = visualEntity.VisualId, PositionX = visualEntity.PositionX, PositionY = visualEntity.PositionY, Direction = visualEntity.Direction, InCharacterSubPacket = new InCharacterSubPacket { Authority = visualEntity.Authority, Gender = visualEntity.Gender, HairStyle = (byte)visualEntity.HairStyle, HairColor = (byte)visualEntity.HairColor, Class = visualEntity.Class, Equipment = visualEntity.Equipment, InAliveSubPacket = new InAliveSubPacket { Hp = (int)(visualEntity.Hp / (float)visualEntity.MaxHp * 100), Mp = (int)(visualEntity.Mp / (float)visualEntity.MaxMp * 100) }, IsSitting = visualEntity.IsSitting, GroupId = visualEntity.Group.GroupId, Fairy = 0, FairyElement = 0, Unknown = 0, Morph = 0, Unknown2 = 0, Unknown3 = 0, WeaponUpgradeRareSubPacket = visualEntity.WeaponUpgradeRareSubPacket, ArmorUpgradeRareSubPacket = visualEntity.ArmorUpgradeRareSubPacket, FamilyId = -1, FamilyName = string.Empty, ReputIco = (short)(visualEntity.DignityIcon == 1 ? visualEntity.ReputIcon : -visualEntity.DignityIcon), Invisible = false, MorphUpgrade = 0, Faction = 0, MorphUpgrade2 = 0, Level = visualEntity.Level, FamilyLevel = 0, ArenaWinner = false, Compliment = (short)(visualEntity.Authority == AuthorityType.Moderator ? 500 : 0), Size = visualEntity.Size, HeroLevel = visualEntity.HeroLevel } }); }
private void AmbiantSoundProcessing(VisualChunk chunk, ICharacterEntity player) { ChunkColumnInfo columnInfo = chunk.BlockData.GetColumnInfo(player.Position.ToCubePosition().X - chunk.ChunkPositionBlockUnit.X, player.Position.ToCubePosition().Z - chunk.ChunkPositionBlockUnit.Y); bool playerAboveMaxChunkheight = (columnInfo.MaxHeight - player.Position.ToCubePosition().Y < -15); bool playerBelowMaxChunkheight = (columnInfo.MaxHeight - player.Position.ToCubePosition().Y > 15); Biome currentBiome = _biomesParams.Biomes[chunk.BlockData.ChunkMetaData.ChunkMasterBiomeType]; //Ambiant sound are just for surface "chunk", if not stop playing them ! if (playerAboveMaxChunkheight || playerBelowMaxChunkheight || player.HealthState == DynamicEntityHealthState.Dead) { if (_currentlyPLayingAmbiantSound != null) { if (_currentlyPLayingAmbiantSound.IsPlaying) { _currentlyPLayingAmbiantSound.Stop(1000); _currentlyPLayingAmbiantSound = null; } _previousBiomePlaying = null; } return; } //IF first pass or biome did change or currently player sound is finished if ( _previousBiomePlaying == null || currentBiome != _previousBiomePlaying || (_currentlyPLayingAmbiantSound != null && _currentlyPLayingAmbiantSound.IsPlaying == false) ) { if (_currentlyPLayingAmbiantSound != null) { if (_currentlyPLayingAmbiantSound.IsPlaying) { _currentlyPLayingAmbiantSound.Stop(1000); _currentlyPLayingAmbiantSound = null; } } //Pickup next biome ambiant sound, and start it ! if (currentBiome.AmbientSound.Count > 0) { int nextAmbientSoundId = _rnd.Next(0, currentBiome.AmbientSound.Count); _currentlyPLayingAmbiantSound = _soundEngine.StartPlay2D(currentBiome.AmbientSound[nextAmbientSoundId].Alias, SourceCategory.Music, false, 3000); _previousBiomePlaying = currentBiome; } } }
public void UpdateEntity(ICharacterEntity entity) { VisualDynamicEntity visualEntity; if (!_dynamicEntitiesDico.TryGetValue(entity.DynamicId, out visualEntity)) { return; } var oldEntity = visualEntity.DynamicEntity; entity.ModelInstance = oldEntity.ModelInstance; visualEntity.DynamicEntity = entity; visualEntity.Entity = entity; }
protected override void ApplyMovement(Vector2Int[] path, ICharacterEntity trackedCharacter, IEntityWithBoardPresence targetedEntity) { FightState instance = FightState.instance; if (instance != null) { if (targetedEntity != null) { instance.frame.SendEntityAttack(trackedCharacter.id, path, targetedEntity.id); } else if (path.Length > 1) { instance.frame.SendEntityMovement(trackedCharacter.id, path); } } }
/// <summary> /// Creates new instance of EntityMessageTranslator /// </summary> public EntityMessageTranslator( ServerComponent server, PlayerEntityManager playerEntityManager, IVisualDynamicEntityManager dynamicEntityManager, IChunkEntityImpactManager landscapeManager, SyncManager syncManager) { _server = server; //Handle Entity received Message from Server _server.MessageEntityIn += ServerMessageEntityIn; _server.MessageEntityOut += ServerMessageEntityOut; _server.MessagePosition += ServerMessagePosition; _server.MessageDirection += ServerMessageDirection; _server.MessageEntityLock += ServerMessageEntityLock; _server.MessageEntityUse += _server_MessageEntityUse; _server.MessageEntityEquipment += _server_MessageEntityEquipment; _server.MessageUseFeedback += _server_MessageUseFeedback; _server.MessageItemTransfer += _server_MessageItemTransfer; _server.MessageEntityVoxelModel += ServerOnMessageEntityVoxelModel; _server.MessageEntityHealth += _server_MessageEntityHealth; _server.MessageEntityHealthState += _server_MessageEntityHealthState; _server.MessageEntityAfflictionState += _server_MessageEntityAfflictionState; if (dynamicEntityManager == null) { throw new ArgumentNullException("dynamicEntityManager"); } if (landscapeManager == null) { throw new ArgumentNullException("landscapeManager"); } if (syncManager == null) { throw new ArgumentNullException("syncManager"); } if (playerEntityManager == null) { throw new ArgumentNullException("playerEntityManager"); } _dynamicEntityManager = dynamicEntityManager; _landscapeManager = landscapeManager; _syncManager = syncManager; PlayerEntity = playerEntityManager.PlayerCharacter; playerEntityManager.PlayerEntityChanged += (sender, args) => { PlayerEntity = args.PlayerCharacter; }; }
public async Task RunScriptAsync(ICharacterEntity character, ScriptClientPacket?packet) { if (character.CurrentScriptId == null) //todo handle other acts { if (_worldConfiguration.Value.SceneOnCreate) { await character.SendPacketAsync(new ScenePacket { SceneId = 40 }).ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(71)).ConfigureAwait(false); } await Task.Delay(TimeSpan.FromSeconds(2)).ConfigureAwait(false); } if (packet != null) { if (!await CheckScriptStateAsync(packet, character).ConfigureAwait(false)) { return; } if (packet.Type == QuestActionType.Achieve) { var quest = character.Quests.Values.FirstOrDefault(s => s.Quest.QuestId == packet.FirstArgument); if (quest != null) { quest.CompletedOn = DateTime.Now; await character.SendPacketAsync(quest.GenerateQstiPacket(false)).ConfigureAwait(false); } } } var scripts = _scripts.OrderBy(s => s.ScriptId).ThenBy(s => s.ScriptStepId).ToList(); var nextScript = scripts.FirstOrDefault(s => (s.ScriptId == (character.Script?.ScriptId ?? 0)) && (s.ScriptStepId > (character.Script?.ScriptStepId ?? 0))) ?? scripts.FirstOrDefault(s => s.ScriptId > (character.Script?.ScriptId ?? 0)); if (nextScript == null) { return; } character.CurrentScriptId = nextScript.Id; character.Script = nextScript; await character.SendPacketAsync(new ScriptPacket() { ScriptId = nextScript.ScriptId, ScriptStepId = nextScript.ScriptStepId }).ConfigureAwait(false); }
private void MoodSoundProcessing(ICharacterEntity player) { MoodSoundKey currentMood = new MoodSoundKey() { TimeOfDay = GetTimeofDay(), Type = GetMoodType(player) }; //No sound was playing, or a new one needs to be played if (_currentlyPlayingMoodSound == null || _currentlyPlayingMoodSound.IsPlaying == false || _previousMood == null || _previousMood != currentMood) { StartNewMoodSound(currentMood); _previousMood = currentMood; } }
/// <summary> /// Initializes a new instance of the <see cref="BaseEntityState"/> class. /// </summary> /// <param name="nStateID">N state I.</param> /// <param name="entity">Entity.</param> public BaseEntityState(int nStateID, IEntity entity) : base(nStateID) { m_ResourceManager = GameEngine.GetSingleton().QueryPlugin<IResourceManager>(); if (!m_ResourceManager) throw new System.NullReferenceException(); m_PlayerManager = GameEngine.GetSingleton().QueryPlugin<PlayerManager>(); if (!m_PlayerManager) throw new System.NullReferenceException(); m_MonsterManager = GameEngine.GetSingleton().QueryPlugin<MonsterManager>(); if (!m_MonsterManager) throw new System.NullReferenceException(); m_Entity = entity as ICharacterEntity; }
public void Dispose() { PlayerEntity = null; _server.MessageEntityIn -= ServerMessageEntityIn; _server.MessageEntityOut -= ServerMessageEntityOut; _server.MessagePosition -= ServerMessagePosition; _server.MessageDirection -= ServerMessageDirection; _server.MessageEntityLock -= ServerMessageEntityLock; _server.MessageEntityUse -= _server_MessageEntityUse; _server.MessageEntityEquipment -= _server_MessageEntityEquipment; _server.MessageUseFeedback -= _server_MessageUseFeedback; _server.MessageItemTransfer -= _server_MessageItemTransfer; _server.MessageEntityVoxelModel -= ServerOnMessageEntityVoxelModel; _server.MessageEntityHealth -= _server_MessageEntityHealth; _server.MessageEntityHealthState -= _server_MessageEntityHealthState; _server.MessageEntityAfflictionState -= _server_MessageEntityAfflictionState; }
public bool TryGetPlayableCharacterAt(Vector2Int position, out ICharacterEntity character) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) foreach (EntityStatus value in m_entities.Values) { ICharacterEntity characterEntity; if (!value.isDirty && (characterEntity = (value as ICharacterEntity)) != null && characterEntity.area.Intersects(position)) { if (!IsCharacterPlayable(characterEntity)) { break; } character = characterEntity; return(true); } } character = null; return(false); }
public bool TryGetEntity <T>(DynamicValueContext context, out T entity) where T : class, IEntity { CharacterActionValueContext characterActionValueContext = context as CharacterActionValueContext; if (characterActionValueContext != null) { ICharacterEntity relatedCharacterStatus = characterActionValueContext.relatedCharacterStatus; if (relatedCharacterStatus is T) { entity = (T)relatedCharacterStatus; return(true); } } else { Log.Error($"Cannot use Effect Holder in {context}", 23, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\TargetSelectors\\EffectHolderSelector.cs"); } entity = null; return(false); }
//in 9 {vnum} {id} {x} {y} {amount} {IsQuestRelative} 0 {owner} //in 3 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 2 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 1 {IsSitting} {GroupId} {HaveFairy} {FairyElement} 0 {FairyMorph} 0 {Morph} {EqRare} {FamilyId} {SecondName} {Reput} {Invisible} {MorphUpgrade} {faction} {MorphUpgrade2} {Level} {FamilyLevel} {ArenaWinner} {Compliment} {Size} {HeroLevel} //in 1 Carlosta - 754816 71 105 2 0 1 0 14 3 340.4855.4867.4864.4846.802.4150.4142 100 37 0 -1 4 3 0 0 0 7 86 86 2340 ~Luna~(Membre) -2 0 5 0 0 88 10 0 0 10 1 //Character in packet public static InPacket GenerateIn(this ICharacterEntity visualEntity) { return(new InPacket { VisualType = visualEntity.VisualType, Name = visualEntity.Name, VNum = visualEntity.VNum == 0 ? string.Empty : visualEntity.VNum.ToString(), VisualId = visualEntity.VisualId, PositionX = visualEntity.PositionX, PositionY = visualEntity.PositionY, Direction = visualEntity.Direction, InCharacterSubPacket = new InCharacterSubPacket { Authority = visualEntity.Authority, Gender = (byte)visualEntity.Gender, HairStyle = (byte)visualEntity.HairStyle, HairColor = (byte)visualEntity.HairColor, Class = visualEntity.Class, Equipment = new InEquipmentSubPacket { Armor = -1, CostumeHat = -1, CostumeSuit = -1, Fairy = -1, Hat = -1, MainWeapon = -1, Mask = -1, SecondaryWeapon = -1, WeaponSkin = -1 }, InAliveSubPacket = new InAliveSubPacket { HP = visualEntity.Hp, MP = visualEntity.Mp }, IsSitting = visualEntity.IsSitting, GroupId = -1 } }); }
private MoodType GetMoodType(ICharacterEntity player) { if (player.HealthState == DynamicEntityHealthState.Dead) { return(MoodType.Dead); } //Add drowning sound ! //Testing "Fear" Condition ! bool playerNearBottom = player.Position.Y <= 30; if (playerNearBottom) { return(MoodType.Fear); } else { //Test against conditions that could change my "Mood" return(MoodType.Peace); } }
private MailRequest GenerateMailRequest(ICharacterEntity characterEntity, long receiverId, IItemInstanceDto?itemInstance, short?vnum, short?amount, sbyte?rare, byte?upgrade, bool isNosmall, string?title, string?text) { var equipment = isNosmall ? null : characterEntity.GetEquipmentSubPacket(); var mail = new MailDto { IsOpened = false, Date = SystemTime.Now(), ReceiverId = receiverId, IsSenderCopy = false, ItemInstanceId = itemInstance?.Id, Title = isNosmall ? "NOSMALL" : title ?? characterEntity.Name, Message = text, SenderId = isNosmall ? (long?)null : characterEntity.VisualId, SenderCharacterClass = isNosmall ? (CharacterClassType?)null : characterEntity.Class, SenderGender = isNosmall ? (GenderType?)null : characterEntity.Gender, SenderHairColor = isNosmall ? (HairColorType?)null : characterEntity.HairColor, SenderHairStyle = isNosmall ? (HairStyleType?)null : characterEntity.HairStyle, Hat = equipment?.Hat, Armor = equipment?.Armor, MainWeapon = equipment?.MainWeapon, SecondaryWeapon = equipment?.SecondaryWeapon, Mask = equipment?.Mask, Fairy = equipment?.Fairy, CostumeSuit = equipment?.CostumeSuit, CostumeHat = equipment?.CostumeHat, WeaponSkin = equipment?.WeaponSkin, WingSkin = equipment?.WingSkin, SenderMorphId = isNosmall ? (short?)null : characterEntity.Morph == 0 ? (short)-1 : characterEntity.Morph }; return(new MailRequest { Mail = mail, VNum = vnum, Amount = amount, Rare = rare, Upgrade = upgrade }); }
public static BlinitPacket GenerateBlinit(this ICharacterEntity visualEntity, IBlacklistHttpClient blacklistHttpClient) { var subpackets = new List <BlinitSubPacket>(); var blackList = blacklistHttpClient.GetBlackLists(visualEntity.VisualId); foreach (var relation in blackList) { if (relation.CharacterId == visualEntity.VisualId) { continue; } subpackets.Add(new BlinitSubPacket { RelatedCharacterId = relation.CharacterId, CharacterName = relation.CharacterName }); } return(new BlinitPacket { SubPackets = subpackets }); }
/// <summary> /// Initializes a new instance of the <see cref="Player"/> class. /// </summary> /// <param name="client">The client to associate this player to.</param> /// <param name="characterEntity">The player's corresponding character entity lodaded from storage.</param> /// <param name="scriptsLoader">A reference to the scripts loader in use.</param> public Player( IClient client, ICharacterEntity characterEntity, IScriptLoader scriptsLoader) : base(characterEntity) { scriptsLoader.ThrowIfNull(nameof(scriptsLoader)); client.ThrowIfNull(nameof(client)); characterEntity.ThrowIfNull(nameof(characterEntity)); this.Client = client; this.Client.PlayerId = this.Id; this.CharacterId = characterEntity.Id; this.Outfit = characterEntity.Outfit; this.InitializeSkills(scriptsLoader); var expLevel = this.Skills.TryGetValue(SkillType.Experience, out ISkill expSkill) ? expSkill.CurrentLevel : 1; this.Stats[CreatureStat.BaseSpeed].Set(220 + (2 * (expLevel - 1))); this.Stats[CreatureStat.CarryStrength].Set(150); this.Stats.Add(CreatureStat.ManaPoints, new Stat(CreatureStat.ManaPoints, characterEntity.CurrentManapoints == default ? characterEntity.MaxHitpoints : characterEntity.CurrentManapoints, characterEntity.MaxManapoints)); this.Stats[CreatureStat.ManaPoints].Changed += this.RaiseStatChange; this.Stats.Add(CreatureStat.SoulPoints, new Stat(CreatureStat.SoulPoints, 0, 0)); this.Stats[CreatureStat.SoulPoints].Changed += this.RaiseStatChange; this.Inventory = new PlayerInventory(this); // Hard-coded stuff. this.EmittedLightLevel = (byte)LightLevels.Torch; this.EmittedLightColor = (byte)LightColors.Orange; }
public static async Task <FinitPacket> GenerateFinitAsync(this ICharacterEntity visualEntity, IFriendHttpClient friendHttpClient, IChannelHttpClient channelHttpClient, IConnectedAccountHttpClient connectedAccountHttpClient) { //same canal var servers = (await channelHttpClient.GetChannelsAsync().ConfigureAwait(false)) ?.Where(c => c.Type == ServerType.WorldServer).ToList(); var accounts = new List <ConnectedAccount>(); foreach (var server in servers ?? new List <ChannelInfo>()) { accounts.AddRange( await connectedAccountHttpClient.GetConnectedAccountAsync(server).ConfigureAwait(false)); } var subpackets = new List <FinitSubPacket?>(); var friendlist = await friendHttpClient.GetListFriendsAsync(visualEntity.VisualId).ConfigureAwait(false); //TODO add spouselist //var spouseList = _webApiAccess.Get<List<CharacterRelationDto>>(WebApiRoute.Spouse, friendServer.WebApi, visualEntity.VisualId) ?? new List<CharacterRelationDto>(); foreach (var relation in friendlist) { var account = accounts.Find(s => (s.ConnectedCharacter != null) && (s.ConnectedCharacter.Id == relation.CharacterId)); subpackets.Add(new FinitSubPacket { CharacterId = relation.CharacterId, RelationType = relation.RelationType, IsOnline = account != null, CharacterName = relation.CharacterName }); } return(new FinitPacket { SubPackets = subpackets }); }
public VisualDynamicEntity(ICharacterEntity dynEntity, VoxelModelManager manager) : base(dynEntity, manager) { DynamicEntity = dynEntity; //Will be used to update the bounding box with world coordinate when the entity is moving LocalBBox.Minimum = new Vector3(-(DynamicEntity.DefaultSize.X / 2.0f), 0, -(DynamicEntity.DefaultSize.Z / 2.0f)); LocalBBox.Maximum = new Vector3(+(DynamicEntity.DefaultSize.X / 2.0f), DynamicEntity.DefaultSize.Y, +(DynamicEntity.DefaultSize.Z / 2.0f)); //Set Position //Set the entity world position following the position received from server WorldPosition.Value = DynamicEntity.Position; WorldPosition.ValuePrev = DynamicEntity.Position; //Compute the initial Player world bounding box RefreshWorldBoundingBox(ref WorldPosition.Value); //Set LookAt LookAtDirection.Value = DynamicEntity.HeadRotation; LookAtDirection.ValuePrev = LookAtDirection.Value; //Set Move direction = to LookAtDirection MoveDirection.Value = LookAtDirection.Value; //Change the default value when Player => The player message arrive much more faster ! if (DynamicEntity is PlayerCharacter) { _interpolationRate = 0.1; } _netLocation = new NetworkValue <Vector3D> { Value = WorldPosition.Value, Interpolated = WorldPosition.Value }; WithNetworkInterpolation = true; }
public static async Task <BlinitPacket> GenerateBlinitAsync(this ICharacterEntity visualEntity, IBlacklistHttpClient blacklistHttpClient) { var subpackets = new List <BlinitSubPacket?>(); var blackList = await blacklistHttpClient.GetBlackListsAsync(visualEntity.VisualId).ConfigureAwait(false); foreach (var relation in blackList) { if (relation.CharacterId == visualEntity.VisualId) { continue; } subpackets.Add(new BlinitSubPacket { RelatedCharacterId = relation.CharacterId, CharacterName = relation.CharacterName }); } return(new BlinitPacket { SubPackets = subpackets }); }
public Task RunScriptAsync(ICharacterEntity character) => RunScriptAsync(character, null);
public static GoldPacket GenerateGold(this ICharacterEntity characterEntity) { return(new GoldPacket { Gold = characterEntity.Gold }); }
/// <summary> /// Add an entity to the dynamic entity collection, all visual part of the entity (voxel) will be created here /// </summary> /// <param name="entity">the entity</param> /// <param name="withNetworkInterpolation">the entity movement will be interpolated between each move/rotate changes</param> public void AddEntity(ICharacterEntity entity, bool withNetworkInterpolation) { string entityVoxelName = entity.ModelName; if (entity.HealthState == DynamicEntityHealthState.Dead) { entityVoxelName = "Ghost"; } //Do we already have this entity ?? if (_dynamicEntitiesDico.ContainsKey(entity.DynamicId) == false) { //subscribe to entity state/afllication changes entity.HealthStateChanged += EntityHealthStateChanged; entity.HealthChanged += entity_HealthChanged; entity.AfflictionStateChanged += EntityAfflictionStateChanged; ModelAndInstances modelWithInstances; //Does the entity model exist in the collection ? //If yes, will send back the instance Ids registered to this Model if (!_models.TryGetValue(entityVoxelName, out modelWithInstances)) { //Model not existing ==== // load a new model modelWithInstances = new ModelAndInstances { VisualModel = _voxelModelManager.GetModel(entityVoxelName), //Get the model from the VoxelModelManager Instances = new Dictionary <uint, VoxelModelInstance>() //Create a new dico of modelInstance }; //If the voxel model was send back by the manager, create the Mesh from it (Vx and idx buffers) if (modelWithInstances.VisualModel != null) { // todo: probably do this in another thread modelWithInstances.VisualModel.BuildMesh(); } _models.Add(entityVoxelName, modelWithInstances); } VoxelModelInstance instance; //If the Model has a Voxel Model (Search by Name) if (modelWithInstances.VisualModel != null) { //Create a new Instance of the Model instance = new VoxelModelInstance(modelWithInstances.VisualModel.VoxelModel); entity.ModelInstance = instance; modelWithInstances.Instances.Add(entity.DynamicId, instance); } else { //Add a new instance for the model, but without Voxel Body (=null instance) modelWithInstances.Instances.Add(entity.DynamicId, null); } VisualDynamicEntity newEntity = CreateVisualEntity(entity); newEntity.WithNetworkInterpolation = withNetworkInterpolation; _dynamicEntitiesDico.Add(entity.DynamicId, newEntity); DynamicEntities.Add(newEntity); OnEntityAdded(new DynamicEntityEventArgs { Entity = entity }); } }
public void SendMessage(ICharacterEntity characterEntity, long receiverId, string title, string text) { Post <bool>(GenerateMailRequest(characterEntity, receiverId, null, null, null, null, null, false, title, text)); }
public void SendGift(ICharacterEntity characterEntity, long receiverId, short vnum, short amount, sbyte rare, byte upgrade, bool isNosmall) { Post <bool>(GenerateMailRequest(characterEntity, receiverId, null, vnum, amount, rare, upgrade, isNosmall, null, null)); }
public void SendGift(ICharacterEntity characterEntity, long receiverId, IItemInstanceDto itemInstance, bool isNosmall) { Post <bool>(GenerateMailRequest(characterEntity, receiverId, itemInstance, null, null, null, null, isNosmall, null, null)); }
public Task SendMessageAsync(ICharacterEntity characterEntity, long receiverId, string title, string text) { return(PostAsync <bool>(GenerateMailRequest(characterEntity, receiverId, null, null, null, null, null, false, title, text))); }
//TODO: Remove these clientsessions as parameter public Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?> ValidateExchange(ClientSession session, ICharacterEntity targetSession) { var exchangeInfo = GetData(session.Character.CharacterId); var targetInfo = GetData(targetSession.VisualId); var dictionary = new Dictionary <long, InfoPacket>(); if (exchangeInfo.Gold + targetSession.Gold > _worldConfiguration.MaxGoldAmount) { dictionary.Add(targetSession.VisualId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.INVENTORY_FULL, targetSession.AccountLanguage) }); } if (targetInfo.Gold + session.Character.Gold > _worldConfiguration.MaxGoldAmount) { dictionary.Add(targetSession.VisualId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.MAX_GOLD, session.Account.Language) }); return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Failure, dictionary)); } if (exchangeInfo.BankGold + targetSession.BankGold > _worldConfiguration.MaxBankGoldAmount) { dictionary.Add(targetSession.VisualId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.BANK_FULL, session.Account.Language) }); return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Failure, dictionary)); } if (targetInfo.BankGold + session.Account.BankMoney > _worldConfiguration.MaxBankGoldAmount) { dictionary.Add(session.Character.CharacterId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.BANK_FULL, session.Account.Language) }); return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Failure, dictionary)); } if (exchangeInfo.ExchangeItems.Keys.Any(s => !s.ItemInstance !.Item !.IsTradable)) { dictionary.Add(session.Character.CharacterId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.ITEM_NOT_TRADABLE, session.Account.Language) }); return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Failure, dictionary)); } if (session.Character.InventoryService.EnoughPlace( targetInfo.ExchangeItems.Keys.Select(s => s.ItemInstance !).ToList(), targetInfo.ExchangeItems.Keys.First().Type) && targetSession.InventoryService.EnoughPlace( exchangeInfo.ExchangeItems.Keys.Select(s => s.ItemInstance !).ToList(), targetInfo.ExchangeItems.Keys.First().Type)) { return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Success, null)); } dictionary.Add(session.Character.CharacterId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.INVENTORY_FULL, session.Account.Language) }); dictionary.Add(targetSession.VisualId, new InfoPacket { Message = GameLanguage.Instance.GetMessageFromKey(LanguageKey.INVENTORY_FULL, targetSession.AccountLanguage) }); return(new Tuple <ExchangeResultType, Dictionary <long, InfoPacket>?>(ExchangeResultType.Failure, dictionary)); }
//in 9 {vnum} {id} {x} {y} {amount} {IsQuestRelative} 0 {owner} //in 3 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 2 {Effect} {IsSitting} {GroupId} {SecondName} 0 -1 0 0 0 0 0 0 0 0 //in 1 {IsSitting} {GroupId} {HaveFairy} {FairyElement} 0 {FairyMorph} 0 {Morph} {EqRare} {FamilyId} {SecondName} {Reput} {Invisible} {MorphUpgrade} {faction} {MorphUpgrade2} {Level} {FamilyLevel} {ArenaWinner} {Compliment} {Size} {HeroLevel} //in 1 Carlosta - 754816 71 105 2 0 1 0 14 3 340.4855.4867.4864.4846.802.4150.4142 100 37 0 -1 4 3 0 0 0 7 86 86 2340 ~Luna~(Membre) -2 0 5 0 0 88 10 0 0 10 1 //Character in packet public static InPacket GenerateIn(this ICharacterEntity visualEntity) { return(new InPacket { VisualType = visualEntity.VisualType, Name = visualEntity.Name, VNum = visualEntity.VNum == 0 ? string.Empty : visualEntity.VNum.ToString(), VisualId = visualEntity.VisualId, PositionX = visualEntity.PositionX, PositionY = visualEntity.PositionY, Direction = visualEntity.Direction, InCharacterSubPacket = new InCharacterSubPacket { Authority = visualEntity.Authority, Gender = (byte)visualEntity.Gender, HairStyle = (byte)visualEntity.HairStyle, HairColor = (byte)visualEntity.HairColor, Class = visualEntity.Class, Equipment = new InEquipmentSubPacket { Armor = -1, CostumeHat = -1, CostumeSuit = -1, Fairy = -1, Hat = -1, MainWeapon = -1, Mask = -1, SecondaryWeapon = -1, WeaponSkin = -1 }, InAliveSubPacket = new InAliveSubPacket { Hp = (int)(visualEntity.Hp / (float)visualEntity.MaxHp * 100), Mp = (int)(visualEntity.Mp / (float)visualEntity.MaxMp * 100) }, IsSitting = visualEntity.IsSitting, GroupId = visualEntity.GroupId, Fairy = 0, FairyElement = 0, Unknown = 0, Morph = 0, WeaponUpgrade = 0, WeaponRare = 0, ArmorUpgrade = 0, ArmorRare = 0, FamilyId = -1, FamilyName = string.Empty, ReputIco = (short)(visualEntity.DignityIcon == 1 ? visualEntity.ReputIcon : -visualEntity.DignityIcon), Invisible = false, MorphUpgrade = 0, Faction = 0, MorphUpgrade2 = 0, Level = visualEntity.Level, FamilyLevel = 0, ArenaWinner = false, Compliment = 0, Size = 0, HeroLevel = visualEntity.HeroLevel } }); }
//Dynamic Entity management private VisualDynamicEntity CreateVisualEntity(ICharacterEntity entity) { return(new VisualDynamicEntity(entity, _voxelModelManager)); }