Exemplo n.º 1
0
        public ClassDefinition(
            Token classToken,
            Token nameToken,
            IList <Token> subclassTokens,
            IList <string> subclassNames,
            Node owner,
            FileScope fileScope,
            ModifierCollection modifiers,
            AnnotationCollection annotations,
            ParserContext context)
            : base(classToken, owner, fileScope, modifiers)
        {
            this.ClassID = context.ClassIdAlloc++;

            this.NameToken             = nameToken;
            this.BaseClassTokens       = subclassTokens.ToArray();
            this.BaseClassDeclarations = subclassNames.ToArray();
            this.annotations           = annotations;

            if (this.Modifiers.HasPrivate)
            {
                throw new ParserException(this.Modifiers.PrivateToken, "Private classes are not supported yet.");
            }
            if (this.Modifiers.HasProtected)
            {
                throw new ParserException(this.Modifiers.ProtectedToken, "Protected classes are not supported yet.");
            }
        }
Exemplo n.º 2
0
        protected override FunctionDefinition MaybeParseFunctionDefinition(
            TokenStream tokens,
            Node owner,
            FileScope fileScope,
            AnnotationCollection annotations,
            ModifierCollection modifiers)
        {
            TokenStream.StreamState tss = tokens.RecordState();
            AType returnType            = this.parser.TypeParser.TryParse(tokens);

            if (returnType == null)
            {
                return(null);
            }
            Token functionName = tokens.PopIfWord();

            if (functionName == null)
            {
                tokens.RestoreState(tss);
                return(null);
            }

            if (tokens.IsNext("("))
            {
                tokens.RestoreState(tss);
                return(this.ParseFunction(tokens, owner as TopLevelEntity, fileScope, modifiers, annotations));
            }

            tokens.RestoreState(tss);
            return(null);
        }
