コード例 #1
0
        public EquipmentWeaponViewModel(ItemSlots slot, IBaseMemoryOffset baseOffset)
            : base(slot, baseOffset)
        {
            this.memory               = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHand : Offsets.Main.OffHand);
            this.memory.Name          = slot.ToString();
            this.memory.ValueChanged += this.Memory_ValueChanged;

            this.modelSet     = this.memory.Value.Set;
            this.modelBase    = this.memory.Value.Base;
            this.modelVariant = this.memory.Value.Variant;
            this.dyeId        = this.memory.Value.Dye;

            if (this.HasWeapon)
            {
                this.scaleMem               = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHandScale : Offsets.Main.OffhandScale);
                this.scaleMem.Name          = slot + "_Scale";
                this.scaleMem.ValueChanged += this.ScaleMem_ValueChanged;

                this.colorMem               = baseOffset.GetMemory(slot == ItemSlots.MainHand ? Offsets.Main.MainHandColor : Offsets.Main.OffhandColor);
                this.colorMem.Name          = slot + "_Color";
                this.colorMem.ValueChanged += this.ColorMem_ValueChanged;

                this.scale = this.scaleMem.Value;
                this.color = this.colorMem.Value;
            }

            this.Item = this.GetItem();
            this.Dye  = this.GetDye();
        }
コード例 #2
0
ファイル: Actor.cs プロジェクト: EliCodesThings/CM3
        public Actor(IBaseMemoryOffset baseOffset)
        {
            this.baseOffset = baseOffset;

            this.Name = this.GetValue(Offsets.Main.Name);
            this.Type = this.GetValue(Offsets.Main.ActorType);
        }
コード例 #3
0
ファイル: Offset{T}.cs プロジェクト: Bluefissure/CM3
 public T GetValue(IBaseMemoryOffset baseOffset)
 {
     using (IMemory <T> mem = this.GetMemory(baseOffset))
     {
         return(mem.Value);
     }
 }
コード例 #4
0
 private void RefreshService_OnRefreshComplete(IBaseMemoryOffset baseOffset)
 {
     if (this.refreshCacheFile != null)
     {
         this.refreshCacheFile.Write(this.Appearance, this.Equipment, AppearanceFile.SaveModes.All);
         this.refreshCacheFile = null;
     }
 }
コード例 #5
0
 public Actor(ActorTypes type, IBaseMemoryOffset address, string actorId, string name, Modes mode)
 {
     this.Type        = type;
     this.BaseAddress = address;
     this.ActorId     = actorId;
     this.Name        = name;
     this.Mode        = mode;
 }
コード例 #6
0
        public Actor(IBaseMemoryOffset baseOffset)
        {
            this.baseOffset = baseOffset;

            this.Name        = this.GetValue(Offsets.Main.Name);
            this.Type        = this.GetValue(Offsets.Main.ActorType);
            this.Description = string.Empty;
        }
コード例 #7
0
        public IMemory <T> GetMemory <T>(IBaseMemoryOffset baseOffset, params IMemoryOffset[] offsets)
        {
            List <IMemoryOffset> newOffsets = new List <IMemoryOffset>();

            newOffsets.Add(new MappedBaseOffset(this.Process, (BaseOffset)baseOffset));
            newOffsets.AddRange(offsets);
            return(this.GetMemory <T>(newOffsets.ToArray()));
        }
