コード例 #1
0
		public void AddDerivedTransformation(GameObject gameObject, DerivedTransformationObject derivedTransformationObject)
		{
			if (gameObject != null && derivedTransformationObject.BaseTransformationObject != null)
			{
				this.objectMap.Add(gameObject, derivedTransformationObject);
				if (this.objectMap.Count == 1)
				{
					Service.Get<ViewTimeEngine>().RegisterFrameTimeObserver(this);
				}
			}
		}
コード例 #2
0
		public void OnViewFrameTime(float dt)
		{
			foreach (KeyValuePair<GameObject, DerivedTransformationObject> current in this.objectMap)
			{
				GameObject key = current.get_Key();
				DerivedTransformationObject value = current.get_Value();
				if (key == null)
				{
					if (!this.alreadyLoggedGameObjectNullError)
					{
						string text = "destroyed";
						if (value.BaseTransformationObject != null)
						{
							text = value.BaseTransformationObject.name;
						}
						Service.Get<StaRTSLogger>().ErrorFormat("GameObject being added to DerivedTransformationManager is being destroyed. Associated base object is {0}.", new object[]
						{
							text
						});
						this.alreadyLoggedGameObjectNullError = true;
					}
				}
				else if (!(value.BaseTransformationObject == null))
				{
					Transform transform = key.transform;
					transform.position = value.BaseTransformationObject.transform.position + value.PositionOffset;
					if (value.IsUpdateRotation)
					{
						if (value.AddRelativeRotation)
						{
							transform.rotation = GameUtils.ApplyRelativeRotation(value.RelativeRotation, value.BaseTransformationObject.transform.rotation);
						}
						else
						{
							transform.rotation = value.BaseTransformationObject.transform.rotation;
						}
					}
				}
			}
		}