Exemplo n.º 3
0
        void Start()
        {
            lRb        = GetComponent <Rigidbody2D>();
            eDirection = Direction.Right;

            var shieldObj = Instantiate(shieldPrefab, transform.position + new Vector3(.6f, .1f), Quaternion.identity, transform);

            eShield = shieldObj.GetComponent <Shield>();

            lNetworkAttacks = new List <NetworkAttack>();

            lHooks     = new HookCollection();
            eModifiers = new ModifierCollection(lHooks);
            // GameController will remove these when the game starts.
            eModifiers.CantAttack.Add();
            eModifiers.CantMove.Add();
            StandardHooks.Install(lHooks, eModifiers);
            lJumpForceHook = new StandardJumpForce();
            lJumpForceHook.Install(lHooks);
            pModifiersDebugField = new ModifiersDebugField(eModifiers, "P" + eId + ": ");

            if (pInputManager != null)
            {
                Initialize();
                lInitialized = true;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a parse tree for an event declaration.
 /// </summary>
 /// <param name="attributes">The attributes for the parse tree.</param>
 /// <param name="modifiers">The modifiers for the parse tree.</param>
 /// <param name="keywordLocation">The location of the keyword.</param>
 /// <param name="name">The name of the declaration.</param>
 /// <param name="parameters">The parameters of the declaration.</param>
 /// <param name="asLocation">The location of the 'As', if any.</param>
 /// <param name="resultTypeAttributes">The attributes on the result type, if any.</param>
 /// <param name="resultType">The result type, if any.</param>
 /// <param name="implementsList">The list of implemented members.</param>
 /// <param name="span">The location of the parse tree.</param>
 /// <param name="comments">The comments for the parse tree.</param>
 public EventDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, ParameterCollection parameters, Location asLocation, AttributeBlockCollection resultTypeAttributes, TypeName resultType, NameCollection implementsList, Span span,
                         IList <Comment> comments) : base(TreeType.EventDeclaration, attributes, modifiers, keywordLocation, name, null, parameters, asLocation, resultTypeAttributes, resultType,
                                                          span, comments)
 {
     SetParent(implementsList);
     _ImplementsList = implementsList;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new parse tree for a Sub declaration.
 /// </summary>
 /// <param name="attributes">The attributes for the parse tree.</param>
 /// <param name="modifiers">The modifiers for the parse tree.</param>
 /// <param name="keywordLocation">The location of the keyword.</param>
 /// <param name="name">The name of the declaration.</param>
 /// <param name="typeParameters">The type parameters on the declaration, if any.</param>
 /// <param name="parameters">The parameters of the declaration.</param>
 /// <param name="implementsList">The list of implemented members.</param>
 /// <param name="handlesList">The list of handled events.</param>
 /// <param name="statements">The statements in the declaration.</param>
 /// <param name="endDeclaration">The end block declaration, if any.</param>
 /// <param name="span">The location of the parse tree.</param>
 /// <param name="comments">The comments for the parse tree.</param>
 public SubDeclaration(
     AttributeBlockCollection attributes,
     ModifierCollection modifiers,
     Location keywordLocation,
     SimpleName name,
     TypeParameterCollection typeParameters,
     ParameterCollection parameters,
     NameCollection implementsList,
     NameCollection handlesList,
     StatementCollection statements,
     EndBlockDeclaration endDeclaration,
     Span span,
     IList <Comment> comments) :
     base(
         TreeType.SubDeclaration,
         attributes,
         modifiers,
         keywordLocation,
         name,
         typeParameters,
         parameters,
         Location.Empty,
         null,
         null,
         implementsList,
         handlesList,
         statements,
         endDeclaration,
         span,
         comments)
 {
 }
Exemplo n.º 6
0
 public void before()
 {
     collection = new ModifierCollection();
     mul        = new TestMutiModifier(2);
     add        = new TestAdditionModifier(5);
     pres       = new TestPresModifier(50);
 }
Exemplo n.º 7
0
        public Namespace(
            Token namespaceToken,
            string name,
            Node owner,
            FileScope fileScope,
            ModifierCollection modifiers,
            AnnotationCollection annotations)
            : base(namespaceToken, owner, fileScope, modifiers)
        {
            this.DefaultName = name;
            this.FullyQualifiedDefaultName = owner == null
                ? name
                : (((Namespace)owner).FullyQualifiedDefaultName + "." + name);
            this.FullyQualifiedDefaultNameSegments = this.FullyQualifiedDefaultName.Split('.');
            this.DefaultNameSegments = this.DefaultName.Split('.');

            this.NamesByLocale = annotations.GetNamesByLocale(this.DefaultNameSegments.Length)
                                 .ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Split('.'));

            Locale defaultLocale = fileScope.CompilationScope.Locale;

            if (!this.NamesByLocale.ContainsKey(defaultLocale))
            {
                this.NamesByLocale[defaultLocale] = this.DefaultName.Split('.');
            }

            this.NestDepth = this.FullyQualifiedDefaultNameSegments.Length - this.DefaultNameSegments.Length;
        }
 internal unsafe override void ExecuteModifiers(ModifierCollection modifiers, float elapsedSeconds, ref Particle particle, int index, int count)
 {
     foreach (var slot in modifiers.Slots)
     {
         slot.Update(elapsedSeconds, ref particle, index, count);
     }
 }
Exemplo n.º 9
0
        public FieldDefinition(
            Token fieldToken,
            AType fieldType,
            Token nameToken,
            ClassDefinition owner,
            ModifierCollection modifiers,
            AnnotationCollection annotations)
            : base(fieldToken, owner, owner.FileScope, modifiers)
        {
            this.NameToken          = nameToken;
            this.FieldType          = fieldType;
            this.DefaultValue       = null;
            this.MemberID           = -1;
            this.Annotations        = annotations;
            this.Lambdas            = new List <Lambda>();
            this.ArgumentNameLookup = new HashSet <string>();

            if (modifiers.HasAbstract)
            {
                throw new ParserException(modifiers.AbstractToken, "Fields cannot be abstract.");
            }
            if (modifiers.HasOverride)
            {
                throw new ParserException(modifiers.OverrideToken, "Fields cannot be marked as overrides.");
            }
            if (modifiers.HasFinal)
            {
                throw new ParserException(modifiers.FinalToken, "Final fields are not supported yet.");
            }
        }
Exemplo n.º 10
0
        protected override FunctionDefinition ParseFunction(
            TokenStream tokens,
            TopLevelEntity nullableOwner,
            FileScope fileScope,
            ModifierCollection modifiers,
            AnnotationCollection annotations)
        {
            AType returnType        = this.parser.TypeParser.Parse(tokens);
            Token firstToken        = modifiers.FirstToken ?? returnType.FirstToken;
            Token functionNameToken = tokens.Pop();

            this.parser.VerifyIdentifier(functionNameToken);

            FunctionDefinition fd = new FunctionDefinition(firstToken, returnType, nullableOwner, functionNameToken, modifiers, annotations, fileScope);

            tokens.PopExpected("(");
            List <AType>      argTypes      = new List <AType>();
            List <Token>      argNames      = new List <Token>();
            List <Expression> defaultValues = new List <Expression>();

            this.ParseArgumentListDeclaration(tokens, fd, argTypes, argNames, defaultValues);

            fd.ArgTypes      = argTypes.ToArray();
            fd.ArgNames      = argNames.ToArray();
            fd.DefaultValues = defaultValues.ToArray();
            fd.FinalizeArguments();

            IList <Executable> code = this.parser.ExecutableParser.ParseBlock(tokens, true, fd);

            fd.Code = code.ToArray();

            return(fd);
        }
Exemplo n.º 11
0
/****************** Constructor *****************/
    public Character()
    {
        Abilities = new Dictionary <string, Ability>(Definitions.StringComp)
        {
            ["Strength"]     = new Ability(),
            ["Constitution"] = new Ability(),
            ["Intelligence"] = new Ability(),
            ["Wisdom"]       = new Ability(),
            ["Dexterity"]    = new Ability(),
            ["Charisma"]     = new Ability()
        };

        Skills = new Dictionary <string, Skill>(Definitions.StringComp)
        {
            ["Acrobatics"]      = new Skill("Dexterity"),
            ["Animal Handling"] = new Skill("Wisdom"),
            ["Arcana"]          = new Skill("Intelligence"),
            ["Athletics"]       = new Skill("Strength"),
            ["Deception"]       = new Skill("Charisma"),
            ["History"]         = new Skill("Intelligence"),
            ["Insight"]         = new Skill("Wisdom"),
            ["Intimidation"]    = new Skill("Charisma"),
            ["Investigation"]   = new Skill("Intelligence"),
            ["Medicine"]        = new Skill("Wisdom"),
            ["Nature"]          = new Skill("Intelligence"),
            ["Perception"]      = new Skill("Wisdom"),
            ["Performance"]     = new Skill("Charisma"),
            ["Persuasion"]      = new Skill("Charisma"),
            ["Religion"]        = new Skill("Intelligence"),
            ["Slight of Hand"]  = new Skill("Dexterity"),
            ["Stealth"]         = new Skill("Dexterity"),
            ["Survival"]        = new Skill("Wisdom")
        };

        ActionEconomy = new Dictionary <string, int>()
        {
            ["Action"]       = 1,
            ["Bonus Action"] = 1,
            ["Reaction"]     = 1
        };

        Modifiers     = new ModifierCollection();
        Resistances   = new List <string>();
        Immunities    = new List <string>();
        Proficiencies = new List <string>();
        EquippedItems = new List <Item>();
        FreeHands     = 2;

        Level = 1;

        Dying      = false;
        Dead       = false;
        DeathSaves = 0;
        DeathFails = 0;

        MaxHP     = 6;
        CurrentHP = MaxHP;
        TempHP    = 0;
    }
Exemplo n.º 12
0
        /// <summary>
        /// Instantiates a new instance of the Emitter class.
        /// </summary>
        public Emitter()
        {
            this.Name = Emitter.NextEmitterName();

            this.Enabled = true;

            this.Modifiers = new ModifierCollection();
        }
Exemplo n.º 13
0
        protected ModifiedDeclaration(TreeType type, AttributeBlockCollection attributes, ModifierCollection modifiers, Span span, IList <Comment> comments) : base(type, span, comments)
        {
            SetParent(attributes);
            SetParent(modifiers);

            _Attributes = attributes;
            _Modifiers  = modifiers;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructs a parse tree for an Enum declaration.
        /// </summary>
        /// <param name="attributes">The attributes for the parse tree.</param>
        /// <param name="modifiers">The modifiers for the parse tree.</param>
        /// <param name="keywordLocation">The location of the keyword.</param>
        /// <param name="name">The name of the declaration.</param>
        /// <param name="asLocation">The location of the 'As', if any.</param>
        /// <param name="elementType">The element type of the enumerated type, if any.</param>
        /// <param name="declarations">The enumerated values.</param>
        /// <param name="endStatement">The end block declaration, if any.</param>
        /// <param name="span">The location of the parse tree.</param>
        /// <param name="comments">The comments for the parse tree.</param>
        public EnumDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location keywordLocation, SimpleName name, Location asLocation, TypeName elementType, DeclarationCollection declarations, EndBlockDeclaration endStatement, Span span, IList <Comment> comments
                               ) : base(TreeType.EnumDeclaration, attributes, modifiers, keywordLocation, name, declarations, endStatement, span, comments)
        {
            SetParent(elementType);

            _AsLocation  = asLocation;
            _ElementType = elementType;
        }
Exemplo n.º 15
0
 internal DefaultReturnParameterName(MemberName member, TypeName parameterType, ModifierCollection modifiers)
 {
     _parameterType = parameterType;
     _member        = member;
     if (modifiers != null)
     {
         _modifiers = ModifierCollection.Empty;
     }
 }
Exemplo n.º 16
0
/****************** Modifier Management **********************/
    public void RefreshModifiers()
    {
        _CombinedMods = new ModifierCollection(Modifiers);
        // TODO: Check for attunement to character
        foreach (Item item in EquippedItems)
        {
            _CombinedMods.Add(item.Modifiers);
        }
    }
        /// <summary>
        /// Constructs a new parse tree for a Get property accessor.
        /// </summary>
        /// <param name="attributes">The attributes for the parse tree.</param>
        /// <param name="modifiers">The modifiers for the parse tree.</param>
        /// <param name="getLocation">The location of the 'Get'.</param>
        /// <param name="statements">The statements in the declaration.</param>
        /// <param name="endDeclaration">The end block declaration, if any.</param>
        /// <param name="span">The location of the parse tree.</param>
        /// <param name="comments">The comments for the parse tree.</param>
        public GetAccessorDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location getLocation, StatementCollection statements, EndBlockDeclaration endDeclaration, Span span, IList <Comment> comments) : base(TreeType.GetAccessorDeclaration, attributes, modifiers, span, comments)
        {
            SetParent(statements);
            SetParent(endDeclaration);

            _GetLocation    = getLocation;
            _Statements     = statements;
            _EndDeclaration = endDeclaration;
        }
