Пример #1
0
 public World(IScene internalScene, ISecurityCredential securityCredential)
 {
     m_security = securityCredential;
     m_internalScene = internalScene;
     m_heights = new Heightmap(m_internalScene);
     m_objs = new ObjectAccessor(m_internalScene, securityCredential);
 }
Пример #2
0
 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 public SPAvatar(Scene scene, UUID ID, ISecurityCredential security, ObjectAccessor accessor)
     : base(accessor)
 {
     m_rootScene = scene;
     m_security = security;
     m_ID = ID;
     m_accessor = accessor;
 }
Пример #3
0
 public World(Scene internalScene, ISecurityCredential securityCredential, bool isGod)
 {
     m_security = securityCredential;
     m_internalScene = internalScene;
     m_heights = new Heightmap(m_internalScene, this);
     m_objs = new ObjectAccessor(m_internalScene, securityCredential, isGod);
     _chatListeners = new List<OnChatDelegate>();
     _newUserListeners = new List<OnNewUserDelegate>();
     CurrentCount++;
     TotalCount++;
 }
Пример #4
0
 public SOPObject(Scene rootScene, uint localID, ObjectAccessor accessor)
 {
     m_rootScene = rootScene;
     m_localID = localID;
     m_accessor = accessor;
     m_id = GetSOP().UUID;
     _touchListeners = new List<OnTouchDelegate>();
     m_touchListener = new EventManager.ObjectGrabDelegate(EventManager_OnObjectGrab);
     _name = GetSOP().Name;
     CurrentCount++;
 }
Пример #5
0
        public override bool OnTrigger(Player player, AreaTriggerRecord areaTrigger, bool entered)
        {
            InstanceScript instance = player.GetInstanceScript();

            if (instance != null)
            {
                if (instance.GetBossState(Bosses.LadyDeathwhisper) != EncounterState.Done)
                {
                    Creature ladyDeathwhisper = ObjectAccessor.GetCreature(player, instance.GetGuidData(Bosses.LadyDeathwhisper));
                    if (ladyDeathwhisper)
                    {
                        ladyDeathwhisper.GetAI().DoAction(0);
                    }
                }
            }

            return(true);
        }
Пример #6
0
        void HandleSpellClick(SpellClick packet)
        {
            // this will get something not in world. crash
            Creature unit = ObjectAccessor.GetCreatureOrPetOrVehicle(GetPlayer(), packet.SpellClickUnitGuid);

            if (unit == null)
            {
                return;
            }

            // @todo Unit.SetCharmedBy: 28782 is not in world but 0 is trying to charm it! . crash
            if (!unit.IsInWorld)
            {
                return;
            }

            unit.HandleSpellClick(GetPlayer());
        }
