Пример #1
0
 public void Save(CharacterContext context)
 {
     foreach (Costume costume in costumes.Values)
     {
         costume.Save(context);
     }
 }
Пример #2
0
        public void Use(CharacterContext context, int2 position)
        {
            var dir = (position - context.Self.Position);

            Debug.Log($"{context.Self.name} {_chargeVerb}.");
            ApplyUseCost(context, EffectType.Permanent);

            if (_chargeEffectPrefab != null)
            {
                var fx = GameObject.Instantiate(_chargeEffectPrefab, new Vector3(context.Self.Position.x, context.Self.Position.y, 0),
                                                Quaternion.identity);

                fx.Setup(dir);
            }

            if (_radius <= 0)
            {
                var character = context.Dungeon.GetCharacterAt(position);
                if (character != null)
                {
                    Use(context, character);
                }
            }
            else
            {
                var sqRad = _radius * _radius;

                for (var y = position.y - _radius; y <= position.y + _radius; y++)
                {
                    for (var x = position.x - _radius; x <= position.x + _radius; x++)
                    {
                        var p = new int2(x, y);
                        if (Shape == AbilityShape.FilledCircle)
                        {
                            var sqDist = math.distancesq(p, position);
                            if (sqDist > sqRad)
                            {
                                continue;
                            }
                        }

                        var character = context.Dungeon.GetCharacterAt(p);
                        if (character != null)
                        {
                            Use(context, character);
                        }
                        else
                        {
                            if (_hitEffectPrefab != null)
                            {
                                var fx = GameObject.Instantiate(_hitEffectPrefab, new Vector3(x, y, 0),
                                                                Quaternion.identity);

                                fx.Setup(dir);
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        private Characters GetCharacters(AccountModel model, ushort gate)
        {
            using CharacterContext characterContext = _characterFactory.CreateDbContext();
            using ItemContext itemContext           = _itemFactory.CreateDbContext();

            return(new(model, gate, characterContext, itemContext));
        }
Пример #4
0
 public override void Execute(Context _context)
 {
     // init context
     this.context = (CharacterContext) _context;
     if(context.animator != null) context.animator.SetBool("Attacking", false);
     context.attacking = false;
 }
Пример #5
0
        // Fresh constructor
        public EmoteSetVariableNode()
            : base(EmoteSetVariableNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conExecute = new ExecutionConnectorViewModel();
            inputValue = new ConnectorViewModel("Value", typeof(NodeDataNumeric));
            inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric));
            inputEasing = new ConnectorViewModel("Easing", typeof(NodeDataNumeric));

            this.InputExecutionConnectors.Add(conExecute);
            this.InputConnectors.Add(inputValue);
            this.InputConnectors.Add(inputFrameCount);
            this.InputConnectors.Add(inputEasing);

            // State Values
            value = 0f;
            frameCount = 0.1f;
            easing = 0.9f;
            varName = string.Empty;

            // Create Dialog
            dlgEdit = new PropertyDialog();

            // Get Character Context
            charContext = CharacterContext.GetCharacterContext();
        }
Пример #6
0
 public void Save(CharacterContext context)
 {
     foreach (Currency currency in currencies.Values)
     {
         currency.Save(context);
     }
 }
Пример #7
0
        public Character()
        {
            CharacterContext db = new CharacterContext();

            CharacterSkills = db.CharacterSkills.ToList <CharacterSkill>();
            CharacterItems  = db.CharacterItems.ToList <CharacterItem>();
        }
Пример #8
0
        public Characters(AccountModel accountModel, ushort gateId, CharacterContext characterContext, ItemContext itemContext)
        {
            Stopwatch stopwatch = new();

            stopwatch.Start();

            foreach (CharacterModel model in GetCharacterModels(accountModel, gateId, characterContext))
            {
                if (!TryAdd(model.Id, new(model, itemContext)))
                {
                    NetworkUtils.DropBadAction();
                }
            }

            if (accountModel.LastSelectedCharacter != -1 && TryGetValue(accountModel.LastSelectedCharacter, out CEntity? last))
            {
                LastSelected = last;
            }

            if (accountModel.FavoriteCharacter != -1 && TryGetValue(accountModel.FavoriteCharacter, out CEntity? favorite))
            {
                Favorite = favorite;
            }

            stopwatch.Stop();
            InitializeTime = stopwatch.Elapsed;
        }
 public void Save(CharacterContext context)
 {
     foreach (Achievement achievement in achievements.Values)
     {
         achievement.Save(context);
     }
 }
Пример #10
0
        public void UpdateSlots(SyncSession session, GestureQuickSlotsUpdateRequest request)
        {
            foreach (uint id in request.Values)
            {
                if (id == 0)
                {
                    continue;
                }

                if (!_tables.Gesture.TryGetValue((ushort)id, out GestureTableEntity? gesture))
                {
                    NetworkUtils.DropBadAction();
                }

                if (gesture !.Hero != session.Character.Hero && gesture !.Hero != Hero.None)
                {
                    NetworkUtils.DropBadAction();
                }
            }

            using CharacterContext context = _characterRepository.CreateDbContext();

            CharacterModel model = context.Characters.First(s => s.Id == session.Character.Id);

            model.Gestures = request.Values.ToArray();

            context.UseAndSave(c => c.Update(model));

            session.SendDeferred(new CharacterGestureUpdateSlotsResponse()
            {
                Values = request.Values
            });
        }
Пример #11
0
 public void Save(CharacterContext context)
 {
     foreach (ZoneMap zoneMap in zoneMaps.Values)
     {
         zoneMap.Save(context);
     }
 }
Пример #12
0
        public UnitOfWork(CharacterContext context, SpellsContext spellsContext, ItemsContext itemsContext, PlayableClassContext playableClassContext, RaceContext raceContext)
        {
            _context           = context;
            Characters         = RepositoryFactory.GetCharacterRepository(context);
            HealthRecords      = RepositoryFactory.GetHealthRepository(context);
            CurrencyRecords    = RepositoryFactory.GetCurrencyRepository(context);
            ProficiencyRecords = RepositoryFactory.GetIsProficientRepository(context);
            Notes = RepositoryFactory.GetNotesRepository(context);
            Stats = RepositoryFactory.GetStatsRepository(context);

            _spellsContext = spellsContext;
            Spells         = RepositoryFactory.GetSpellsRepository(spellsContext);

            _itemsContext = itemsContext;
            Items         = RepositoryFactory.GetItemsRepository(itemsContext);

            _playableClassContext = playableClassContext;
            Classes           = RepositoryFactory.GetPlayableClassRepository(playableClassContext);
            ClassAbilities    = RepositoryFactory.GetClassAbilityRepository(playableClassContext);
            Subclasses        = RepositoryFactory.GetSubclassRepository(playableClassContext);
            SubclassAbilities = RepositoryFactory.GetSubclassAbilityRepository(playableClassContext);

            _raceContext = raceContext;
            Races        = RepositoryFactory.GetRacesRepository(raceContext);
        }
Пример #13
0
 public void Save(CharacterContext context)
 {
     foreach (Reputation reputation in reputations.Values)
     {
         reputation.Save(owner.CharacterId, context);
     }
 }
Пример #14
0
 public Toon()
 {
     _context         = new CharacterContext();
     _context.Hunger  = 0.0f;
     _context.Thirst  = 0.0f;
     _context.Bladder = 0.0f;
 }
Пример #15
0
 protected override void OnEnter(CharacterContext context)
 {
     SetDelay(0f, () => context.Animator.SetTrigger("Jump"));
     context.TouchFloor           = false;
     context.VerticalSpeed        = _settings.JumpSpeed;
     context.VerticalAcceleration = _settings.JumpGravity;
 }
Пример #16
0
        public void Save(CharacterContext context)
        {
            if (saveMask == SaveMask.None)
            {
                return;
            }

            var model = new CharacterEntitlementModel
            {
                Id            = characterId,
                EntitlementId = (byte)Type,
                Amount        = amount
            };

            if ((saveMask & SaveMask.Create) != 0)
            {
                context.Add(model);
            }
            else
            {
                EntityEntry <CharacterEntitlementModel> entity = context.Attach(model);
                entity.Property(p => p.Amount).IsModified = true;
            }

            saveMask = SaveMask.None;
        }
Пример #17
0
 public List <ChatChannelModel> GetChatChannels()
 {
     using var context = new CharacterContext(config);
     return(context.ChatChannel
            .Include(c => c.Members)
            .ToList());
 }
Пример #18
0
        public async Task <List <CharacterModel> > GetCharacters(uint accountId)
        {
            await using var context = new CharacterContext(config);

            IQueryable <CharacterModel> query = context.Character.Where(c => c.AccountId == accountId);
            await query.SelectMany(c => c.Appearance).LoadAsync();

            await query.SelectMany(c => c.Customisation).LoadAsync();

            await query.SelectMany(c => c.Item).LoadAsync();

            await query.SelectMany(c => c.Bone).LoadAsync();

            await query.SelectMany(c => c.Currency).LoadAsync();

            await query.SelectMany(c => c.Path).LoadAsync();

            await query.SelectMany(c => c.CharacterTitle).LoadAsync();

            await query.SelectMany(c => c.Stat).LoadAsync();

            await query.SelectMany(c => c.Costume)
            .Include(c => c.CostumeItem)
            .LoadAsync();

            await query.SelectMany(c => c.PetCustomisation).LoadAsync();

            await query.SelectMany(c => c.PetFlair).LoadAsync();

            await query.SelectMany(c => c.Keybinding).LoadAsync();

            await query.SelectMany(c => c.Spell).LoadAsync();

            await query.SelectMany(c => c.ActionSetShortcut).LoadAsync();

            await query.SelectMany(c => c.ActionSetAmp).LoadAsync();

            await query.SelectMany(c => c.Datacube).LoadAsync();

            await query.SelectMany(c => c.Mail)
            .Include(c => c.Attachment)
            .ThenInclude(c => c.Item)
            .LoadAsync();

            await query.SelectMany(c => c.ZonemapHexgroup).LoadAsync();

            await query.SelectMany(c => c.Quest)
            .Include(c => c.QuestObjective)
            .LoadAsync();

            await query.SelectMany(c => c.Entitlement).LoadAsync();

            await query.SelectMany(c => c.Achievement).LoadAsync();

            await query.SelectMany(c => c.TradeskillMaterials).LoadAsync();

            await query.SelectMany(c => c.Reputation).LoadAsync();

            return(await query.ToListAsync());
        }
Пример #19
0
 public void Save(CharacterContext context)
 {
     foreach (Datacube datacube in datacubes.Values)
     {
         datacube.Save(context, player.CharacterId);
     }
 }
Пример #20
0
 public void Save(CharacterContext context)
 {
     foreach (TradeskillMaterial material in tradeskillMaterials.Values)
     {
         material.Save(context);
     }
 }
Пример #21
0
        public void Save(CharacterContext context)
        {
            if (saveMask == ActionSetSaveMask.None)
            {
                return;
            }

            if ((saveMask & ActionSetSaveMask.ActionSetAmps) != 0)
            {
                foreach ((ushort id, ActionSetAmp amp) in amps.OrderBy(i => i.Value.PendingDelete == true).ToList())
                {
                    if (amp.PendingDelete)
                    {
                        amps.Remove(id);
                    }

                    amp.Save(context);
                }
            }

            if ((saveMask & ActionSetSaveMask.ActionSetActions) != 0)
            {
                foreach ((UILocation location, ActionSetShortcut shortcut) in actions.OrderBy(i => i.Value.PendingDelete == true).ToList())
                {
                    if (shortcut.PendingDelete)
                    {
                        actions.Remove(location);
                    }

                    shortcut.Save(context);
                }
            }

            saveMask = ActionSetSaveMask.None;
        }
Пример #22
0
        public void Tick(CharacterContext context)
        {
            context.KnownEnemies.Clear();

            // Ensure we're not blind
            if (context.Self.Sight == 0)
            {
                context.OnKnownEnemiesUpdated?.Invoke(context);
                return;
            }

            var sight = context.Self.Sight;

            foreach (var character in context.Dungeon.Characters)
            {
                if (character == context.Self)
                {
                    continue;
                }

                if (character.IsDead)
                {
                    continue;
                }

                var dir    = (character.Position - context.Self.Position);
                var distSq = math.lengthsq(dir);
                if (distSq <= sight * sight)
                {
                    context.KnownEnemies.Add(character);
                }
            }

            context.OnKnownEnemiesUpdated?.Invoke(context);
        }
Пример #23
0
        public void Save(CharacterContext context)
        {
            while (outgoingMail.TryDequeue(out MailItem mail))
            {
                mail.Save(context);

                MailManager mailManager;
                if (mail.RecipientId == player.CharacterId)
                {
                    mailManager = player.MailManager;
                }
                else
                {
                    // ReSharper disable once AccessToModifiedClosure
                    WorldSession session = NetworkManager <WorldSession> .Instance.GetSession(c => c.Player.CharacterId == mail.RecipientId);

                    mailManager = session?.Player.MailManager;
                }

                // deliver mail if user is online
                mailManager?.EnqueueMail(mail);
            }

            foreach (MailItem mail in availableMail.Values.ToList())
            {
                if (mail.PendingDelete)
                {
                    availableMail.Remove(mail.Id);
                }

                mail.Save(context);
            }
        }
Пример #24
0
        public void Save(CharacterContext context)
        {
            foreach (Quest.Quest quest in completedQuests.Values)
            {
                quest.Save(context);
            }

            foreach (Quest.Quest quest in inactiveQuests.Values.ToList())
            {
                if (quest.PendingDelete)
                {
                    inactiveQuests.Remove(quest.Id);
                }

                quest.Save(context);
            }

            foreach (Quest.Quest quest in activeQuests.Values.ToList())
            {
                if (quest.PendingDelete)
                {
                    activeQuests.Remove(quest.Id);
                }

                quest.Save(context);
            }
        }
Пример #25
0
 /// <summary>
 /// Execute a DB Save of the <see cref="CharacterContext"/>
 /// </summary>
 /// <param name="context"></param>
 public void Save(CharacterContext context)
 {
     foreach (PathEntry pathEntry in paths)
     {
         pathEntry.Save(context);
     }
 }
Пример #26
0
 private CharacterService()
 {
     using (var db = new CharacterContext())
     {
         db.Database.EnsureCreated();
     }
 }
Пример #27
0
 public static async Task <List <Model.Character> > GetCharacters(uint accountId)
 {
     using (var context = new CharacterContext())
     {
         return(await context.Character
                .Where(c => c.AccountId == accountId)
                .Include(c => c.CharacterAppearance)
                .Include(c => c.CharacterCustomisation)
                .Include(c => c.Item)
                .Include(c => c.CharacterBone)
                .Include(c => c.CharacterCurrency)
                .Include(c => c.CharacterPath)
                .Include(c => c.CharacterTitle)
                .Include(c => c.CharacterStats)
                .Include(c => c.CharacterCostume)
                .ThenInclude(c => c.CharacterCostumeItem)
                .Include(c => c.CharacterPetCustomisation)
                .Include(c => c.CharacterPetFlair)
                .Include(c => c.CharacterKeybinding)
                .Include(c => c.CharacterSpell)
                .Include(c => c.CharacterActionSetShortcut)
                .Include(c => c.CharacterActionSetAmp)
                .Include(c => c.CharacterDatacube)
                .Include(c => c.CharacterMail)
                .ThenInclude(c => c.CharacterMailAttachment)
                .ThenInclude(a => a.ItemGu)
                .Include(c => c.CharacterZonemapHexgroup)
                .ToListAsync());
     }
 }
Пример #28
0
        // Fresh constructor
        public EmoteSetVariableNode() : base(EmoteSetVariableNodeFactory.TYPESTRING)
        {
            // Prepare Connections
            conExecute      = new ExecutionConnectorViewModel();
            inputValue      = new ConnectorViewModel("Value", typeof(NodeDataNumeric));
            inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric));
            inputEasing     = new ConnectorViewModel("Easing", typeof(NodeDataNumeric));

            this.InputExecutionConnectors.Add(conExecute);
            this.InputConnectors.Add(inputValue);
            this.InputConnectors.Add(inputFrameCount);
            this.InputConnectors.Add(inputEasing);

            // State Values
            value      = 0f;
            frameCount = 0.1f;
            easing     = 0.9f;
            varName    = string.Empty;

            // Create Dialog
            dlgEdit = new PropertyDialog();

            // Get Character Context
            charContext = CharacterContext.GetCharacterContext();
        }
Пример #29
0
        private void OnSceneGUI()
        {
            CharacterContext FOW = (CharacterContext)target;

            Handles.color = Color.white;
            Handles.color = Color.white;
            Handles.DrawWireArc(FOW.transform.position, Vector3.up, Vector3.forward, 360, FOW.viewRadius);
            Vector3 ViewAngleA = FOW.DirFromAngle(-FOW.viewAngle / 2, false);
            Vector3 ViewAngleB = FOW.DirFromAngle(FOW.viewAngle / 2, false);

            Handles.DrawLine(FOW.transform.position, FOW.transform.position + ViewAngleA * FOW.viewRadius);
            Handles.DrawLine(FOW.transform.position, FOW.transform.position + ViewAngleB * FOW.viewRadius);

            Handles.color = Color.blue;
            Handles.DrawWireArc(FOW.transform.position, Vector3.up, Vector3.forward, 360, FOW.EngageRadius);
            Vector3 ViewAngleC = FOW.DirFromAngle(-FOW.EngageViewAngle / 2, false);
            Vector3 ViewAngleD = FOW.DirFromAngle(FOW.EngageViewAngle / 2, false);

            Handles.DrawLine(FOW.transform.position, FOW.transform.position + ViewAngleC * FOW.EngageRadius);
            Handles.DrawLine(FOW.transform.position, FOW.transform.position + ViewAngleD * FOW.EngageRadius);

            Handles.color = Color.red;
            foreach (Transform visibleTarget in FOW.VisibleTargets)
            {
                Handles.DrawLine(FOW.transform.position, visibleTarget.position);
            }
        }
Пример #30
0
        // TODO: This could be a little smarter.
        // TODO: E.g. if damage is negative, it implies healing, which we'd want to apply to ourself.
        // TODO: E.g. if spell has AOE, ensure we pick a target that does not implicate ourself in the damage radius.
        public Character.Character FindDefaultTarget(CharacterContext context)
        {
            float sqClosest = float.MaxValue;

            Character.Character bestCharacter = null;

            foreach (var character in context.Dungeon.Characters)
            {
                if (character == context.Self)
                {
                    continue;
                }

                if (context.FieldOfView.ContainsKey(character.Position))
                {
                    var sqDist = math.distancesq(character.Position, context.Self.Position);
                    if (sqDist < sqClosest)
                    {
                        sqClosest     = sqDist;
                        bestCharacter = character;
                    }
                }
            }

            if (bestCharacter != null)
            {
                return(bestCharacter);
            }

            return(context.Self);
        }
Пример #31
0
        public void Save(CharacterContext context)
        {
            if (saveMask == AmpSaveMask.None)
            {
                return;
            }

            var model = new CharacterActionSetAmpModel
            {
                Id        = actionSet.Owner,
                SpecIndex = actionSet.Index,
                AmpId     = (byte)Entry.Id
            };

            if ((saveMask & AmpSaveMask.Create) != 0)
            {
                context.Add(model);
            }
            else if ((saveMask & AmpSaveMask.Delete) != 0)
            {
                context.Entry(model).State = EntityState.Deleted;
            }

            saveMask = AmpSaveMask.None;
        }
Пример #32
0
        public void Save(CharacterContext context)
        {
            if (saveMask != MailAttachmentSaveMask.None)
            {
                if ((saveMask & MailAttachmentSaveMask.Create) != 0)
                {
                    context.Add(new CharacterMailAttachmentModel
                    {
                        Id       = Id,
                        Index    = Index,
                        ItemGuid = Item.Guid
                    });
                }
                else if ((saveMask & MailAttachmentSaveMask.Delete) != 0)
                {
                    var model = new CharacterMailAttachmentModel
                    {
                        Id    = Id,
                        Index = Index
                    };

                    context.Entry(model).State = EntityState.Deleted;
                }

                saveMask = MailAttachmentSaveMask.None;
            }

            Item.Save(context);
        }
Пример #33
0
	void Awake() {
		curState = null;
		Menu = new MenuContext( this );
		Character = new CharacterContext( this );
		Map = new MapContext( this );
		EnterName = new EnterNameContext( this );
		MatchScore = new MatchScore( this );
		Header = new HeaderContext( this );
	}
Пример #34
0
    public override void Execute(Context _context)
    {
        // init context

        this.context = (CharacterContext) _context;

        // action logic here

        context.attacking = true;
        context.StartCoroutine(Attack());
    }
Пример #35
0
    void Awake()
    {
        context = gameObject.GetComponent<CharacterContext>();
        //set the dimensions for the bar relative to the screen height
        rect.x = (float)Screen.height* barHeightRatio * barWidthRatio;
        rect.y = (float)Screen.height * barHeightRatio;

        healthBarGUIStyle = new GUIStyle();

        healthTexture = new Texture2D(1, 1);
        healthTexture.SetPixel(0,0, healthColor);
        healthTexture.wrapMode = TextureWrapMode.Clamp;
        healthTexture.Apply();

        barTexture = new Texture2D(1, 1);
        barTexture.SetPixel(0,0, barColor);
        barTexture.wrapMode = TextureWrapMode.Clamp;
        barTexture.Apply();
    }
Пример #36
0
        // Load Data Constructor
        public EmoteSetVariableNode(JObject data, Guid[] executeIn, Guid[] executeOut, Guid[] dataIn, Guid[] dataOut)
        {
            // Prepare Connections
            conExecute = new ExecutionConnectorViewModel(executeIn[0]);
            inputValue = new ConnectorViewModel("Value", typeof(NodeDataNumeric), dataIn[0]);
            if (dataIn.Length > 1) // allow loading older node graph saves
            {
                inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric), dataIn[1]);
                inputEasing = new ConnectorViewModel("Easing", typeof(NodeDataNumeric), dataIn[2]);
            }
            else
            {
                inputFrameCount = new ConnectorViewModel("FrameCount", typeof(NodeDataNumeric));
                inputEasing = new ConnectorViewModel("Easing", typeof(NodeDataNumeric));
            }

            this.InputExecutionConnectors.Add(conExecute);
            this.InputConnectors.Add(inputValue);
            this.InputConnectors.Add(inputFrameCount);
            this.InputConnectors.Add(inputEasing);

            // Set Name
            Name = (string)data["name"];

            // State Values
            value = (float)data["value"];
            frameCount = (float)data["frameCount"];
            easing = (float)data["easing"];
            varName = (string)data["varName"];

            // Create Dialog
            dlgEdit = new PropertyDialog();

            // Get Character Context
            charContext = CharacterContext.GetCharacterContext();
        }