Exemplo n.º 18
0
        public static void Install(HookCollection hooks, ModifierCollection modifiers)
        {
            new StandardWalkForce().Install(hooks);

            (modifiers.CantMove.Hook = new CantMoveMaxSpeedHook()).Install(hooks);
            (modifiers.Slow.Hook = new SlowMaxSpeedHook()).Install(hooks);
            (modifiers.Fast.Hook = new FastMaxSpeedHook()).Install(hooks);
            new StandardMaxSpeed().Install(hooks);
        }
        public Emitter(int capacity, TimeSpan term, Profile profile)
        {
            _term = (float)term.TotalSeconds;

            Buffer = new ParticleBuffer(capacity);
            Profile = profile;
            Modifiers = new ModifierCollection();
            ModifierExecutionStrategy = ModifierExecutionStrategy.Parallel;
            Parameters = new ReleaseParameters();
        }
Exemplo n.º 20
0
    public TestWeapon()
    {
        Modifier m = new AttackModifier(5);

        modifiers = new ModifierCollection();
        modifiers.add(m);

        damgeMin = 20;
        damgeMax = 30;
    }
Exemplo n.º 21
0
 public Buff(float timer, List <Modifier> mods)
 {
     this.timer = timer;
     timeLeft   = this.timer;
     modifiers  = new ModifierCollection();
     for (int i = 0; i < mods.Count; i++)
     {
         modifiers.add(mods[i]);
     }
 }
