Exemplo n.º 1
0
        private static void callback(object state)
        {
            Test obj = (Test)state;


            if (obj.RandTick < 0)
            {
                obj.RandTick = Rand.Next(8, 26);
            }
            else if (obj.RandTick == 0)
            {
                List <ActorInstance> unlitTorches = new List <ActorInstance>();
                var map = ActorMemoryMapper.FetchFilesAndInstances();

                var allTorches = map.Instances
                                 .Where(x => x.Actor == 0x5E).ToList();


                foreach (var item in allTorches)
                {
                    Ptr localTorch = SPtr.New(item.Ram.Start);
                    var time       = localTorch.ReadInt16(TORCH_TIMER_OFFSET);
                    if (time <= 0)
                    {
                        unlitTorches.Add(item);
                    }
                }

                if (unlitTorches.Count > 0)
                {
                    var torchOvl = map.Files.Where(x => x.Actor == 0x5E).SingleOrDefault();
                    var select   = Rand.Next(0, unlitTorches.Count);

                    Ptr torch = SPtr.New(unlitTorches[select].Ram.Start);

                    torch.Write(TORCH_TIMER_OFFSET, TORCH_TIMER);

                    if (torchOvl != null)
                    {
                        Ptr ovl = SPtr.New(torchOvl.Ram.Start);
                        int lit = ovl.ReadInt32(TORCHES_LIT_OFFSET);
                        lit++;
                        ovl.Write(TORCHES_LIT_OFFSET, lit);
                    }
                    //Console.WriteLine(string.Format("Light! {0:X6}", (int)torch));
                }
            }
            obj.RandTick--;
        }
Exemplo n.º 2
0
        public ActorInstance(RomVersion version, N64Ptr address, ActorMemoryMapper map)
        {
            Ptr ptr = SPtr.New(address);


            ActorId = ptr.ReadUInt16(0);
            Type    = ptr.ReadByte(2);
            Room    = ptr.ReadByte(3);
            Address = address;

            Variable = ptr.ReadUInt16(0x1C);

            Position = new Vector3 <float>(
                ptr.ReadFloat(0x24),
                ptr.ReadFloat(0x28),
                ptr.ReadFloat(0x2C));


            int off = version.Game == Game.OcarinaOfTime ? 0 : 8;

            Rotation = new Vector3 <short>(
                ptr.ReadInt16(0xB4 + off),
                ptr.ReadInt16(0xB6 + off),
                ptr.ReadInt16(0xB8 + off));

            PrevActor       = ptr.ReadInt32(0x120 + off);
            NextActor       = ptr.ReadInt32(0x124 + off);
            Update          = ptr.ReadInt32(0x130 + off);
            ProcessInstance = ptr.ReadByte(0x115);


            map.GetActorIdAndSize(this, out ushort actorId, out uint instanceSize);
            ActorId = actorId;

            Ram = new N64PtrRange(Address, Address + instanceSize);
        }