Пример #7
0
        public void BasicWriteTest_PropsOnClass_ViaWrapper()
        {
            var now = DateTime.Now;

            var obj = new PropsOnClass();

            var wrapper = ObjectAccessor.Create(obj);

            wrapper["A"] = 123;
            wrapper["B"] = "abc";
            wrapper["C"] = now;
            wrapper["D"] = null;

            Assert.AreEqual(123, obj.A);
            Assert.AreEqual("abc", obj.B);
            Assert.AreEqual(now, obj.C);
            Assert.AreEqual(null, obj.D);
        }
        public TEntity BuildEntity(TRowResult input)
        {
            var target   = _activator.Activate();
            var accessor = ObjectAccessor.Create(target);

            var timestamps = new ConcurrentDictionary <string, long>();


            ProcessMap(_map, accessor, input.Columns, timestamps);
            RowkeyProcessor.PopulateEntity(target, _map.RowKey, input.Row, accessor);

            if (target is ITimestamp ts)
            {
                ts.Set(new Dictionary <string, long>(timestamps));
            }

            return(target);
        }
        private void ProcessListMap(ListMap map, ObjectAccessor accessor, Dictionary <byte[], TCell> input, ConcurrentDictionary <string, long> ts)
        {
            switch (map.MappingStrategy)
            {
            case MappingStrategy.EntireCfAsObject:
                EntireCfAsObject(map, accessor, input, ts);
                break;

            case MappingStrategy.RegexColumnsAsObject:
                break;

            case MappingStrategy.ColumnAsList:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #10
0
        private ComponentData SetupComponentData(Component component)
        {
            var accessor = ObjectAccessor.Create(component);

            var defaultVisibility = component.GetType().GetCustomAttribute <ObjectEditorVisibleAttribute>()?.Visible ?? DefaultObjectEditorMemberVisibility;

            var editableMembers = new List <IEditableMemberType>();

            foreach (var info in component.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance))
            {
                (var memberType, var isWritable) = GetMemberData(info);

                if (memberType != null && isWritable)
                {
                    var visible = info.GetCustomAttribute <ObjectEditorVisibleAttribute>()?.Visible ?? defaultVisibility;

                    if (visible)
                    {
                        EditableMemberFactory factory = null;

                        if (memberType.IsEnum)
                        {
                            factory = _enumEditableMemberTypeFactory;
                        }
                        else
                        {
                            _editableMemberTypes.TryGetValue(memberType, out factory);
                        }

                        if (factory != null)
                        {
                            var index = editableMembers.Count;

                            var editableMember = factory(index, component, info, memberType, accessor);
                            editableMember.Initialize(index, component, info, accessor);

                            editableMembers.Add(editableMember);
                        }
                    }
                }
            }

            return(new ComponentData(component, accessor, editableMembers));
        }
Пример #11
0
            public override void UpdateAI(uint diff)
            {
                base.UpdateAI(diff);

                if (uiTimer <= diff)
                {
                    switch (uiPhase)
                    {
                    case 1:
                        DoSummonGrandChampion(uiSecondBoss);
                        NextStep(10000, true);
                        break;

                    case 2:
                        DoSummonGrandChampion(uiThirdBoss);
                        NextStep(0, false);
                        break;

                    case 3:
                        if (!Champion1List.Empty())
                        {
                            foreach (var guid in Champion1List)
                            {
                                Creature summon = ObjectAccessor.GetCreature(me, guid);
                                if (summon)
                                {
                                    AggroAllPlayers(summon);
                                }
                            }
                            NextStep(0, false);
                        }
                        break;
                    }
                }
                else
                {
                    uiTimer -= diff;
                }

                if (!UpdateVictim())
                {
                    return;
                }
            }
Пример #12
0
        void HandleQueryBattlePetName(QueryBattlePetName queryBattlePetName)
        {
            QueryBattlePetNameResponse response = new();

            response.BattlePetID = queryBattlePetName.BattlePetID;

            Creature summonedBattlePet = ObjectAccessor.GetCreatureOrPetOrVehicle(_player, queryBattlePetName.UnitGUID);

            if (!summonedBattlePet || !summonedBattlePet.IsSummon())
            {
                SendPacket(response);
                return;
            }

            response.CreatureID = summonedBattlePet.GetEntry();
            response.Timestamp  = summonedBattlePet.GetBattlePetCompanionNameTimestamp();

            Unit petOwner = summonedBattlePet.ToTempSummon().GetSummonerUnit();

            if (!petOwner.IsPlayer())
            {
                SendPacket(response);
                return;
            }

            BattlePet battlePet = petOwner.ToPlayer().GetSession().GetBattlePetMgr().GetPet(queryBattlePetName.BattlePetID);

            if (battlePet == null)
            {
                SendPacket(response);
                return;
            }

            response.Name = battlePet.PacketInfo.Name;
            if (battlePet.DeclinedName != null)
            {
                response.HasDeclined   = true;
                response.DeclinedNames = battlePet.DeclinedName;
            }

            response.Allow = !response.Name.IsEmpty();

            SendPacket(response);
        }
Пример #13
0
 private void OnCallRemote(string route, HttpGet httpGet, MessageStructure response)
 {
     try
     {
         string[] mapList   = route.Split('.');
         string   funcName  = "";
         string   routeName = "";
         if (mapList.Length > 1)
         {
             funcName  = mapList[mapList.Length - 1];
             routeName = string.Join("/", mapList, 0, mapList.Length - 1);
         }
         string      routeFile = "";
         string      typeName  = string.Format("Game.Script.Remote.{0}", routeName);
         int         actionId  = httpGet.ActionId;
         MessageHead head      = new MessageHead(actionId);
         if (!ScriptEngines.DisablePython)
         {
             routeFile = string.Format("{0}/Remote/{1}.py", ScriptEngines.PythonDirName, routeName);
             dynamic scope = ScriptEngines.Execute(routeFile, typeName);
             if (scope != null)
             {
                 var funcHandle = scope.GetVariable <RemoteHandle>(funcName);
                 if (funcHandle != null)
                 {
                     funcHandle(httpGet, head, response);
                     response.WriteBuffer(head);
                     return;
                 }
             }
         }
         routeFile = string.Format("{0}/Remote/{1}.cs", ScriptEngines.CSharpDirName, routeName);
         var instance = (object)ScriptEngines.Execute(routeFile, typeName);
         if (instance != null)
         {
             var result = ObjectAccessor.Create(instance, true)[funcName];
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("{0}", ex);
     }
 }
Пример #14
0
        private static void CopyProperties(dynamic targetViewModel, dynamic sourceViewModel)
        {
            if (sourceViewModel == null)
            {
                return;
            }

            var accessor = ObjectAccessor.Create(targetViewModel);

            var properties = TypeDescriptor.GetProperties(sourceViewModel);

            foreach (PropertyDescriptor property in properties)
            {
                var propertyName  = property.Name;
                var propertyValue = property.GetValue(sourceViewModel);

                accessor[propertyName] = propertyValue;
            }
        }
Пример #15
0
    public static void SetMember <T> (this object obj, string memberPath, T value)
    {
        string[] memberNames = memberPath.Split('.');
        string   memberName  = "";
        object   _obj        = obj;

        for (int i = 0; i < memberNames.Length; i++)
        {
            memberName = memberNames[i];
            if (i < memberNames.Length - 1)
            {
                ObjectAccessor objectAccessor = ObjectAccessor.Create(_obj);
                _obj = objectAccessor[memberName];
            }
        }
        TypeAccessor typeAccessor = TypeAccessor.Create(_obj.GetType());

        typeAccessor[_obj, memberName] = value;
    }
Пример #16
0
        public override void DamageTaken(Unit attacker, ref uint damage)
        {
            // Attumen does not die until he mounts Midnight, let health fall to 1 and prevent further damage.
            if (damage >= me.GetHealth() && _phase != Phases.Mounted)
            {
                damage = (uint)(me.GetHealth() - 1);
            }

            if (_phase == Phases.AttumenEngages && me.HealthBelowPctDamaged(25, damage))
            {
                _phase = Phases.None;

                Creature midnight = ObjectAccessor.GetCreature(me, _midnightGUID);
                if (midnight != null)
                {
                    midnight.GetAI().DoCastAOE(SpellIds.Mount, true);
                }
            }
        }
Пример #17
0
        public void GetMethod()
        {
            var cb = new Device();

            var propName = "Id";

            var accessor = TypeAccessor.Create(cb.GetType());
            var getVal   = accessor[cb, propName];

            accessor[cb, propName] = (int)getVal + 1;

            var wrapped = ObjectAccessor.Create(cb);
            var val     = wrapped[propName];

            wrapped[propName] = (int)val + 1;
            var ifexist = wrapped["Id"];

            Assert.IsTrue(cb.DeviceId == "2");
        }
Пример #18
0
        public void ModifyName(ObjectGuid guid, string name, DeclinedName declinedName)
        {
            if (!HasJournalLock())
            {
                return;
            }

            BattlePet pet = GetPet(guid);

            if (pet == null)
            {
                return;
            }

            pet.PacketInfo.Name = name;
            pet.NameTimestamp   = GameTime.GetGameTime();

            pet.DeclinedName = new DeclinedName();
            if (declinedName != null)
            {
                pet.DeclinedName = declinedName;
            }

            if (pet.SaveInfo != BattlePetSaveInfo.New)
            {
                pet.SaveInfo = BattlePetSaveInfo.Changed;
            }

            // Update the timestamp if the battle pet is summoned
            Player   player            = _owner.GetPlayer();
            Creature summonedBattlePet = ObjectAccessor.GetCreatureOrPetOrVehicle(player, player.GetCritterGUID());

            if (summonedBattlePet != null)
            {
                if (player.GetSummonedBattlePetGUID() == summonedBattlePet.GetBattlePetCompanionGUID())
                {
                    if (summonedBattlePet.GetBattlePetCompanionGUID() == guid)
                    {
                        summonedBattlePet.SetBattlePetCompanionNameTimestamp((uint)pet.NameTimestamp);
                    }
                }
            }
        }
Пример #19
0
        public override void MovementInform(MovementGeneratorType type, uint id)
        {
            ObjectGuid guid = _instance.GetGuidData(BossIds.Xt002);

            if (type == MovementGeneratorType.Follow && id == guid.GetCounter())
            {
                Creature xt002 = ObjectAccessor.GetCreature(me, guid);
                if (xt002)
                {
                    if (me.IsWithinMeleeRange(xt002))
                    {
                        DoCast(xt002, SpellIds.ScrapbotRideVehicle);
                        // Unapply vehicle aura again
                        xt002.RemoveAurasDueToSpell(SpellIds.ScrapbotRideVehicle);
                        me.DespawnOrUnsummon();
                    }
                }
            }
        }
Пример #20
0
        void HandleDismissCritter(DismissCritter packet)
        {
            Unit pet = ObjectAccessor.GetCreatureOrPetOrVehicle(GetPlayer(), packet.CritterGUID);

            if (!pet)
            {
                Log.outDebug(LogFilter.Network, "Vanitypet {0} does not exist - player '{1}' ({2} / account: {3}) attempted to dismiss it (possibly lagged out)",
                             packet.CritterGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString(), GetAccountId());
                return;
            }

            if (GetPlayer().GetCritterGUID() == pet.GetGUID())
            {
                if (pet.IsTypeId(TypeId.Unit) && pet.ToCreature().IsSummon())
                {
                    pet.ToTempSummon().UnSummon();
                }
            }
        }
Пример #21
0
        public override void SpellHit(Unit caster, SpellInfo spell)
        {
            switch (spell.Id)
            {
            case SpellIds.DarkEmpowermentT:
                me.UpdateEntry(CreatureIds.EmpoweredAdherent);
                break;

            case SpellIds.DarkMartyrdomT:
                me.SetReactState(ReactStates.Passive);
                me.InterruptNonMeleeSpells(true);
                me.AttackStop();
                DoCastSelf(SpellIds.DarkMartyrdomAdherent);
                break;

            case SpellIds.DarkMartyrdomAdherent:
                _scheduler.Schedule(TimeSpan.FromSeconds(2), context =>
                {
                    me.UpdateEntry(CreatureIds.ReanimatedAdherent);
                    DoCastSelf(SpellIds.PermanentFeighDeath);
                    DoCastSelf(SpellIds.ClearAllDebuffs);
                    DoCastSelf(SpellIds.FullHeal, true);
                    me.AddUnitFlag(UnitFlags.Stunned | UnitFlags.Unk29 | UnitFlags.NotSelectable);
                }).Schedule(TimeSpan.FromSeconds(6), context =>
                {
                    me.RemoveAurasDueToSpell(SpellIds.PermanentFeighDeath);
                    me.RemoveUnitFlag(UnitFlags.Stunned | UnitFlags.Unk29 | UnitFlags.NotSelectable);
                    me.SetReactState(ReactStates.Aggressive);
                    DoCastSelf(SpellIds.ShorudOfTheOccult);
                    DoZoneInCombat(me);

                    Creature ladyDeathwhisper = ObjectAccessor.GetCreature(me, _instance.GetGuidData(Bosses.LadyDeathwhisper));
                    if (ladyDeathwhisper != null)
                    {
                        ladyDeathwhisper.GetAI().Talk(TextIds.SayAnimateDead);
                    }
                });
                break;

            default:
                break;
            }
        }
Пример #22
0
        public override void JustDied(Unit killer)
        {
            Creature otherWorm = ObjectAccessor.GetCreature(me, instance.GetGuidData(OtherWormEntry));

            if (otherWorm)
            {
                if (!otherWorm.IsAlive())
                {
                    instance.SetData(DataTypes.NorthrendBeasts, NorthrendBeasts.SnakesDone);

                    me.DespawnOrUnsummon();
                    otherWorm.DespawnOrUnsummon();
                }
                else
                {
                    instance.SetData(DataTypes.NorthrendBeasts, NorthrendBeasts.SnakesSpecial);
                }
            }
        }
Пример #23
0
        public override void DoAction(int actionId)
        {
            if (actionId == Misc.ActionOutro)
            {
                Creature tyrannusPtr = ObjectAccessor.GetCreature(me, _instanceScript.GetGuidData(DataTypes.TyrannusEvent));
                if (tyrannusPtr)
                {
                    tyrannusPtr.NearTeleportTo(Misc.outroPos[1].GetPositionX(), Misc.outroPos[1].GetPositionY(), Misc.outroPos[1].GetPositionZ(), Misc.outroPos[1].GetOrientation());
                }
                else
                {
                    tyrannusPtr = me.SummonCreature(CreatureIds.TyrannusEvents, Misc.outroPos[1], TempSummonType.ManualDespawn);
                }

                tyrannusPtr.SetCanFly(true);
                me.GetMotionMaster().MovePoint(Misc.PointKrickIntro, Misc.outroPos[0].GetPositionX(), Misc.outroPos[0].GetPositionY(), Misc.outroPos[0].GetPositionZ());
                tyrannusPtr.SetFacingToObject(me);
            }
        }
Пример #24
0
        public override bool OnGossipHello(Player player, GameObject go)
        {
            Creature anchor = go.FindNearestCreature(29521, 15);

            if (anchor)
            {
                ObjectGuid prisonerGUID = anchor.GetAI().GetGUID();
                if (!prisonerGUID.IsEmpty())
                {
                    Creature prisoner = ObjectAccessor.GetCreature(player, prisonerGUID);
                    if (prisoner)
                    {
                        ((npc_unworthy_initiate)prisoner.GetAI()).EventStart(anchor, player);
                    }
                }
            }

            return(false);
        }
Пример #25
0
 void AddsAttack()
 {
     for (byte i = 0; i < 4; ++i)
     {
         if (!AddGUID[i].IsEmpty())
         {
             Creature temp = ObjectAccessor.GetCreature((me), AddGUID[i]);
             if (temp && temp.IsAlive())
             {
                 temp.GetAI().AttackStart(me.GetVictim());
                 DoZoneInCombat(temp);
             }
             else
             {
                 EnterEvadeMode();
             }
         }
     }
 }
Пример #26
0
        internal object Create(ServiceName name, bool isEnumerable, object arguments)
        {
            Func <object> compiledFactory;
            var           hasPendingResolutionContext = ResolutionContext.HasPendingResolutionContext;

            if (arguments == null && factoryCache.TryGetValue(name, out compiledFactory) && !hasPendingResolutionContext)
            {
                return(compiledFactory());
            }
            var activation                = ResolutionContext.Push(this);
            ContainerService result       = null;
            List <string>    oldContracts = null;

            try
            {
                if (hasPendingResolutionContext)
                {
                    oldContracts = activation.activated.Contracts.Replace(name.Contracts);
                    name         = new ServiceName(name.Type);
                }
                result = ResolveCore(name, true, ObjectAccessor.Get(arguments), activation.activated);
            }
            finally
            {
                if (oldContracts != null)
                {
                    activation.activated.Contracts.Restore(oldContracts);
                }
                PopResolutionContext(activation, result, isEnumerable);
            }
            if (!hasPendingResolutionContext)
            {
                result.EnsureInitialized(containerContext, result);
            }
            result.CheckStatusIsGood(containerContext);
            if (isEnumerable)
            {
                return(result.GetAllValues());
            }
            result.CheckSingleValue(containerContext);
            return(result.Instances[0].Instance);
        }
Пример #27
0
        public override void Reset()
        {
            Initialize();

            DoCast(SpellIds.AuraBoombot); // For achievement

            // HACK/workaround:
            // these values aren't confirmed - lack of data - and the values in DB are incorrect
            // these values are needed for correct damage of Boom spell
            me.SetFloatValue(UnitFields.MinDamage, 15000.0f);
            me.SetFloatValue(UnitFields.MaxDamage, 18000.0f);

            // @todo proper waypoints?
            Creature pXT002 = ObjectAccessor.GetCreature(me, _instance.GetGuidData(BossIds.Xt002));

            if (pXT002)
            {
                me.GetMotionMaster().MoveFollow(pXT002, 0.0f, 0.0f);
            }
        }
Пример #28
0
        public void Test_private_property()
        {
            var foo            = new Foo(privateProp: "red");
            var publicAccessor = ObjectAccessor.For(typeof(Foo)).GetProperty("PrivateProp", false);

            Assert.IsNull(publicAccessor);             // can't get public accessor to private property

            var nonPublicAccessor = ObjectAccessor.For(typeof(Foo)).GetProperty("PrivateProp", true);

            Assert.IsNotNull(nonPublicAccessor);
            Assert.IsTrue(nonPublicAccessor.IsReadable);
            Assert.IsTrue(nonPublicAccessor.IsWritable);

            var value = nonPublicAccessor.GetValue(foo);

            Assert.AreEqual("red", value);

            nonPublicAccessor.SetValue(foo, "blue");
            Assert.AreEqual("blue", foo.GetPrivatePropValue());
        }
    public static void AssignValueToProperty(this ObjectAccessor accessor, string propertyName, object value)
    {
        var index = propertyName.IndexOf('.');

        if (index == -1)
        {
            var targetType = Expression.Parameter(accessor.Target.GetType());
            var property   = Expression.Property(targetType, propertyName);
            var type       = property.Type;
            type  = Nullable.GetUnderlyingType(type) ?? type;
            value = value == null?GetDefault(type) : Convert.ChangeType(value, type);

            accessor[propertyName] = value;
        }
        else
        {
            accessor = ObjectAccessor.Create(accessor[propertyName.Substring(0, index)]);
            AssignValueToProperty(accessor, propertyName.Substring(index + 1), value);
        }
    }
Пример #30
0
        public void SnQuery_Lexer_CharTypeDoesNotThrow()
        {
            var s        = new String(Enumerable.Range(1, 256 - 32).Select(i => (char)i).ToArray());
            var lexer    = new CqlLexer(s);
            var lexerAcc = new ObjectAccessor(lexer);
            var thrown   = false;

            try
            {
                while ((bool)lexerAcc.Invoke("NextChar"))
                {
                    ;
                }
            }
            catch (Exception) // not logged, not rethrown
            {
                thrown = true;
            }
            Assert.IsFalse(thrown);
        }
Пример #31
0
        /// <summary>
        /// Takes a path to a property (e.g. "Property/NestedProperty") and attempts to resolve it into a value within the context of this object.
        /// </summary>
        public static object ResolvePropertyPath(this object target, string path)
        {
            var pathParts = path.Split('/');
            var curObj    = target;

            try {
                foreach (var part in pathParts)
                {
                    // If this is an enumerable and the part is a valid number, get the nth item of that enumerable
                    if (curObj is IEnumerable e && int.TryParse(part, out var index))
                    {
                        curObj = e.ElementAtIndex(index);
                    }

                    // Otherwise if this is any other object, use FastMember to access the relevant property/field.
                    else
                    {
                        curObj = ObjectAccessor.Create(curObj)[part];
                    }
                }
Пример #32
0
        /// <summary>
        /// Sets the <paramref name="modelPropertyName"/> property of the <paramref name="model"/> to the <paramref name="newValue"/>
        /// if they are different and raise <see cref="PropertyChanged"/> for the property and other properties marked with the <see cref="AlsoNotifyAttribute"/>.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="model">The model instance.</param>
        /// <param name="modelPropertyName">The property name of the model.</param>
        /// <param name="newValue">The new value to set.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>True if the property changed.</returns>
        protected bool SetProperty <TModel, TValue>(TModel model, string modelPropertyName, TValue newValue, [CallerMemberName] string propertyName = null)
        {
            if (!_modelToAccessor.ContainsKey(model))
            {
                _modelToAccessor.Add(model, ObjectAccessor.Create(model));
            }

            var currentModelValue = (TValue)_modelToAccessor[model][modelPropertyName];

            if (EqualityComparer <TValue> .Default.Equals(currentModelValue, newValue))
            {
                return(false);
            }

            OnPropertyChanging(propertyName);
            _modelToAccessor[model][modelPropertyName] = newValue;
            RaisePropertyChanged(propertyName);
            OnPropertyChanged(propertyName);
            RaiseAlsoNotify(propertyName);
            return(true);
        }
Пример #33
0
        public void CanSetByRef()
        {
            var foo = new Foo {
                Val = 42
            };
            var acc = ObjectAccessor.Create(foo);

            acc["Val"] = 43;
            Assert.Equal(43, foo.Val);

            acc["Ref"] = 44;
            Assert.Equal(44, foo.Val);

            var ex = Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                acc["RefReadOnly"] = 45;
            });

            Assert.Equal("name", ex.ParamName);
            Assert.Equal(44, foo.Val);
        }
Пример #34
0
        void HandlePetAbandon(PetAbandon packet)
        {
            if (!GetPlayer().IsInWorld)
            {
                return;
            }

            Creature pet = ObjectAccessor.GetCreatureOrPetOrVehicle(GetPlayer(), packet.Pet);

            if (pet)
            {
                if (pet.IsPet())
                {
                    GetPlayer().RemovePet(pet.ToPet(), PetSaveMode.AsDeleted);
                }
                else if (pet.GetGUID() == GetPlayer().GetCharmGUID())
                {
                    GetPlayer().StopCastingCharm();
                }
            }
        }
Пример #35
0
 public World(Scene internalScene)
 {
     m_internalScene = internalScene;
     m_heights = new Heightmap(m_internalScene);
     m_objs = new ObjectAccessor(m_internalScene);
 }