Exemplo n.º 22
0
        protected override void ParseClassMember(
            TokenStream tokens,
            FileScope fileScope,
            ClassDefinition classDef,
            IList <FunctionDefinition> methodsOut,
            IList <FieldDefinition> fieldsOut,
            IList <PropertyDefinition> propertiesOutIgnored)
        {
            AnnotationCollection annotations = this.parser.AnnotationParser.ParseAnnotations(tokens);
            ModifierCollection   modifiers   = ModifierCollection.Parse(tokens);

            if (tokens.IsNext(this.parser.Keywords.FUNCTION))
            {
                methodsOut.Add(this.ParseFunction(tokens, classDef, fileScope, modifiers, annotations));
            }
            else if (tokens.IsNext(this.parser.Keywords.CONSTRUCTOR))
            {
                if (modifiers.HasStatic)
                {
                    if (classDef.StaticConstructor != null)
                    {
                        throw new ParserException(tokens.Pop(), "Multiple static constructors are not allowed.");
                    }

                    classDef.StaticConstructor = this.ParseConstructor(tokens, classDef, modifiers, annotations);
                }
                else
                {
                    if (classDef.Constructor != null)
                    {
                        throw this.parser.GenerateParseError(
                                  ErrorMessages.CLASS_CANNOT_HAVE_MULTIPLE_CONSTRUCTORS,
                                  tokens.Pop());
                    }

                    classDef.Constructor = this.ParseConstructor(tokens, classDef, modifiers, annotations);
                }
            }
            else if (tokens.IsNext(this.parser.Keywords.FIELD))
            {
                fieldsOut.Add(this.ParseField(tokens, classDef, modifiers, annotations));
            }
            else if (tokens.IsNext(this.parser.Keywords.CLASS))
            {
                throw new ParserException(tokens.Pop(), "Nested classes are not currently supported.");
            }
            else
            {
                tokens.PopExpected("}");
            }

            // TODO: check for annotations that aren't used.
            // https://github.com/blakeohare/crayon/issues/305
        }