コード例 #8
0
        private async Task Watch()
        {
            await Task.Delay(500);

            IInjectionService injection = App.Services.Get <IInjectionService>();

            while (this.IsAlive)
            {
                try
                {
                    await Task.Delay(1000);

                    Selection.Modes   mode       = this.GetMode();
                    IBaseMemoryOffset baseOffset = mode == Selection.Modes.GPose ? Offsets.Gpose : Offsets.Target;

                    ActorTypes type = baseOffset.GetValue(Offsets.ActorType);
                    string     name = baseOffset.GetValue(Offsets.Name);

                    // Hide name while debugging
                                        #if DEBUG
                    name = "Tester";
                                        #endif

                    string actorId = mode.ToString() + "_" + name;

                    if (string.IsNullOrEmpty(actorId))
                    {
                        this.CurrentGameTarget = null;
                        continue;
                    }

                    if (this.CurrentGameTarget == null ||
                        this.CurrentGameTarget.Type != type ||
                        this.CurrentGameTarget.ActorId != actorId ||
                        this.CurrentGameTarget.Mode != mode)
                    {
                        this.CurrentGameTarget = new Selection(type, baseOffset, actorId, name, mode);
                    }

                    if (this.UseGameTarget && this.CurrentSelection != this.CurrentGameTarget)
                    {
                        this.CurrentSelection = this.CurrentGameTarget;
                    }
                }
                catch (MemoryException)
                {
                    // If the user has _never_ selected anything in game, then the memory wont be read correctly.
                    // once the user has selected something, even if they then select nothing, the memory will work
                    // fine, leaving the old selected behind.
                    // so in this case, we just swallow the error, and let the thread loop.
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }
        }
コード例 #9
0
        public void Refresh(IBaseMemoryOffset offset)
        {
            this.applyCountdown = ApplyDelay;

            if (this.applyTask == null || this.applyTask.IsCompleted)
            {
                this.applyTask = this.ApplyAfterDelay(offset);
            }
        }
コード例 #10
0
        private void RefreshService_OnRefreshStarting(IBaseMemoryOffset baseOffset)
        {
            if (this.baseOffset != baseOffset)
            {
                return;
            }

            this.refreshCacheFile = new AppearanceFile();
            this.refreshCacheFile.Read(this.Appearance, this.Equipment, AppearanceFile.SaveModes.All);
        }
コード例 #11
0
        public UIntPtr GetAddress(IBaseMemoryOffset offset)
        {
            IMemoryOffset newOffset = new MappedBaseOffset(this.Process, (BaseOffset)offset);
            UIntPtr       ptr       = this.Process.GetAddress(newOffset);

            if (ptr == UIntPtr.Zero)
            {
                throw new InvalidAddressException();
            }

            return(ptr);
        }
コード例 #12
0
        private void OnActorChanged(Actor actor)
        {
            bool hasValidSelection = actor != null && (actor.Type == ActorTypes.Player || actor.Type == ActorTypes.BattleNpc || actor.Type == ActorTypes.EventNpc);

            if (hasValidSelection)
            {
                this.baseOffset = actor.BaseAddress;
            }

            Application.Current.Dispatcher.Invoke(() =>
            {
                this.IsEnabled = hasValidSelection;
            });
        }
コード例 #13
0
        private async Task ApplyAfterDelay(IBaseMemoryOffset actorOffset)
        {
            while (this.applyCountdown > 0)
            {
                while (this.applyCountdown > 0)
                {
                    this.applyCountdown -= 50;
                    await Task.Delay(50);
                }

                this.IsRefreshing = true;
                this.OnRefreshStarting?.Invoke(actorOffset);
                Log.Write("Refresh Begin", "Actor Refresh");

                using IMemory <ActorTypes> actorTypeMem = actorOffset.GetMemory(Offsets.Main.ActorType);
                actorTypeMem.Name = "Actor Type";
                using IMemory <byte> actorRenderMem = actorOffset.GetMemory(Offsets.Main.ActorRender);
                actorRenderMem.Name = "Actor Render";

                if (actorTypeMem.Value == ActorTypes.Player)
                {
                    actorTypeMem.SetValue(ActorTypes.BattleNpc, true);
                    actorRenderMem.SetValue(2, true);
                    await Task.Delay(150);

                    actorRenderMem.SetValue(0, true);
                    await Task.Delay(150);

                    actorTypeMem.SetValue(ActorTypes.Player, true);
                }
                else
                {
                    actorRenderMem.SetValue(2, true);
                    await Task.Delay(150);

                    actorRenderMem.SetValue(0, true);
                }

                this.OnRefreshComplete?.Invoke(actorOffset);
                Log.Write("Refresh Complete", "Actor Refresh");
                this.IsRefreshing = false;
            }
        }
コード例 #14
0
        public async Task RefreshAsync(IBaseMemoryOffset offset)
        {
            while (this.IsRefreshing)
            {
                await Task.Delay(100);
            }

            this.Refresh(offset);
            this.PendingRefreshImmediate();

            await Task.Delay(50);

            while (this.IsRefreshing)
            {
                await Task.Delay(100);
            }

            await Task.Delay(50);
        }
コード例 #15
0
        public void Retarget(Actor actor)
        {
            if (this.baseOffset == actor.baseOffset)
            {
                return;
            }

            Log.Write("Retargeting actor from " + this.Description + "(" + this.baseOffset + " to " + actor.Description + "(" + actor.baseOffset + ")");

            this.ActorRetargetBegin?.Invoke(this);

            this.baseOffset  = actor.baseOffset;
            this.Name        = actor.Name;
            this.Description = actor.Description;
            this.Type        = actor.Type;

            IMemory mem;

            foreach (WeakReference <IMemory> weakRef in this.memories)
            {
                if (weakRef.TryGetTarget(out mem))
                {
                    if (!mem.Active)
                    {
                        continue;
                    }

                    try
                    {
                        mem.UpdateBaseOffset(this.baseOffset);
                    }
                    catch (MemoryException)
                    {
                        mem.Dispose();
                    }
                }
            }

            this.ActorRetargetComplete?.Invoke(this);

            Log.Write("Retargeting actor done");
        }
コード例 #16
0
 /// <summary>
 /// Creates a two-way binding between this memory object and the given property.
 /// </summary>
 /// <param name="self">this.</param>
 /// <param name="offset">the offset to bind to.</param>
 /// <param name="owner">the object that owns the property.</param>
 /// <param name="propertyName">the property to bind.</param>
 public static void Bind <T>(this IBaseMemoryOffset self, IMemoryOffset <T> offset, object owner, string propertyName)
     where T : struct
 {
     self.GetMemory(offset).Bind(owner, propertyName);
 }
コード例 #17
0
ファイル: Offset{T}.cs プロジェクト: 92RED/CM3
 public IMemory <T> GetMemory(IBaseMemoryOffset baseAddress)
 {
     return(InjectionService.Instance.GetMemory <T>(baseAddress, this));
 }
コード例 #18
0
ファイル: InjectionService.cs プロジェクト: damphands/CM3
 public IMemory <T> GetMemory <T>(IBaseMemoryOffset <T> baseOffset, params IMemoryOffset <T>[] offsets)
 {
     return(this.service.GetMemory <T>(baseOffset, offsets));
 }
コード例 #19
0
 public EquipmentBaseViewModel(ItemSlots slot, IBaseMemoryOffset baseOffset)
 {
     this.baseOffset = baseOffset;
     this.gameData   = Services.Get <IGameDataService>();
     this.Slot       = slot;
 }
コード例 #20
0
        private void OnActorChanged(Actor actor)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                this.IsEnabled = false;
            });

            this.eqMem?.Dispose();
            this.MainHand?.Dispose();
            this.OffHand?.Dispose();
            this.eqMem?.Dispose();
            this.Head?.Dispose();
            this.Body?.Dispose();
            this.Hands?.Dispose();
            this.Legs?.Dispose();
            this.Feet?.Dispose();
            this.Ears?.Dispose();
            this.Neck?.Dispose();
            this.Wrists?.Dispose();
            this.LeftRing?.Dispose();
            this.RightRing?.Dispose();

            this.MainHand  = null;
            this.OffHand   = null;
            this.Head      = null;
            this.Body      = null;
            this.Hands     = null;
            this.Legs      = null;
            this.Feet      = null;
            this.Ears      = null;
            this.Neck      = null;
            this.Wrists    = null;
            this.LeftRing  = null;
            this.RightRing = null;

            if (actor == null || (actor.Type != ActorTypes.Player && actor.Type != ActorTypes.BattleNpc && actor.Type != ActorTypes.EventNpc))
            {
                return;
            }

            this.BaseOffset = actor.BaseAddress;

            // Weapon slots
            this.MainHand = new EquipmentWeaponViewModel(ItemSlots.MainHand, this.BaseOffset);
            this.OffHand  = new EquipmentWeaponViewModel(ItemSlots.OffHand, this.BaseOffset);

            // Equipment slots
            this.eqMem      = actor.BaseAddress.GetMemory(Offsets.Main.ActorEquipment);
            this.eqMem.Name = "Equipment";

            this.Head      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Head, this.BaseOffset);
            this.Body      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Body, this.BaseOffset);
            this.Hands     = new EquipmentItemViewModel(this.eqMem, ItemSlots.Hands, this.BaseOffset);
            this.Legs      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Legs, this.BaseOffset);
            this.Feet      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Feet, this.BaseOffset);
            this.Ears      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Ears, this.BaseOffset);
            this.Neck      = new EquipmentItemViewModel(this.eqMem, ItemSlots.Neck, this.BaseOffset);
            this.Wrists    = new EquipmentItemViewModel(this.eqMem, ItemSlots.Wrists, this.BaseOffset);
            this.LeftRing  = new EquipmentItemViewModel(this.eqMem, ItemSlots.LeftRing, this.BaseOffset);
            this.RightRing = new EquipmentItemViewModel(this.eqMem, ItemSlots.RightRing, this.BaseOffset);

            Application.Current.Dispatcher.Invoke(() =>
            {
                ////this.ContentArea.DataContext = null;
                this.ContentArea.DataContext = this;
                this.IsEnabled = true;
            });
        }
