Beispiel #1
0
        public static List <Error> ExecuteRunBlock(ThingInstance currentInstance, string runBlockId, List <Symbol> parameters = null)
        {
            var currentRunBlock = currentInstance.Breed.RunBlocks.TryGetValue(runBlockId, out var runBlock);

            if (!currentRunBlock)
            {
                return(Instance.errors);
            }

            Instance.scope = new Scope(World.Instance.ToScope(), runBlockId);

            var instanceType = TypeSystem.Instance[currentInstance.GetType().Name];

            Instance.scope["Self"] = new Symbol("Self", instanceType, currentInstance.Id);
            if (parameters != null)
            {
                foreach (var p in parameters)
                {
                    Instance.scope[p.Name] = p;
                }
            }

            Instance.Visit(runBlock);
            return(Instance.errors);
        }
Beispiel #2
0
 private void ClearState()
 {
     scope            = new Scope();
     errors           = new List <Error>();
     buildBreedOnly   = false;
     currentAnimation = null;
     currentBreed     = null;
     currentInstance  = null;
     currentModel     = null;
     currentRegion    = null;
 }