Exemplo n.º 23
0
 public ModifierCollection(ModifierCollection oldCollection)
 {
     foreach (KeyValuePair <string, List <Modifier> > oldPair in oldCollection.Mods)
     {
         Mods.Add(oldPair.Key, new List <Modifier>());
         foreach (Modifier oldMod in oldPair.Value)
         {
             Mods[oldPair.Key].Add(new Modifier(oldMod));
         }
     }
 }
Exemplo n.º 24
0
    /// <summary>
    /// Modifiers list from database
    /// </summary>
    /// <returns></returns>
    private Modifier[] GetModifiers()
    {
        List <Modifier>    modifier          = new List <Modifier>();
        ModifierCollection matchingModifiers = ModifierList.GetModifierList();

        foreach (Modifier ModifierRow in matchingModifiers)
        {
            modifier.Add(new Modifier(ModifierRow.ModifierCode, ModifierRow.Description));
        }
        return(modifier.ToArray());
    }
Exemplo n.º 25
0
        /// <summary>
        /// Constructs a parse tree for variable declarations.
        /// </summary>
        /// <param name="attributes">The attributes on the declaration.</param>
        /// <param name="modifiers">The modifiers on the declaration.</param>
        /// <param name="variableDeclarators">The variables being declared.</param>
        /// <param name="span">The location of the parse tree.</param>
        /// <param name="comments">The comments for the parse tree.</param>
        public VariableListDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, VariableDeclaratorCollection variableDeclarators, Span span, IList <Comment> comments) : base(TreeType.VariableListDeclaration, attributes, modifiers, span, comments)
        {
            if (variableDeclarators == null)
            {
                throw new ArgumentNullException("variableDeclarators");
            }

            SetParent(variableDeclarators);

            _VariableDeclarators = variableDeclarators;
        }
        /// <summary>
        /// Constructs a new parse tree for a custom property declaration.
        /// </summary>
        /// <param name="attributes">The attributes on the declaration.</param>
        /// <param name="modifiers">The modifiers on the declaration.</param>
        /// <param name="customLocation">The location of the 'Custom' keyword.</param>
        /// <param name="keywordLocation">The location of the keyword.</param>
        /// <param name="name">The name of the custom event.</param>
        /// <param name="asLocation">The location of the 'As', if any.</param>
        /// <param name="resultType">The result type, if any.</param>
        /// <param name="implementsList">The implements list.</param>
        /// <param name="accessors">The custom event accessors.</param>
        /// <param name="endDeclaration">The End Event declaration, if any.</param>
        /// <param name="span">The location of the parse tree.</param>
        /// <param name="comments">The comments for the parse tree.</param>
        public CustomEventDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location customLocation, Location keywordLocation, SimpleName name, Location asLocation, TypeName resultType, NameCollection implementsList, DeclarationCollection accessors, EndBlockDeclaration endDeclaration,
                                      Span span, IList <Comment> comments) : base(TreeType.CustomEventDeclaration, attributes, modifiers, keywordLocation, name, null, null, asLocation, null, resultType,
                                                                                  span, comments)
        {
            SetParent(accessors);
            SetParent(endDeclaration);
            SetParent(implementsList);

            _CustomLocation = customLocation;
            _ImplementsList = implementsList;
            _Accessors      = accessors;
            _EndDeclaration = endDeclaration;
        }
