public static T Evaluate <T, U, S>(this ScratchObject obj, string objectName, bool general = false) where T : IValoration, new() where U : ISpriteValoration, new() where S : IGeneralValoration, new() { if (obj.RawScripts == null) { return((T)ValorationHelper .Get_DefaultSingle <T, U>(objectName)); } return(Get_singleValoration <T, U>(obj.Scripts, obj.Blocks, obj.ScriptsString, objectName, obj.DeadCodeCount, obj.NestedControl, obj.NestedOperator, general)); }
private static int ProcessMessage(int messageIndex) { Sims3.SimIFace.StopWatch stopWatch = Sims3.SimIFace.StopWatch.Create(Sims3.SimIFace.StopWatch.TickStyles.Milliseconds); stopWatch.Start(); uint message = 0; stopWatch.SetElapsedTime(10); int readIndex = messageIndex; while (message == 0) { try { message = BitConverter.ToUInt32(messageBuffer, readIndex); readIndex += intSize; } catch { } while (stopWatch.GetElapsedTime() < 10) { } stopWatch.Restart(); } if (message == (uint)MessageIDs.HandShakeRequest) { byte[] comfirmBytes = BitConverter.GetBytes((uint)MessageIDs.HandShakeComfirm); sendBuffer.Add(comfirmBytes); bufferConnected = true; } else if (message == (uint)MessageIDs.StartGame) { Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates); gameStarted = true; } else if (message == (uint)MessageIDs.GameFlowNormal) { Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates); } else if (message == (uint)MessageIDs.GameFlowPause) { Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.SimIFace.Gameflow.GameSpeed.Pause, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates); } else if (message == (uint)MessageIDs.InteractionTerrain) { uint type = BitConverter.ToUInt32(messageBuffer, readIndex); readIndex += intSize; if (type == (uint)InteractionTerrainTypes.GoHereSameLot) { ulong targetID = BitConverter.ToUInt64(messageBuffer, readIndex); readIndex += longSize; float x = BitConverter.ToSingle(messageBuffer, readIndex); readIndex += sizeof(float); float y = BitConverter.ToSingle(messageBuffer, readIndex); readIndex += sizeof(float); float z = BitConverter.ToSingle(messageBuffer, readIndex); readIndex += sizeof(float); InteractionPriority priority = new InteractionPriority(); priority.Level = InteractionPriorityLevel.UserDirected; ObjectGuid guid = new ObjectGuid(); guid.Value = targetID; guid.mValue = targetID; Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(Terrain.GoHere.SameLotSingleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); Terrain.GoHere gohere = new Terrain.GoHere(); gohere.Init(ref paras); gohere.SetTargetPosition(new Vector3(x, y, z)); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(gohere); } } else if (message == (uint)MessageIDs.InteractionShared) { uint type = BitConverter.ToUInt32(messageBuffer, readIndex); readIndex += intSize; ulong targetID = BitConverter.ToUInt64(messageBuffer, readIndex); readIndex += longSize; InteractionPriority priority = new InteractionPriority(); priority.Level = InteractionPriorityLevel.UserDirected; ObjectGuid guid = new ObjectGuid(); guid.Value = targetID; guid.mValue = targetID; if (type == (uint)InteractionSharedTypes.JumpOnObject) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(JumpOnObject.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); JumpOnObject interaction = new JumpOnObject(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.JumpOffObject) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(JumpOffObject.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); JumpOffObject interaction = new JumpOffObject(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.SleepAndNapOnObject) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(SleepAndNapOnObject.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); SleepAndNapOnObject interaction = new SleepAndNapOnObject(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.StretchOnObject) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(StretchOnObject.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); StretchOnObject interaction = new StretchOnObject(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ShooOff) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ShooOff.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ShooOff interaction = new ShooOff(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ShooNeighborPet) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ShooNeighborPet.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ShooNeighborPet interaction = new ShooNeighborPet(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ShooFromFood) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ShooFromFood.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ShooFromFood interaction = new ShooFromFood(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ScratchObject) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ScratchObject.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ScratchObject interaction = new ScratchObject(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.PetSingAlong) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(PetSingAlong.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); PetSingAlong interaction = new PetSingAlong(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ReactToDisturbance) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ReactToDisturbance.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ReactToDisturbance interaction = new ReactToDisturbance(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.Sit) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(Sit.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); Sit interaction = new Sit(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.Stand) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(Stand.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); Stand interaction = new Stand(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.ViewObjects) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(ViewObjects.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); ViewObjects interaction = new ViewObjects(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.Reminisce) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(Reminisce.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); Reminisce interaction = new Reminisce(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } else if (type == (uint)InteractionSharedTypes.CatchFlies) { Sims3.Gameplay.Autonomy.InteractionObjectPair iop = new Sims3.Gameplay.Autonomy.InteractionObjectPair(CatchFlies.Singleton, Terrain.GetObject(guid)); InteractionInstanceParameters paras = new InteractionInstanceParameters(iop, Sims3.Gameplay.Actors.Sim.ActiveActor, priority, false, true); CatchFlies interaction = new CatchFlies(); interaction.Init(ref paras); netIntercactionAdded = true; Sims3.Gameplay.Actors.Sim.ActiveActor.InteractionQueue.Add(interaction); } } else { return(-1); } return(readIndex); }
public static T GeneralEvaluation <T, U, S>( this ScratchObject obj, string objectName, List <U> previousValorations) where T : IValoration, new() where U : ISpriteValoration, new() where S : IGeneralValoration, new() { if (obj.Children == null) { return((T)ValorationHelper .Get_DefaultSingle <T, U>(objectName)); } var blocks = new List <string>(); var scripts = new List <List <object> >(); var scriptList = new List <string>(); var messagesRecieved = new List <string>(); var messagesSent = new List <string>(); var deadCodeSums = 0; if (obj.RawScripts != null) { blocks.AddRange(obj.Blocks); scripts.AddRange(obj.Scripts); scriptList.AddRange(obj.ScriptsString); messagesRecieved.AddRange(obj.MessagesRecieved); messagesSent.AddRange(obj.MessagesSent); } foreach (var child in obj.Children) { deadCodeSums += child.DeadCodeCount; if (child.Blocks != null) { blocks.AddRange(child.Blocks); } if (child.Scripts != null) { scripts.AddRange(child.Scripts); } if (child.ScriptsString != null) { scriptList.AddRange(child.ScriptsString); } if (child.MessagesRecieved != null) { messagesRecieved.AddRange(child.MessagesRecieved); } if (child.MessagesSent != null) { messagesSent.AddRange(child.MessagesSent); } } var vars = obj.Variables != null?obj.Variables.ToList() : new List <Variable>(); var lists = obj.Lists != null?obj.Lists.ToList() : new List <ScratchList>(); return(Get_generalValoration <T, U, S>(scripts, blocks, scriptList, objectName, previousValorations, vars, lists, deadCodeSums, previousValorations.Count, messagesRecieved, messagesSent, true)); }
public static bool IsOperatorBlock(this ScratchObject _this, string name) { return(_BasicOperators.ContainsKey(name) || _MediumOperators.ContainsKey(name)); }
public static bool IsControlBlock(this ScratchObject _this, string name) { return(_ControlBlocks.ContainsKey(name)); }