コード例 #21
0
        public EquipmentItemViewModel(IMemory <Equipment> equipmentMemory, ItemSlots slot, IBaseMemoryOffset baseOffset)
            : base(slot, baseOffset)
        {
            this.memory = equipmentMemory;
            Equipment.Item item = equipmentMemory.Value.GetItem(slot);

            if (item == null)
            {
                return;
            }

            this.modelBase    = item.Base;
            this.modelVariant = item.Variant;
            this.dyeId        = item.Dye;

            this.Item = this.GetItem();
            this.Dye  = this.GetDye();
        }
コード例 #22
0
ファイル: Offset{T}.cs プロジェクト: Bluefissure/CM3
 public IMemory <T> GetMemory(IBaseMemoryOffset baseAddress)
 {
     return(injection.GetMemory <T>(baseAddress, this));
 }
コード例 #23
0
 /// <summary>
 /// Creates a two-way binding between this memory object and the given property.
 /// </summary>
 /// <param name="self">this.</param>
 /// <param name="offset">the offset to bind to.</param>
 /// <param name="owner">the object that owns the property.</param>
 /// <param name="propertyName">the property to bind.</param>
 public static void UnBind <T>(this IBaseMemoryOffset self, IMemoryOffset <T> offset, object owner, string propertyName)
     where T : struct
 {
     BindUtility.Clear(owner, propertyName);
 }
コード例 #24
0
 public PossibleSelection(ActorTypes type, IBaseMemoryOffset address, string actorId, string name, Modes mode)
     : base(type, address, actorId, name, mode)
 {
 }
コード例 #25
0
ファイル: InjectionService.cs プロジェクト: 92RED/CM3
        public UIntPtr GetAddress(IBaseMemoryOffset offset)
        {
            IMemoryOffset newOffset = new MappedBaseOffset(this.Process.Process, (BaseOffset)offset);

            return(this.Process.GetAddress(newOffset));
        }