Exemplo n.º 27
0
        protected MethodDeclaration(
            TreeType type,
            AttributeBlockCollection attributes,
            ModifierCollection modifiers,
            Location keywordLocation,
            SimpleName name,
            TypeParameterCollection typeParameters,
            ParameterCollection parameters,
            Location asLocation,
            AttributeBlockCollection resultTypeAttributes,
            TypeName resultType,
            NameCollection implementsList,
            NameCollection handlesList,
            StatementCollection statements,
            EndBlockDeclaration endDeclaration,
            Span span,
            IList <Comment> comments
            ) :
            base(
                type,
                attributes,
                modifiers,
                keywordLocation,
                name,
                typeParameters,
                parameters,
                asLocation,
                resultTypeAttributes,
                resultType,
                span,
                comments
                )
        {
            Debug.Assert(
                type == TreeType.SubDeclaration ||
                type == TreeType.FunctionDeclaration ||
                type == TreeType.ConstructorDeclaration ||
                type == TreeType.OperatorDeclaration ||
                type == TreeType.PropertyDeclaration
                );

            SetParent(endDeclaration);
            SetParent(implementsList);
            SetParent(handlesList);
            SetParent(statements);

            _ImplementsList = implementsList;
            _HandlesList    = handlesList;
            _Statements     = statements;
            _EndDeclaration = endDeclaration;
        }
Exemplo n.º 28
0
 public void Add(ModifierCollection newMods)
 {
     foreach (KeyValuePair <string, List <Modifier> > pair in newMods.Mods)
     {
         if (!Mods.ContainsKey(pair.Key))
         {
             Mods.Add(pair.Key, new List <Modifier>(pair.Value));
         }
         else
         {
             Mods[pair.Key].AddRange(pair.Value);
         }
     }
 }
Exemplo n.º 29
0
 public bool CallModifierStateChangedHooks(ModifierCollection modifiers, ModId id, bool newState)
 {
     foreach (var hook in modifierStateChangedHooks)
     {
         if (!hook.IsEnabled)
         {
             continue;
         }
         if (!hook.Call(modifiers, id, ref newState))
         {
             break;
         }
     }
     return(newState);
 }
