public void StartFade(Direction direction, float duration = 1.0f) { Conditions.Assert(duration > 0.0f, "Duration has to be greater than 0"); this.startTime = Time.time; this.duration = duration; this.direction = direction; }
public void EndGraph() { Conditions.Assert(indentLevel > 0, "Can't end a graph when indentLevel is 0!"); Outdent(); WriteIndentation(); writer.WriteLine("}"); }
void UpdateTriggerState(bool newState) { Conditions.Assert(!(inTriggerRecursion & newState), "Recursion in trigger, backing out"); inTriggerRecursion = true; triggered = newState; Vector3 scale = transform.localScale; scale.y = triggered ? initialScaleY / 5.0f : initialScaleY; transform.localScale = scale; foreach (TriggerTarget trigger in target) { trigger.Trigger(this); } if (triggered && disable != null) { foreach (Trigger trigger in disable) { trigger.UpdateTriggerState(false); } } if (triggered && enable != null) { foreach (Trigger trigger in enable) { trigger.UpdateTriggerState(true); } } inTriggerRecursion = false; }
public override TypeDefinition Generate(IErrorReporter errorReporter) { // If an entry-point is declared that has no injectables (i.e. a primitive type), // there's nothing to emit. if ((InjectableCtor == null || !InjectableCtor.CustomAttributes.Any(Attributes.IsInjectAttribute)) && InjectableProperties.Count == 0 && BaseTypeKey == null) { Conditions.Assert(IsModuleInjectable, "Non-injectable types must have a constructor!"); return(null); } var injectBinding = new TypeDefinition( injectedType.Namespace, injectedType.Name + CodegenLoader.InjectSuffix, injectedType.Attributes, References.Binding); injectBinding.CustomAttributes.Add(new CustomAttribute(References.CompilerGeneratedAttribute)); var propertyFields = new List <FieldDefinition>(InjectableProperties.Count); foreach (var property in InjectableProperties) { var propertyBinding = new FieldDefinition(property.PropertyName, FieldAttributes.Private, References.Binding); injectBinding.Fields.Add(propertyBinding); propertyFields.Add(propertyBinding); } FieldDefinition ctorParamsField = null; if (CtorParams.Count > 0) { ctorParamsField = new FieldDefinition("ctorParamBindings", FieldAttributes.Private, References.BindingArray); injectBinding.Fields.Add(ctorParamsField); } FieldDefinition baseTypeField = null; if (BaseTypeKey != null) { baseTypeField = new FieldDefinition("baseTypeBinding", FieldAttributes.Private, References.Binding); injectBinding.Fields.Add(baseTypeField); } EmitCtor(injectBinding); EmitResolve(injectBinding, propertyFields, ctorParamsField, baseTypeField); EmitGetDependencies(injectBinding, propertyFields, ctorParamsField, baseTypeField); var injectProperties = EmitInjectProperties(injectBinding, baseTypeField, propertyFields); EmitGet(injectBinding, injectProperties, ctorParamsField); if (injectedType.DeclaringType != null) { injectBinding.DeclaringType = injectedType.DeclaringType; } return(injectBinding); }
public void Trigger(Trigger trigger) { Conditions.Assert(allTriggers.Contains(trigger), "Goal triggered by unknown trigger"); if (!enabledTriggers.Remove(trigger)) { enabledTriggers.Add(trigger); } }
public void RegisterTrigger(Trigger trigger) { Conditions.Assert(!allTriggers.Contains(trigger), "Trying to register trigger, but trigger already registered"); allTriggers.Add(trigger); if (trigger.Triggered) { enabledTriggers.Add(trigger); } }
private void WriteAttributes(string[] attributes) { if (attributes.Length == 0) { return; } Conditions.Assert((attributes.Length & 1) == 0, "Invalid attributes (odd number)"); for (var i = 0; i < attributes.Length; i += 2) { WriteIndentation(); writer.Write(attributes[i]); writer.Write(" = \""); writer.Write(attributes[i + 1]); writer.WriteLine("\";"); } }