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 allTorches = InfoPoll.GetAllActorInstances() .Where(x => x.Actor == 0x5E).ToList(); foreach (var item in allTorches) { Ptr localTorch = SPtr.New((int)item.Ram.Start & 0xFFFFFF); var time = localTorch.ReadInt16(TORCH_TIMER_OFFSET); if (time <= 0) { unlitTorches.Add(item); } } if (unlitTorches.Count > 0) { var torchOvl = OvlActor.GetActorFiles().Where(x => x.Actor == 0x5E).SingleOrDefault(); var select = Rand.Next(0, unlitTorches.Count); Ptr torch = SPtr.New((int)unlitTorches[select].Ram.Start & 0xFFFFFF); torch.Write(TORCH_TIMER_OFFSET, TORCH_TIMER); if (torchOvl != null) { Ptr ovl = SPtr.New((int)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--; }
public static List <OvlActor> GetActorFiles() { List <OvlActor> actorFiles = new List <OvlActor>(); OvlActor working; byte[] actorTbl; byte[] actorFileData = new byte[LENGTH]; actorTbl = Zpr.ReadRam(OVL_TABLE_ADDR, TOTAL_ACTORS * LENGTH); for (int i = 0; i < TOTAL_ACTORS; i++) { Array.Copy(actorTbl, i * LENGTH, actorFileData, 0, LENGTH); working = new OvlActor(i, actorFileData); if (working.IsFileLoaded) { actorFiles.Add(working); } } return(actorFiles); }
public static List <ActorInstance> GetActorsInCategory(int cat) { return(OvlActor.GetActorInstances(cat)); }
public static List <ActorInstance> GetAllActorInstances() { return(OvlActor.GetActorInstances()); }
public ActorInstance(RomVersion version, N64Ptr address) { int instanceSize; int off = 0; Ptr ptr = SPtr.New(address); ActorId = ptr.ReadUInt16(0); Type = ptr.ReadByte(2); Room = ptr.ReadByte(3); Address = address; try { if (version.Game == Game.OcarinaOfTime) { if (ActorId == 0 && Type == 4) { ActorId = 0x008F; forcedActorId = true; } } // & 0xFFF is hack to correct instances with no proper actor id instanceSize = OvlActor.GetInstanceSize(ActorId & 0xFFF); } catch { instanceSize = 0; } Ram = new N64PtrRange(Address, Address + instanceSize); Variable = ptr.ReadUInt16(0x1C); Position = new Vector3 <float>( ptr.ReadFloat(0x24), ptr.ReadFloat(0x28), ptr.ReadFloat(0x2C)); if (version.Game == Game.OcarinaOfTime) { off = 0; } else { off = 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); ProcessInstance = ptr.ReadByte(0x115); }