Exemplo n.º 30
0
        /// <summary>
        /// Constructs a parse tree for a namespace VBConverter.CodeParser.declaration.
        /// </summary>
        /// <param name="attributes">The attributes on the declaration.</param>
        /// <param name="modifiers">The modifiers on the declaration.</param>
        /// <param name="namespaceLocation">The location of 'Namespace'.</param>
        /// <param name="name">The name of the namespace.</param>
        /// <param name="declarations">The declarations in the namespace.</param>
        /// <param name="endDeclaration">The End Namespace statement, if any.</param>
        /// <param name="span">The location of the parse tree.</param>
        /// <param name="comments">The comments for the parse tree.</param>
        public NamespaceDeclaration(AttributeBlockCollection attributes, ModifierCollection modifiers, Location namespaceLocation, Name name, DeclarationCollection declarations, EndBlockDeclaration endDeclaration, Span span, IList <Comment> comments) : base(TreeType.NamespaceDeclaration, attributes, modifiers, span, comments)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            SetParent(name);
            SetParent(declarations);
            SetParent(endDeclaration);

            _NamespaceLocation = namespaceLocation;
            _Name           = name;
            _Declarations   = declarations;
            _EndDeclaration = endDeclaration;
        }
Exemplo n.º 31
0
        protected PropertyDefinition ParseProperty(
            TokenStream tokens,
            ClassDefinition classDef,
            FileScope fileScope,
            ModifierCollection modifiers,
            AnnotationCollection annotations)
        {
            AType propertyType = this.parser.TypeParser.Parse(tokens);

            tokens.EnsureNotEof();
            Token propertyName = tokens.PopIfWord();

            if (propertyName == null)
            {
                throw new ParserException(tokens.Peek(), "Expected property name.");
            }
            tokens.PopExpected("{");
            PropertyMember     getter   = null;
            PropertyMember     setter   = null;
            PropertyDefinition property = new PropertyDefinition(propertyType.FirstToken, classDef, fileScope, modifiers);

            while (!tokens.PopIfPresent("}"))
            {
                PropertyMember member = this.ParsePropertyMember(tokens, property);
                if (member.IsGetter)
                {
                    if (getter != null)
                    {
                        throw new ParserException(member.FirstToken, "Property has multiple getters");
                    }
                    getter = member;
                }
                else if (member.IsSetter)
                {
                    if (setter != null)
                    {
                        throw new ParserException(member.FirstToken, "Property has multiple setters");
                    }
                    setter = member;
                }
            }

            property.Getter = getter;
            property.Setter = setter;

            return(property);
        }
Exemplo n.º 32
0
 // Copy Constructor
 public Item(Item oldItem)
 {
     this.Weight             = oldItem.Weight;
     this.Cost               = oldItem.Cost;
     this.Description        = oldItem.Description;
     this.Name               = oldItem.Name;
     this.Requirement        = oldItem.Requirement;
     this.Hands              = oldItem.Hands;
     this.Modifiers          = new ModifierCollection(oldItem.Modifiers);
     this.Damage1H           = oldItem.Damage1H;
     this.Damage2H           = oldItem.Damage2H;
     this.DamageType         = oldItem.DamageType;
     this.Range              = oldItem.Range;
     this.LongRange          = oldItem.LongRange;
     this.Properties         = new List <string>(oldItem.Properties);
     this.RequiresAttunement = oldItem.RequiresAttunement;
 }
Exemplo n.º 33
0
        private ModifierCollection GetNoDirModifiers(string moduleRootDir, DirectoryInfo dir)
        {
            ModifierCollection list = new ModifierCollection();

            Modifier m = new Modifier();
            m.ActionMode = ActionType.UpdateFile;
            m.FileMode = FileType.Directory;
            m.Path = PathHelper.GetServerPath(moduleRootDir, dir.FullName);
            list.Add(m);

            foreach (FileInfo file in dir.GetFiles())
            {
                Modifier fm = new Modifier();
                fm.FileMode = FileType.File;
                fm.ActionMode = ActionType.UpdateFile;
                fm.Path = file.FullName;
                list.Add(fm);
            }

            foreach (DirectoryInfo sub in dir.GetDirectories())
            {
                list.Import(GetNoDirModifiers(moduleRootDir, sub));
            }

            return list;
        }
Exemplo n.º 34
0
 IEnumerable<IModifier> CreateModifiers(ModifierCollection modifierCollection)
 {
     return from c in modifierCollection
            let type = Type.GetType(c.Type, true)
            select (IModifier)Activator.CreateInstance(type);
 }
 internal unsafe override void ExecuteModifiers(ModifierCollection modifiers, float elapsedSeconds, ref Particle particle, int index, int count)
 {
     var p = particle;
     System.Threading.Tasks.Parallel.ForEach(modifiers.Slots, slot => slot.Update(elapsedSeconds, ref p, index, count));
 }
Exemplo n.º 36
0
        public ModifierCollection CheckUploadModifier()
        {
            ModifierCollection modifiers = new ModifierCollection();
            if (string.IsNullOrWhiteSpace(this.LocalPath)) return modifiers;

            XmlElement dirElement = this.Source.GetElement("Directory");
            DirectoryInfo dir = new DirectoryInfo(this.LocalPath);
            return this.CompareDir(dir, dirElement);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Instantiates a new instance of the Emitter class.
        /// </summary>
        public Emitter()
        {
            this.Name = Emitter.NextEmitterName();

            this.Enabled = true;

            this.Modifiers = new ModifierCollection();
        }
Exemplo n.º 38
0
 /// <summary>
 /// Instantiates a new instance of the Emitter class.
 /// </summary>
 public Emitter()
 {
     this.Triggers = new Queue<Vector2>();
     this.Modifiers = new ModifierCollection();
 }
 internal unsafe abstract void ExecuteModifiers(ModifierCollection modifiers, float elapsedSeconds, ref Particle particle, int index, int count);
Exemplo n.º 40
0
        private ModifierCollection CompareDir(DirectoryInfo dir, XmlElement dirElement)
        {
            ModifierCollection list = new ModifierCollection();

            XmlHelper h = new XmlHelper(dirElement);
            foreach (XmlElement subDir in h.GetElements("Directory"))
            {
                string name = subDir.GetAttribute("Name");
                DirectoryInfo sd = null;
                foreach (DirectoryInfo sub in dir.GetDirectories())
                {
                    if (sub.Name == name)
                    {
                        sd = sub;
                        break;
                    }
                }
                if (sd == null)
                {
                    Modifier m = new Modifier();
                    m.ActionMode = ActionType.SendDelete;
                    m.FileMode = FileType.Directory;
                    m.Path = PathHelper.GetServerPath(this, subDir);
                    list.Add(m);
                }
                else
                {
                    ModifierCollection mc = CompareDir(sd, subDir);
                    list.Import(mc);
                }
            }

            foreach (DirectoryInfo sub in dir.GetDirectories())
            {
                if (h.GetElement("Directory[@Name='" + sub.Name + "']") == null)
                {
                    ModifierCollection mc = this.GetNoDirModifiers(this.LocalPath, sub);
                    list.Import(mc);
                }
            }

            foreach (XmlElement subFile in h.GetElements("File"))
            {
                string name = subFile.GetAttribute("Name");
                FileInfo file = null;
                foreach (FileInfo sub in dir.GetFiles())
                {
                    if (sub.Name != name)
                        continue;
                    file = sub;
                    break;
                }
                if (file == null)
                {
                    Modifier m = new Modifier();
                    m.ActionMode = ActionType.SendDelete;
                    m.FileMode = FileType.File;
                    m.Path = PathHelper.GetServerPath(this, subFile);
                    list.Add(m);
                }
                else
                {
                    string md5 = subFile.GetAttribute("MD5");
                    string fileMD5 = this.ComputeFileMD5(file);

                    if (md5 != fileMD5)
                    {
                        Modifier m = new Modifier();
                        m.ActionMode = ActionType.UpdateFile;
                        m.FileMode = FileType.File;
                        m.Path = file.FullName;
                        list.Add(m);
                    }
                }
            }

            foreach (FileInfo sub in dir.GetFiles())
            {
                if (h.GetElement("File[@Name='" + sub.Name + "']") == null)
                {
                    Modifier m = new Modifier();
                    m.ActionMode = ActionType.UpdateFile;
                    m.FileMode = FileType.File;
                    m.Path = sub.FullName;
                    list.Add(m);
                }
            }
            return list;
        }